@@ -58,19 +58,21 @@ sections for diff tool arguments, when n
You can use -I/-X and list of file or directory names like normal
:hg:`diff` command. The extdiff extension makes snapshots of only
needed files, so running the external diff program will actually be
pretty fast (at least faster than having to compare the entire tree).
'''
from mercurial.i18n import _
from mercurial.node import short, nullid
-from mercurial import scmutil, scmutil, util, commands, encoding
+from mercurial import cmdutil, scmutil, scmutil, util, commands, encoding
import os, shlex, shutil, tempfile, re
+cmdtable = {}
+command = cmdutil.command(cmdtable)
testedwith = 'internal'
def snapshot(ui, repo, files, node, tmproot):
'''snapshot files as of some revision
if not using snapshot, -I/-X does not work and recursive diff
in tools like kdiff3 and meld displays too many files.'''
dirname = os.path.basename(repo.root)
if dirname == "":
@@ -233,16 +235,25 @@ def dodiff(ui, repo, diffcmd, diffopts,
'Overwriting: %s (src: %s)\n' % (working_fn, copy_fn))
util.copyfile(copy_fn, working_fn)
return 1
finally:
ui.note(_('cleaning up temp directory\n'))
shutil.rmtree(tmproot)
+@command('extdiff',
+ [('p', 'program', '',
+ _('comparison program to run'), _('CMD')),
+ ('o', 'option', [],
+ _('pass option to comparison program'), _('OPT')),
+ ('r', 'rev', [], _('revision'), _('REV')),
+ ('c', 'change', '', _('change made by revision'), _('REV')),
+ ] + commands.walkopts,
+ _('hg extdiff [OPT]... [FILE]...'))
def extdiff(ui, repo, *pats, **opts):
'''use external program to diff repository (or selected files)
Show differences between revisions for the specified files, using
an external program. The default program used is diff, with
default options "-Npru".
To select a different program, use the -p/--program option. The
@@ -257,31 +268,16 @@ def extdiff(ui, repo, *pats, **opts):
to its parent.'''
program = opts.get('program')
option = opts.get('option')
if not program:
program = 'diff'
option = option or ['-Npru']
return dodiff(ui, repo, program, option, pats, opts)
-cmdtable = {
- "extdiff":
- (extdiff,
- [('p', 'program', '',
- _('comparison program to run'), _('CMD')),
- ('o', 'option', [],
- _('pass option to comparison program'), _('OPT')),
- ('r', 'rev', [],
- _('revision'), _('REV')),
- ('c', 'change', '',
- _('change made by revision'), _('REV')),
- ] + commands.walkopts,
- _('hg extdiff [OPT]... [FILE]...')),
- }
-
def uisetup(ui):
for cmd, path in ui.configitems('extdiff'):
if cmd.startswith('cmd.'):
cmd = cmd[4:]
if not path:
path = cmd
diffopts = ui.config('extdiff', 'opts.' + cmd, '')
diffopts = diffopts and [diffopts] or []