Patchwork [1,of,4] cmdutil: make getgraphlogrevs return revs in descending order

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 29, 2012, 12:56 a.m.
Message ID <794951c412ac05bad45c.1356742597@sid0x220>
Download mbox | patch
Permalink /patch/326/
State Accepted
Commit ae663cba9a8d9cb1ca7f54d436136ff407af7793
Headers show

Comments

Siddharth Agarwal - Dec. 29, 2012, 12:56 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1356734818 28800
# Node ID 794951c412ac05bad45cf6aa3f91b64f20f8b539
# Parent  4945f41b009b6aa8eff843497ac96a0eb1840a56
cmdutil: make getgraphlogrevs return revs in descending order

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1430,8 +1430,12 @@  def getgraphlogrevs(repo, pats, opts):
     # Default --rev value depends on --follow but --follow behaviour
     # depends on revisions resolved from --rev...
     follow = opts.get('follow') or opts.get('follow_first')
+    possiblyunsorted = False # whether revs might need sorting
     if opts.get('rev'):
         revs = scmutil.revrange(repo, opts['rev'])
+        # Don't sort here because _makegraphlogrevset might depend on the
+        # order of revs
+        possiblyunsorted = True
     else:
         if follow and len(repo) > 0:
             revs = repo.revs('reverse(:.)')
@@ -1441,6 +1445,8 @@  def getgraphlogrevs(repo, pats, opts):
     if not revs:
         return iter([]), None, None
     expr, filematcher = _makegraphlogrevset(repo, pats, opts, revs)
+    if possiblyunsorted:
+        revs.sort(reverse=True)
     if expr:
         matcher = revset.match(repo.ui, expr)
         revs = increasingrevs(repo, revs, matcher)