Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel Diffbreaker a utility for manipulating unified d...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/71bd48b43054
branches:  trunk
changeset: 432692:71bd48b43054
user:      nat <nat%pkgsrc.org@localhost>
date:      Sun May 24 16:44:19 2020 +0000

description:
Diffbreaker a utility for manipulating unified diffs interactively
with curses(3).

diffstat:

 devel/Makefile                                    |    3 +-
 devel/diffbreaker/DESCR                           |    2 +
 devel/diffbreaker/Makefile                        |   46 +
 devel/diffbreaker/PLIST                           |    3 +
 devel/diffbreaker/files/diffbreaker/Makefile      |    9 +
 devel/diffbreaker/files/diffbreaker/diffbreaker.1 |   96 +++
 devel/diffbreaker/files/diffbreaker/diffbreaker.c |  683 ++++++++++++++++++++++
 7 files changed, 841 insertions(+), 1 deletions(-)

diffs (truncated from 880 to 300 lines):

diff -r 2ad61874fae8 -r 71bd48b43054 devel/Makefile
--- a/devel/Makefile    Sun May 24 14:17:33 2020 +0000
+++ b/devel/Makefile    Sun May 24 16:44:19 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3134 2020/05/23 08:19:22 adam Exp $
+# $NetBSD: Makefile,v 1.3135 2020/05/24 16:44:19 nat Exp $
 #
 
 COMMENT=       Development utilities
@@ -264,6 +264,7 @@
 SUBDIR+=       devhelp
 SUBDIR+=       device-driver-doc-de
 SUBDIR+=       dia2code
+SUBDIR+=       diffbreaker
 SUBDIR+=       diffuse
 SUBDIR+=       diffutils
 SUBDIR+=       distcc
