5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2, incorporated herein by reference. |
6 # GNU General Public License version 2, incorporated herein by reference. |
7 |
7 |
8 '''command to allow external programs to compare revisions |
8 '''command to allow external programs to compare revisions |
9 |
9 |
10 The `extdiff' Mercurial extension allows you to use external programs |
10 The `extdiff' Mercurial extension allows you to use external programs to |
11 to compare revisions, or revision with working directory. The external diff |
11 compare revisions, or revision with working directory. The external diff |
12 programs are called with a configurable set of options and two |
12 programs are called with a configurable set of options and two non-option |
13 non-option arguments: paths to directories containing snapshots of |
13 arguments: paths to directories containing snapshots of files to compare. |
14 files to compare. |
14 |
15 |
15 The `extdiff' extension also allows to configure new diff commands, so you do |
16 The `extdiff' extension also allows to configure new diff commands, so |
16 not need to type "hg extdiff -p kdiff3" always. |
17 you do not need to type "hg extdiff -p kdiff3" always. |
|
18 |
17 |
19 [extdiff] |
18 [extdiff] |
20 # add new command that runs GNU diff(1) in 'context diff' mode |
19 # add new command that runs GNU diff(1) in 'context diff' mode |
21 cdiff = gdiff -Nprc5 |
20 cdiff = gdiff -Nprc5 |
22 ## or the old way: |
21 ## or the old way: |
27 vdiff = kdiff3 |
26 vdiff = kdiff3 |
28 |
27 |
29 # add new command called meld, runs meld (no need to name twice) |
28 # add new command called meld, runs meld (no need to name twice) |
30 meld = |
29 meld = |
31 |
30 |
32 # add new command called vimdiff, runs gvimdiff with DirDiff plugin |
31 # add new command called vimdiff, runs gvimdiff with DirDiff plugin (see |
33 # (see http://www.vim.org/scripts/script.php?script_id=102) |
32 # http://www.vim.org/scripts/script.php?script_id=102) Non English user, be |
34 # Non English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in |
33 # sure to put "let g:DirDiffDynamicDiffText = 1" in your .vimrc |
35 # your .vimrc |
|
36 vimdiff = gvim -f '+next' '+execute "DirDiff" argv(0) argv(1)' |
34 vimdiff = gvim -f '+next' '+execute "DirDiff" argv(0) argv(1)' |
37 |
35 |
38 You can use -I/-X and list of file or directory names like normal "hg |
36 You can use -I/-X and list of file or directory names like normal "hg diff" |
39 diff" command. The `extdiff' extension makes snapshots of only needed |
37 command. The `extdiff' extension makes snapshots of only needed files, so |
40 files, so running the external diff program will actually be pretty |
38 running the external diff program will actually be pretty fast (at least |
41 fast (at least faster than having to compare the entire tree). |
39 faster than having to compare the entire tree). |
42 ''' |
40 ''' |
43 |
41 |
44 from mercurial.i18n import _ |
42 from mercurial.i18n import _ |
45 from mercurial.node import short |
43 from mercurial.node import short |
46 from mercurial import cmdutil, util, commands |
44 from mercurial import cmdutil, util, commands |
157 shutil.rmtree(tmproot) |
155 shutil.rmtree(tmproot) |
158 |
156 |
159 def extdiff(ui, repo, *pats, **opts): |
157 def extdiff(ui, repo, *pats, **opts): |
160 '''use external program to diff repository (or selected files) |
158 '''use external program to diff repository (or selected files) |
161 |
159 |
162 Show differences between revisions for the specified files, using |
160 Show differences between revisions for the specified files, using an |
163 an external program. The default program used is diff, with |
161 external program. The default program used is diff, with default options |
164 default options "-Npru". |
162 "-Npru". |
165 |
163 |
166 To select a different program, use the -p/--program option. The |
164 To select a different program, use the -p/--program option. The program |
167 program will be passed the names of two directories to compare. To |
165 will be passed the names of two directories to compare. To pass additional |
168 pass additional options to the program, use -o/--option. These |
166 options to the program, use -o/--option. These will be passed before the |
169 will be passed before the names of the directories to compare. |
167 names of the directories to compare. |
170 |
168 |
171 When two revision arguments are given, then changes are shown |
169 When two revision arguments are given, then changes are shown between |
172 between those revisions. If only one revision is specified then |
170 those revisions. If only one revision is specified then that revision is |
173 that revision is compared to the working directory, and, when no |
171 compared to the working directory, and, when no revisions are specified, |
174 revisions are specified, the working directory files are compared |
172 the working directory files are compared to its parent. |
175 to its parent.''' |
173 ''' |
176 program = opts['program'] or 'diff' |
174 program = opts['program'] or 'diff' |
177 if opts['program']: |
175 if opts['program']: |
178 option = opts['option'] |
176 option = opts['option'] |
179 else: |
177 else: |
180 option = opts['option'] or ['-Npru'] |
178 option = opts['option'] or ['-Npru'] |