##// END OF EJS Templates
Improve extdiff configuration....
Brendan Cully -
r5245:a1efa71f default
parent child Browse files
Show More
@@ -4,55 +4,51 b''
4 #
4 #
5 # This software may be used and distributed according to the terms
5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference.
6 # of the GNU General Public License, incorporated herein by reference.
7 #
7
8 # The `extdiff' Mercurial extension allows you to use external programs
8 '''
9 # to compare revisions, or revision with working dir. The external diff
9 The `extdiff' Mercurial extension allows you to use external programs
10 # programs are called with a configurable set of options and two
10 to compare revisions, or revision with working dir. The external diff
11 # non-option arguments: paths to directories containing snapshots of
11 programs are called with a configurable set of options and two
12 # files to compare.
12 non-option arguments: paths to directories containing snapshots of
13 #
13 files to compare.
14 # To enable this extension:
14
15 #
15 To enable this extension:
16 # [extensions]
16
17 # hgext.extdiff =
17 [extensions]
18 #
18 hgext.extdiff =
19 # The `extdiff' extension also allows to configure new diff commands, so
19
20 # you do not need to type "hg extdiff -p kdiff3" always.
20 The `extdiff' extension also allows to configure new diff commands, so
21 #
21 you do not need to type "hg extdiff -p kdiff3" always.
22 # [extdiff]
23 # # add new command that runs GNU diff(1) in 'context diff' mode
24 # cmd.cdiff = gdiff
25 # opts.cdiff = -Nprc5
26
22
27 # # add new command called vdiff, runs kdiff3
23 [extdiff]
28 # cmd.vdiff = kdiff3
24 # add new command that runs GNU diff(1) in 'context diff' mode
25 cdiff = gdiff -Nprc5
26 ## or the old way:
27 #cmd.cdiff = gdiff
28 #opts.cdiff = -Nprc5
29
29
30 # # add new command called meld, runs meld (no need to name twice)
30 # add new command called vdiff, runs kdiff3
31 # cmd.meld =
31 vdiff = kdiff3
32
32
33 # # add new command called vimdiff, runs gvimdiff with DirDiff plugin
33 # add new command called meld, runs meld (no need to name twice)
34 # #(see http://www.vim.org/scripts/script.php?script_id=102)
34 meld =
35 # # Non english user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
35
36 # # your .vimrc
36 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
37 # cmd.vimdiff = gvim
37 #(see http://www.vim.org/scripts/script.php?script_id=102)
38 # opts.vimdiff = -f '+next' '+execute "DirDiff" argv(0) argv(1)'
38 # Non english user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
39 #
39 # your .vimrc
40 # Each custom diff commands can have two parts: a `cmd' and an `opts'
40 vimdiff = gvim -f '+next' '+execute "DirDiff" argv(0) argv(1)'
41 # part. The cmd.xxx option defines the name of an executable program
41
42 # that will be run, and opts.xxx defines a set of command-line options
42 You can use -I/-X and list of file or directory names like normal
43 # which will be inserted to the command between the program name and
43 "hg diff" command. The `extdiff' extension makes snapshots of only
44 # the files/directories to diff (i.e. the cdiff example above).
44 needed files, so running the external diff program will actually be
45 #
45 pretty fast (at least faster than having to compare the entire tree).
46 # You can use -I/-X and list of file or directory names like normal
46 '''
47 # "hg diff" command. The `extdiff' extension makes snapshots of only
48 # needed files, so running the external diff program will actually be
49 # pretty fast (at least faster than having to compare the entire tree).
50
47
51 from mercurial.i18n import _
48 from mercurial.i18n import _
52 from mercurial.node import *
49 from mercurial.node import *
53 from mercurial import cmdutil, util, commands
50 from mercurial import cmdutil, util, commands
54 import os, shutil, tempfile
51 import os, shlex, shutil, tempfile
55
56
52
57 def snapshot_node(ui, repo, files, node, tmproot):
53 def snapshot_node(ui, repo, files, node, tmproot):
58 '''snapshot files as of some revision'''
54 '''snapshot files as of some revision'''
@@ -187,11 +183,20 b' cmdtable = {'
187
183
188 def uisetup(ui):
184 def uisetup(ui):
189 for cmd, path in ui.configitems('extdiff'):
185 for cmd, path in ui.configitems('extdiff'):
190 if not cmd.startswith('cmd.'): continue
186 if cmd.startswith('cmd.'):
191 cmd = cmd[4:]
187 cmd = cmd[4:]
192 if not path: path = cmd
188 if not path: path = cmd
193 diffopts = ui.config('extdiff', 'opts.' + cmd, '')
189 diffopts = ui.config('extdiff', 'opts.' + cmd, '')
194 diffopts = diffopts and [diffopts] or []
190 diffopts = diffopts and [diffopts] or []
191 elif cmd.startswith('opts.'):
192 continue
193 else:
194 # command = path opts
195 if path:
196 diffopts = shlex.split(path)
197 path = diffopts.pop(0)
198 else:
199 path, diffopts = cmd, []
195 def save(cmd, path, diffopts):
200 def save(cmd, path, diffopts):
196 '''use closure to save diff command to use'''
201 '''use closure to save diff command to use'''
197 def mydiff(ui, repo, *pats, **opts):
202 def mydiff(ui, repo, *pats, **opts):
General Comments 0
You need to be logged in to leave comments. Login now