diff -r 2ad61874fae8 -r 71bd48b43054 devel/diffbreaker/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/diffbreaker/DESCR   Sun May 24 16:44:19 2020 +0000
@@ -0,0 +1,2 @@
+Diffbreaker allows the user to create incremental patches
+from a single unified diff interactively using curses.
diff -r 2ad61874fae8 -r 71bd48b43054 devel/diffbreaker/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/diffbreaker/Makefile        Sun May 24 16:44:19 2020 +0000
@@ -0,0 +1,46 @@
+# $NetBSD: Makefile,v 1.1 2020/05/24 16:44:20 nat Exp $
+
+PKGNAME=       diffbreaker-0.1
+#PKGREVISION=  1
+CATEGORIES=    devel
+
+MAINTAINER=    nat%NetBSD.org@localhost
+COMMENT=       Tool to manuipulate unified diffs using curses
+LICENSE=       2-clause-bsd
+
+NO_CONFIGURE=  yes
+
+USE_LANGUAGES= c
+USE_TOOLS=     make
+
+.include "../../mk/bsd.prefs.mk"
+
+BUILD_DEFS+=   MANINSTALL
+
+INSTALLATION_DIRS=     bin
+.if !empty(MANINSTALL:Mcatinstall)
+INSTALLATION_DIRS+=    ${PKGMANDIR}/cat1
+.endif
+.if !empty(MANINSTALL:Mmaninstall)
+INSTALLATION_DIRS+=    ${PKGMANDIR}/man1
+.endif
+
+pre-build:
+       ${CP} -R ${FILESDIR}/diffbreaker ${WRKSRC}
+
+do-install:
+.for f in diffbreaker
+       ${INSTALL_SCRIPT} ${WRKSRC}/${f} ${DESTDIR}${PREFIX}/bin
+.  if !empty(MANINSTALL:Mcatinstall)
+.    if defined(CATMAN_SECTION_SUFFIX) && !empty(CATMAN_SECTION_SUFFIX:M[Yy][Ee][Ss])
+       ${INSTALL_MAN} ${WRKSRC}/${f}.0 ${DESTDIR}${PREFIX}/${PKGMANDIR}/cat1/${f}.1
+.    else
+       ${INSTALL_MAN} ${WRKSRC}/${f}.0 ${DESTDIR}${PREFIX}/${PKGMANDIR}/cat1
+.    endif
+.  endif
+.  if !empty(MANINSTALL:Mmaninstall)
+       ${INSTALL_MAN} ${WRKSRC}/${f}.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1
+.  endif
+.endfor
+
+.include "../../mk/bsd.pkg.mk"
diff -r 2ad61874fae8 -r 71bd48b43054 devel/diffbreaker/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/diffbreaker/PLIST   Sun May 24 16:44:19 2020 +0000
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1 2020/05/24 16:44:20 nat Exp $
+bin/diffbreaker
+man/man1/diffbreaker.1
diff -r 2ad61874fae8 -r 71bd48b43054 devel/diffbreaker/files/diffbreaker/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/diffbreaker/files/diffbreaker/Makefile      Sun May 24 16:44:19 2020 +0000
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2020/05/24 16:44:20 nat Exp $
+
+PROG=  diffbreaker
+MAN=   diffbreaker.1
+DPADD= ${LIBCURSES} ${LIBTERMINFO}
+LDADD= -lcurses -lterminfo
+
+WARNS?=        6
+.include <bsd.prog.mk>
diff -r 2ad61874fae8 -r 71bd48b43054 devel/diffbreaker/files/diffbreaker/diffbreaker.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/diffbreaker/files/diffbreaker/diffbreaker.1 Sun May 24 16:44:19 2020 +0000
@@ -0,0 +1,96 @@
+.\"    $NetBSD: diffbreaker.1,v 1.1 2020/05/24 16:44:20 nat Exp $
+.\"
+.\" Copyright (c) 2020 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd April 10, 2020
+.Dt DIFFBREAKER 1
+.Os
+.Sh NAME
+.Nm diffbreaker
+.Nd unified diff cherry picker / patch set editor
+.Sh SYNOPSIS
+.Nm
+.Op Fl s
+.Fl i Ar input file
+.Fl o Ar output file
+.Sh DESCRIPTION
+The
+.Nm
+command allows the user to create incremental patches from a single unified diff
+interactively using
+.Xr curses 3 .
+.Bl -tag -indent width
+.It Fl i Ar input file
+Unified diff input file.
+.It Fl o Ar output file / beginning of file path.
+Output location / file.
+A file name of "-" means to write to stderr, useful for redirecting the output.
+.It Op Fl s 
+If the
+.Op Fl s
+switch is given the output file argument is a prefix and path for files to be
+output.
+Files are written from output file.1.diff etc.
+.PP
+If no
+.Op Fl s
+switch is
+.Em not
+given the output file is appended to on each subsequent
+write.
+.El
+.Sh KEYS
+.Nm
+accepts the following keys:
+.Bl -tag -indent width
+.It [SPACE]
+Select / Un-select change.
+.It [l]
+Redraw the current screen.
+.It [j]
+Move down 1 line.
+.It [k]
+Move up 1 line.
+.It [G]
+Move to the beginning of the diff.
+.It [g]
+Move to the end of the diff.
+.It [w]
+Write changes to output file(s).
+Clearing sections from the screen in which all changes within a block or file
+have been written and return to the top of the diff.
+.It [q]
+Quit the program,
+.Em DISCARDING
+any unsaved changes.
+.Sh STATUS LINE
+At the bottom of the screen the number of unwritten lines in the buffer is
+displayed.
+.Sh SEE ALSO
+.Xr curses 3
+.Xr diff 1
+.Xr patch 1
+.Sh AUTHORS
+Nathanial Sloss
diff -r 2ad61874fae8 -r 71bd48b43054 devel/diffbreaker/files/diffbreaker/diffbreaker.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/diffbreaker/files/diffbreaker/diffbreaker.c Sun May 24 16:44:19 2020 +0000
@@ -0,0 +1,683 @@
+/* $NetBSD: diffbreaker.c,v 1.1 2020/05/24 16:44:20 nat Exp $ */
+
+/*-
+ * Copyright (c) 2018, 2019 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <curses.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+ssize_t finalize_context(ssize_t context, ssize_t current, ssize_t secthead,
+                    ssize_t first, ssize_t part, ssize_t origoffs,
+                    ssize_t newoffs, ssize_t last, ssize_t pos);
+ssize_t update_context(ssize_t lines, ssize_t current, ssize_t last);
+ssize_t get_context(ssize_t current, ssize_t last, ssize_t num);
+void print_buffer(ssize_t myLine, ssize_t dispLines);
+void parse_buffer(char *outfile, bool incremental, uint32_t filesuffix);
+void read_data_to_buffer(char *myFile);
+void free_buffers_actions(void);
+void setup_screen(void);
+void mark_dirty(void);
+#ifndef __dead
+#define __dead __attribute__((__noreturn__))
+#endif
+#ifdef __linux__
+extern char *__progname;
+#define getprogname()  __progname
+#endif
+
+__dead static void usage(void);
+
+int dispLine, promptLine, scrcols, scrlines;
+int displayLines;
+WINDOW *mywin = NULL;
+static char *buffer;
+static char *newbuffer;
+static char *action;
+static char *newaction;
+static ssize_t currentLine, totalLines, cpl;
+
+#define ORIGBUF(x)     (buffer + ((x) * cpl))
+#define NEWBUF(x)      (newbuffer + ((x) * cpl))
+
+#define COLORTEXT(x)                           \
+       do {                                    \
+               if (has_colors())                       \
+                       attrset(COLOR_PAIR(x)); \
+               else                            \
+                       attrset(A_REVERSE);     \
+       } while (0)                                             
+
+#define NORMALTEXT                             \
+       do {                                    \
+               if (has_colors())                       \
+                       attrset(COLOR_PAIR(1)); \
+               else                            \
+                       attrset(A_NORMAL);      \
+       } while (0)                                             
+void
+mark_dirty(void)
+{
+       bool writetome = false, display = false;
+       bool pending = false, writesect = false;
+       ssize_t i, j = 0, last = 0, myfile = 0;
+
+       j = 0;
+       for (i = 0; i < totalLines; i++) {
+               switch (action[i]) {
+               case 2: /* Selected */
+                       if (*ORIGBUF(i) == '-') {
+                               continue;
+                       }
+                       if (*ORIGBUF(i) == '+') {
+                               if (j != i)



Home | Main Index | Thread Index | Old Index