@@ -662,6 +662,8 @@
options ([+] can be repeated):
-r --rev REV [+] revision
+ --from REV revision to diff from
+ --to REV revision to diff to
-c --change REV change made by revision
-a --text treat all files as text
-g --git use git extended diff format
@@ -1,4 +1,4 @@
-Testing diff --change
+Testing diff --change, --from, --to
$ hg init a
$ cd a
@@ -29,6 +29,59 @@
-first
+second
+Test --from and --to
+
+ $ hg diff --from . --rev .
+ abort: cannot specify both --from and --rev
+ [10]
+ $ hg diff --to . --rev .
+ abort: cannot specify both --to and --rev
+ [10]
+ $ hg diff --from . --change .
+ abort: cannot specify both --from and --change
+ [10]
+ $ hg diff --to . --change .
+ abort: cannot specify both --to and --change
+ [10]
+ $ echo dirty > file.txt
+ $ hg diff --from .
+ diff -r bf5ff72eb7e0 file.txt
+ --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
+ +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
+ @@ -1,1 +1,1 @@
+ -third
+ +dirty
+ $ hg diff --from . --reverse
+ diff -r bf5ff72eb7e0 file.txt
+ --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
+ +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
+ @@ -1,1 +1,1 @@
+ -dirty
+ +third
+ $ hg diff --to .
+ diff -r bf5ff72eb7e0 file.txt
+ --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
+ +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
+ @@ -1,1 +1,1 @@
+ -dirty
+ +third
+ $ hg diff --from 0 --to 2
+ diff -r 4bb65dda5db4 -r bf5ff72eb7e0 file.txt
+ --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
+ +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
+ @@ -1,1 +1,1 @@
+ -first
+ +third
+ $ hg diff --from 2 --to 0
+ diff -r bf5ff72eb7e0 -r 4bb65dda5db4 file.txt
+ --- a/file.txt Thu Jan 01 00:00:00 1970 +0000
+ +++ b/file.txt Thu Jan 01 00:00:00 1970 +0000
+ @@ -1,1 +1,1 @@
+ -third
+ +first
+ $ hg co -C .
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
$ cd ..
Test dumb revspecs: top-level "x:y", "x:", ":y" and ":" ranges should be handled
@@ -333,7 +333,7 @@
debugwhyunstable:
debugwireargs: three, four, five, ssh, remotecmd, insecure
debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
- diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
+ diff: rev, from, to, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template
files: rev, print0, include, exclude, template, subrepos
forget: interactive, include, exclude, dry-run
@@ -2456,6 +2456,8 @@
b'diff',
[
(b'r', b'rev', [], _(b'revision'), _(b'REV')),
+ (b'', b'from', b'', _(b'revision to diff from'), _(b'REV')),
+ (b'', b'to', b'', _(b'revision to diff to'), _(b'REV')),
(b'c', b'change', b'', _(b'change made by revision'), _(b'REV')),
]
+ diffopts
@@ -2530,13 +2532,21 @@
opts = pycompat.byteskwargs(opts)
revs = opts.get(b'rev')
change = opts.get(b'change')
+ from_rev = opts.get(b'from')
+ to_rev = opts.get(b'to')
stat = opts.get(b'stat')
reverse = opts.get(b'reverse')
+ cmdutil.check_incompatible_arguments(opts, b'from', [b'rev', b'change'])
+ cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change'])
if change:
repo = scmutil.unhidehashlikerevs(repo, [change], b'nowarn')
ctx2 = scmutil.revsingle(repo, change, None)
ctx1 = ctx2.p1()
+ elif from_rev or to_rev:
+ repo = scmutil.unhidehashlikerevs(repo, [from_rev] + [to_rev], b'nowarn')
+ ctx1 = scmutil.revsingle(repo, from_rev, None)
+ ctx2 = scmutil.revsingle(repo, to_rev, None)
else:
repo = scmutil.unhidehashlikerevs(repo, revs, b'nowarn')
ctx1, ctx2 = scmutil.revpair(repo, revs)