[PATCH 5 of 5] revpair: do not optimize tree to check for odd-range spec

Yuya Nishihara yuya at tcha.org
Mon Aug 8 11:25:24 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1470484013 -32400
#      Sat Aug 06 20:46:53 2016 +0900
# Node ID 61c8a67750ead0434765c0ad38de895e4fa86539
# Parent  ba93a75f774fbbaa07bef5327e4f8c43755f42cd
revpair: do not optimize tree to check for odd-range spec

At cc3a30ff9490, we had to optimize a parsed tree to resolve x^:y ambiguity.
Since we've moved the resolution of x^:y to parse(), we no longer have to call
optimize(). Therefore, (x:y) can be taken as a single expression, not an odd
range expression x:y.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -781,7 +781,6 @@ def revsingle(repo, revspec, default='.'
 
 def _pairspec(revspec):
     tree = revset.parse(revspec)
-    tree = revset.optimize(tree)  # fix up "x^:y" -> "(x^):y"
     return tree and tree[0] in ('range', 'rangepre', 'rangepost', 'rangeall')
 
 def revpair(repo, revs):
diff --git a/tests/test-diff-change.t b/tests/test-diff-change.t
--- a/tests/test-diff-change.t
+++ b/tests/test-diff-change.t
@@ -50,6 +50,13 @@ as pairs even if x == y, but not for "f(
   @@ -1,1 +1,1 @@
   -third
   +wdir
+  $ hg diff -r '(2:2)' --nodates
+  diff -r bf5ff72eb7e0 file.txt
+  --- a/file.txt
+  +++ b/file.txt
+  @@ -1,1 +1,1 @@
+  -third
+  +wdir
   $ hg diff -r 2::2 --nodates
   diff -r bf5ff72eb7e0 file.txt
   --- a/file.txt


More information about the Mercurial-devel mailing list