Patchwork D2399: stack: return a sorted smartrev by default

login
register
mail settings
Submitter phabricator
Date March 19, 2018, 8:06 p.m.
Message ID <9d4f7697fb66c054bf469cf7f2ff0bf3@localhost.localdomain>
Download mbox | patch
Permalink /patch/29640/
State Not Applicable
Headers show

Comments

phabricator - March 19, 2018, 8:06 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG68fcc5503ec5: stack: return a sorted smartrev by default (authored by lothiraldan, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2399?vs=6215&id=7128

REVISION DETAIL
  https://phab.mercurial-scm.org/D2399

AFFECTED FILES
  mercurial/destutil.py
  mercurial/stack.py
  tests/test-stack.t

CHANGE DETAILS




To: lothiraldan, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel

Patch

diff --git a/tests/test-stack.t b/tests/test-stack.t
--- a/tests/test-stack.t
+++ b/tests/test-stack.t
@@ -205,13 +205,13 @@ 
   ~
 Check the stack order
   $ hg log -r "first(stack())"
-  10 foo draft c_h
+  9 foo draft c_g
   $ hg log -r "first(stack(10))"
-  10 foo draft c_h
+  9 foo draft c_g
   $ hg log -r "first(stack(8))"
-  8 foo draft c_f
+  7 foo draft c_e
   $ hg log -r "first(stack(head()))"
-  8 foo draft c_f
+  7 foo draft c_e
 
 Case with multiple heads with unstability involved
 --------------------------------------------------
diff --git a/mercurial/stack.py b/mercurial/stack.py
--- a/mercurial/stack.py
+++ b/mercurial/stack.py
@@ -13,8 +13,8 @@ 
 )
 
 def getstack(repo, rev=None):
-    """return a smartrev of the stack containing either rev if it is not None
-    or the current working directory parent.
+    """return a sorted smartrev of the stack containing either rev if it is
+    not None or the current working directory parent.
 
     The stack will always contain all drafts changesets which are ancestors to
     the revision and are not merges.
@@ -24,4 +24,6 @@ 
 
     revspec = 'reverse(only(%s) and not public() and not ::merge())'
     revset = revsetlang.formatspec(revspec, rev)
-    return scmutil.revrange(repo, [revset])
+    revisions = scmutil.revrange(repo, [revset])
+    revisions.sort()
+    return revisions
diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -359,7 +359,7 @@ 
 
 def stackbase(ui, repo):
     revs = stack.getstack(repo)
-    return revs.last() if revs else None
+    return revs.first() if revs else None
 
 def _statusotherbook(ui, repo):
     bmheads = bookmarks.headsforactive(repo)