annotate hgext/extdiff.py @ 2675:d99a92b7acad

extdiff : add comment on how to use vim for doing directoy diff
author "Mathieu Clabaut <mathieu.clabaut@gmail.com>"
date Tue, 25 Jul 2006 23:10:11 +0200
parents 391c5d0f9ef3
children 3d6efcbbd1c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2333
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
1 # extdiff.py - external diff program support for mercurial
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
2 #
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
3 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
4 #
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
6 # of the GNU General Public License, incorporated herein by reference.
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
7 #
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
8 # allow to use external programs to compare revisions, or revision
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
9 # with working dir. program is called with two arguments: paths to
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
10 # directories containing snapshots of files to compare.
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
11 #
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
12 # to enable:
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
13 #
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
14 # [extensions]
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
15 # hgext.extdiff =
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
16 #
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
17 # also allows to configure new diff commands, so you do not need to
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
18 # type "hg extdiff -p kdiff3" always.
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
19 #
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
20 # [extdiff]
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
21 # # add new command called vdiff, runs kdiff3
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
22 # cmd.vdiff = kdiff3
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
23 # # add new command called meld, runs meld (no need to name twice)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
24 # cmd.meld =
2675
d99a92b7acad extdiff : add comment on how to use vim for doing directoy diff
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents: 2338
diff changeset
25 # # add new command called vimdiff, runs gvimdiff with DirDiff plugin
d99a92b7acad extdiff : add comment on how to use vim for doing directoy diff
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents: 2338
diff changeset
26 # #(see http://www.vim.org/scripts/script.php?script_id=102)
d99a92b7acad extdiff : add comment on how to use vim for doing directoy diff
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents: 2338
diff changeset
27 # cmd.vimdiff = LC_ALL=C gvim -f '+bdel 1 2' '+ execute "DirDiff ".argv(0)." ".argv(1)'
2333
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
28 #
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
29 # you can use -I/-X and list of file or directory names like normal
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
30 # "hg diff" command. extdiff makes snapshots of only needed files, so
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
31 # compare program will be fast.
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
32
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
33 from mercurial.demandload import demandload
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
34 from mercurial.i18n import gettext as _
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
35 from mercurial.node import *
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
36 demandload(globals(), 'mercurial:commands,util os shutil tempfile')
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
37
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
38 def dodiff(ui, repo, diffcmd, pats, opts):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
39 def snapshot_node(files, node):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
40 '''snapshot files as of some revision'''
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
41 changes = repo.changelog.read(node)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
42 mf = repo.manifest.read(changes[0])
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
43 dirname = '%s.%s' % (os.path.basename(repo.root), short(node))
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
44 base = os.path.join(tmproot, dirname)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
45 os.mkdir(base)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
46 if not ui.quiet:
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
47 ui.write_err(_('making snapshot of %d files from rev %s\n') %
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
48 (len(files), short(node)))
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
49 for fn in files:
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
50 wfn = util.pconvert(fn)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
51 ui.note(' %s\n' % wfn)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
52 dest = os.path.join(base, wfn)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
53 destdir = os.path.dirname(dest)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
54 if not os.path.isdir(destdir):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
55 os.makedirs(destdir)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
56 repo.wwrite(wfn, repo.file(fn).read(mf[fn]), open(dest, 'w'))
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
57 return dirname
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
58
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
59 def snapshot_wdir(files):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
60 '''snapshot files from working directory.
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
61 if not using snapshot, -I/-X does not work and recursive diff
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
62 in tools like kdiff3 and meld displays too many files.'''
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
63 dirname = os.path.basename(repo.root)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
64 base = os.path.join(tmproot, dirname)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
65 os.mkdir(base)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
66 if not ui.quiet:
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
67 ui.write_err(_('making snapshot of %d files from working dir\n') %
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
68 (len(files)))
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
69 for fn in files:
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
70 wfn = util.pconvert(fn)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
71 ui.note(' %s\n' % wfn)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
72 dest = os.path.join(base, wfn)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
73 destdir = os.path.dirname(dest)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
74 if not os.path.isdir(destdir):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
75 os.makedirs(destdir)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
76 fp = open(dest, 'w')
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
77 for chunk in util.filechunkiter(repo.wopener(wfn)):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
78 fp.write(chunk)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
79 return dirname
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
80
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
81 node1, node2 = commands.revpair(ui, repo, opts['rev'])
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
82 files, matchfn, anypats = commands.matchpats(repo, pats, opts)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
83 modified, added, removed, deleted, unknown = repo.changes(
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
84 node1, node2, files, match=matchfn)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
85 if not (modified or added or removed):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
86 return 0
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
87
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
88 tmproot = tempfile.mkdtemp(prefix='extdiff.')
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
89 try:
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
90 dir1 = snapshot_node(modified + removed, node1)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
91 if node2:
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
92 dir2 = snapshot_node(modified + added, node2)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
93 else:
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
94 dir2 = snapshot_wdir(modified + added)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
95 util.system('%s %s "%s" "%s"' %
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
96 (diffcmd, ' '.join(opts['option']), dir1, dir2),
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
97 cwd=tmproot)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
98 return 1
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
99 finally:
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
100 ui.note(_('cleaning up temp directory\n'))
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
101 shutil.rmtree(tmproot)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
102
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
103 def extdiff(ui, repo, *pats, **opts):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
104 '''use external program to diff repository (or selected files)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
105
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
106 Show differences between revisions for the specified files, using
2338
391c5d0f9ef3 Minor typo change to reflect actual values used.
"Daniel Santa Cruz <dansan@vikus.com>"
parents: 2333
diff changeset
107 an external program. The default program used is "diff -Npru".
2333
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
108 To select a different program, use the -p option. The program
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
109 will be passed the names of two directories to compare. To pass
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
110 additional options to the program, use the -o option. These will
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
111 be passed before the names of the directories to compare.
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
112
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
113 When two revision arguments are given, then changes are
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
114 shown between those revisions. If only one revision is
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
115 specified then that revision is compared to the working
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
116 directory, and, when no revisions are specified, the
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
117 working directory files are compared to its parent.'''
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
118 return dodiff(ui, repo, opts['program'] or 'diff -Npru', pats, opts)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
119
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
120 cmdtable = {
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
121 "extdiff":
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
122 (extdiff,
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
123 [('p', 'program', '', _('comparison program to run')),
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
124 ('o', 'option', [], _('pass option to comparison program')),
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
125 ('r', 'rev', [], _('revision')),
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
126 ('I', 'include', [], _('include names matching the given patterns')),
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
127 ('X', 'exclude', [], _('exclude names matching the given patterns'))],
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
128 _('hg extdiff [OPT]... [FILE]...')),
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
129 }
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
130
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
131 def uisetup(ui):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
132 for cmd, path in ui.configitems('extdiff'):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
133 if not cmd.startswith('cmd.'): continue
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
134 cmd = cmd[4:]
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
135 if not path: path = cmd
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
136 def save(cmd, path):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
137 '''use closure to save diff command to use'''
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
138 def mydiff(ui, repo, *pats, **opts):
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
139 return dodiff(ui, repo, path, pats, opts)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
140 mydiff.__doc__ = '''use %s to diff repository (or selected files)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
141
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
142 Show differences between revisions for the specified
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
143 files, using the %s program.
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
144
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
145 When two revision arguments are given, then changes are
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
146 shown between those revisions. If only one revision is
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
147 specified then that revision is compared to the working
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
148 directory, and, when no revisions are specified, the
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
149 working directory files are compared to its parent.''' % (cmd, cmd)
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
150 return mydiff
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
151 cmdtable[cmd] = (save(cmd, path),
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
152 cmdtable['extdiff'][1][1:],
de0c05afa511 new extension: extdiff. allows to use external diff program.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
153 _('hg %s [OPT]... [FILE]...') % cmd)