extdiff: add --change option to display single changeset diff
This is the counterpart for extdiff of
9c6ae2e09e11.
--- a/hgext/extdiff.py Fri Feb 13 11:32:33 2009 +0100
+++ b/hgext/extdiff.py Sat Feb 07 19:41:05 2009 +0100
@@ -117,7 +117,19 @@
another one and more than 1 file is changed
- just invoke the diff for a single file in the working dir
'''
- node1, node2 = cmdutil.revpair(repo, opts['rev'])
+
+ revs = opts.get('rev')
+ change = opts.get('change')
+
+ if revs and change:
+ msg = _('cannot specify --rev and --change at the same time')
+ raise util.Abort(msg)
+ elif change:
+ node2 = repo.lookup(change)
+ node1 = repo[node2].parents()[0].node()
+ else:
+ node1, node2 = cmdutil.revpair(repo, revs)
+
matcher = cmdutil.match(repo, pats, opts)
modified, added, removed = repo.status(node1, node2, matcher)[:3]
if not (modified or added or removed):
@@ -205,6 +217,7 @@
[('p', 'program', '', _('comparison program to run')),
('o', 'option', [], _('pass option to comparison program')),
('r', 'rev', [], _('revision')),
+ ('c', 'change', '', _('change made by revision')),
] + commands.walkopts,
_('hg extdiff [OPT]... [FILE]...')),
}
--- a/tests/test-extdiff Fri Feb 13 11:32:33 2009 +0100
+++ b/tests/test-extdiff Sat Feb 07 19:41:05 2009 +0100
@@ -32,9 +32,14 @@
echo c >> c
hg add c
hg ci -m "new branch" -d '1 0'
-hg update -C 1
-hg merge tip
+hg merge 1
# should diff cloned file against wc file
-hg falabala > out || echo "diff-like tools yield a non-zero exit code"
+hg falabala > out
# cleanup the output since the wc is a tmp directory
sed 's:\(.* \).*\(\/test-extdiff\):\1[tmp]\2:' out
+# test --change option
+hg ci -d '2 0' -mtest3
+hg falabala -c 1
+# check diff are made from the first parent
+hg falabala -c 3 || echo "diff-like tools yield a non-zero exit code"
+#hg log
--- a/tests/test-extdiff.out Fri Feb 13 11:32:33 2009 +0100
+++ b/tests/test-extdiff.out Sat Feb 07 19:41:05 2009 +0100
@@ -20,6 +20,7 @@
-o --option pass option to comparison program
-r --rev revision
+ -c --change change made by revision
-I --include include names matching the given patterns
-X --exclude exclude names matching the given patterns
@@ -27,8 +28,9 @@
diffing a.8a5febb7f867/a a.34eed99112ab/a
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
created new head
-1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
+diffing a.2a13a4d2da36/a [tmp]/test-extdiff/a/a
+diffing a.8a5febb7f867/a a.34eed99112ab/a
+diffing a.2a13a4d2da36/a a.46c0e4daeb72/a
diff-like tools yield a non-zero exit code
-diffing a.34eed99112ab/c [tmp]/test-extdiff/a/c