changeset 25383:5909ac39b86a

revrange: drop unnecessary deduplication of revisions Because "l" is a smartset, duplicated entries are omitted by addsets.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 24 May 2015 17:53:22 +0900
parents 6084926366b9
children 99d3ca7d67e4
files mercurial/scmutil.py tests/test-revset.t
diffstat 2 files changed, 14 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/scmutil.py	Fri May 29 22:23:58 2015 +0200
+++ b/mercurial/scmutil.py	Sun May 24 17:53:22 2015 +0900
@@ -709,14 +709,12 @@
             return defval
         return repo[val].rev()
 
-    seen, l = set(), revset.baseset([])
+    l = revset.baseset([])
 
     revsetaliases = [alias for (alias, _) in
                      repo.ui.configitems("revsetalias")]
 
     for spec in revs:
-        if l and not seen:
-            seen = set(l)
         # attempt to parse old-style ranges first to deal with
         # things like old-tag which contain query metacharacters
         try:
@@ -727,7 +725,6 @@
                 raise error.RepoLookupError
 
             if isinstance(spec, int):
-                seen.add(spec)
                 l = l + revset.baseset([spec])
                 continue
 
@@ -741,24 +738,15 @@
                 if end == nullrev and start < 0:
                     start = nullrev
                 rangeiter = repo.changelog.revs(start, end)
-                if not seen and not l:
+                if not l:
                     # by far the most common case: revs = ["-1:0"]
                     l = revset.baseset(rangeiter)
-                    # defer syncing seen until next iteration
                     continue
                 newrevs = set(rangeiter)
-                if seen:
-                    newrevs.difference_update(seen)
-                    seen.update(newrevs)
-                else:
-                    seen = newrevs
                 l = l + revset.baseset(sorted(newrevs, reverse=start > end))
                 continue
             elif spec and spec in repo: # single unquoted rev
                 rev = revfix(repo, spec, None)
-                if rev in seen:
-                    continue
-                seen.add(rev)
                 l = l + revset.baseset([rev])
                 continue
         except error.RepoLookupError:
@@ -766,10 +754,9 @@
 
         # fall through to new-style queries if old-style fails
         m = revset.match(repo.ui, spec, repo)
-        if seen or l:
-            dl = [r for r in m(repo) if r not in seen]
+        if l:
+            dl = [r for r in m(repo)]
             l = l + revset.baseset(dl)
-            seen.update(dl)
         else:
             l = m(repo)
 
--- a/tests/test-revset.t	Fri May 29 22:23:58 2015 +0200
+++ b/tests/test-revset.t	Sun May 24 17:53:22 2015 +0900
@@ -858,6 +858,16 @@
   4
   5
 
+test that more than one `-r`s are combined in the right order and deduplicated:
+
+  $ hg log -T '{rev}\n' -r 3 -r 3 -r 4 -r 5:2 -r 'ancestors(4)'
+  3
+  4
+  5
+  2
+  0
+  1
+
 test that `or` operation skips duplicated revisions from right-hand side
 
   $ try 'reverse(1::5) or ancestors(4)'