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

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 8, 2016, 3:25 p.m.
Message ID <61c8a67750ead0434765.1470669924@mimosa>
Download mbox | patch
Permalink /patch/16202/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 8, 2016, 3:25 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.
Pierre-Yves David - Aug. 11, 2016, 7:58 p.m.
On 08/08/2016 05:25 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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

This series is a bit hairy but I think I got enough of it to say it is 
right. Thanks a lot for fixing this parsing issue, this was very annoying.

Pushed

Patch

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