Skip to content

Commit 9b2c630

Browse files
sergiomb2twaugh
andcommitted
Patchview addon are 3 bash and 1 python scripts
tools (scripts) to work under svn and git repos . Version 2020-06-26 Update patchview/README.patchview Co-authored-by: Tim Waugh <[email protected]>
1 parent 59182fb commit 9b2c630

File tree

6 files changed

+159
-0
lines changed

6 files changed

+159
-0
lines changed

Makefile.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ bin_SCRIPTS = \
1010
scripts/dehtmldiff \
1111
scripts/espdiff
1212

13+
dist_bin_SCRIPTS = \
14+
patchview/gitdiff \
15+
patchview/gitdiffview \
16+
patchview/svndiff \
17+
patchview/svndiffview
18+
1319
AM_CFLAGS = -I$(srcdir)/src
1420
src_interdiff_SOURCES = src/interdiff.c src/util.c src/util.h src/diff.c \
1521
src/diff.h src/myerror.c

patchview/README.patchview

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
So what is patchview? It is a wrapper of filterdiff for use with numbered files.
2+
3+
$ patchview
4+
(without args)
5+
6+
is equivalent to: lsdiff --number
7+
8+
$ patchview -F2-
9+
(or with any other args)
10+
11+
is equivalent to: filterdiff -F2- (or whatever arguments are supplied)
12+
13+
There are two scripts for working with git (gitdiff and gitdiffview) and two for svn (svndiff and svndiffview).
14+
15+
$ svndiff
16+
$ gitdiff
17+
(without args)
18+
19+
will give the list of files modified
20+
21+
$ svndiff -F1
22+
$ gitdiff -F1
23+
24+
will show the patch of file #1
25+
26+
$ svndiffview
27+
$ gitdiffview
28+
29+
pipe all patches through filterdiff to `vim - -R` (in read-only mode, easy to quit), showing complete patch with color.
30+
31+
$ svndiffview -F2
32+
$ gitdiffview -F2
33+
(or any other args)
34+
35+
will pipe patch of file #2 to `vim - -R`
36+
37+
Example:
38+
We can make the following one-line script with the name difftotrunk.sh, to view the differences of two directories or svn repos (trunk and .)
39+
40+
diff ../trunk . -ru -x .svn | patchview "$@"
41+
42+
$ ./difftotrunk.sh , will show all different files and his number.
43+
$ ./difftotrunk.sh -F3,4 , will show the differences of files #3 and #4 only.
44+
$ ./difftotrunk.sh -F3 -#1, will show only hunk #1 of file #3.
45+
$ ./difftotrunk.sh -F3 -#x1, will show the differences of files #3 without hunk #1 (x means that exclude).
46+

patchview/gitdiff

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (C) 2015-2019 Sérgio Basto <[email protected]>
5+
#
6+
# This program is free software; you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation; either version 2 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
#
20+
21+
import os
22+
import sys
23+
import argparse
24+
from subprocess import Popen, PIPE
25+
26+
enviro = os.environ
27+
workdir = '.'
28+
29+
parser = argparse.ArgumentParser()
30+
parser.add_argument('-v', '--debug',
31+
help='writes the commands that will be executed',
32+
action='store_true')
33+
parser.add_argument('git_args', nargs='*', default=[])
34+
parser.add_argument('patchview_args', nargs=argparse.REMAINDER)
35+
args, unknown = parser.parse_known_args()
36+
largs = vars(args).get("git_args")
37+
rargs = vars(args).get("patchview_args")
38+
39+
if args.debug:
40+
print("%s | %s" % (" ".join(['git', 'diff'] + largs),
41+
" ".join(['patchview'] + rargs + unknown)))
42+
43+
p1 = Popen(['git', 'diff'] + largs, stdout=PIPE, env=enviro, cwd=workdir)
44+
p2 = Popen(['patchview'] + rargs + unknown, stdin=p1.stdout, stdout=PIPE,
45+
env=enviro, cwd=workdir)
46+
p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
47+
sys.stdout.buffer.write(p2.communicate()[0])

patchview/gitdiffview

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (C) 2014-2019 Sérgio Basto <[email protected]>
4+
#
5+
# This program is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation; either version 2 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program; if not, write to the Free Software
17+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18+
#
19+
20+
gitdiff --filter "$@" | vim -R -

patchview/svndiff

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (C) 2014-2019 Sérgio Basto <[email protected]>
4+
#
5+
# This program is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation; either version 2 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program; if not, write to the Free Software
17+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18+
#
19+
20+
svn diff | patchview "$@"

patchview/svndiffview

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (C) 2014-2019 Sérgio Basto <[email protected]>
4+
#
5+
# This program is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation; either version 2 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program; if not, write to the Free Software
17+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18+
#
19+
20+
svndiff --filter "$@" | vim -R -

0 commit comments

Comments
 (0)