Patchwork D2403: stack: remove destutil.stackbase

login
register
mail settings
Submitter phabricator
Date Feb. 23, 2018, 10:37 a.m.
Message ID <differential-rev-PHID-DREV-vkzxlcx22okmhrqett5z-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28275/
State New
Headers show

Comments

phabricator - Feb. 23, 2018, 10:37 a.m.
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Use directly stack.getstack in show stack command. Remove destutil.stackbase.
  Import a TODO from the show stack in the code.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/show.py
  mercurial/destutil.py

CHANGE DETAILS




To: lothiraldan, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 24, 2018, 2:44 a.m.
indygreg added a comment.


  Oh, I guess the series never did formerly define a revset for stack :/
  
  I think there is room for one. We have the ability to mark revsets as experimental or internal, right? Could/should we do that so we don't need `hg debugstack`?
  
  Anyway, I could probably queue this with some minor rework. But I'm going to hold off a bit and see if others have opinions.

REPOSITORY
  rHG Mercurial

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

To: lothiraldan, #hg-reviewers
Cc: indygreg, mercurial-devel
phabricator - March 1, 2018, 8 p.m.
lothiraldan added a comment.


  In https://phab.mercurial-scm.org/D2403#39460, @indygreg wrote:
  
  > Oh, I guess the series never did formerly define a revset for stack :/
  >
  > I think there is room for one. We have the ability to mark revsets as experimental or internal, right? Could/should we do that so we don't need `hg debugstack`?
  >
  > Anyway, I could probably queue this with some minor rework. But I'm going to hold off a bit and see if others have opinions.
  
  
  I have updated the series without using debugstack, thank you for the suggestion. I thought revset would were much harder to implement but turn out not so much harder.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -357,10 +357,6 @@ 
 
     return None
 
-def stackbase(ui, repo):
-    revs = stack.getstack(repo)
-    return revs.first() if revs else None
-
 def _statusotherbook(ui, repo):
     bmheads = bookmarks.headsforactive(repo)
     curhead = repo[repo._activebookmark].node()
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -35,7 +35,6 @@ 
 from mercurial import (
     cmdutil,
     commands,
-    destutil,
     error,
     formatter,
     graphmod,
@@ -45,6 +44,7 @@ 
     registrar,
     revset,
     revsetlang,
+    stack
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -193,17 +193,17 @@ 
                    'changeset)\n'))
         return
 
-    # TODO extract "find stack" into a function to facilitate
-    # customization and reuse.
-
-    baserev = destutil.stackbase(ui, repo)
     basectx = None
 
+    _stack = stack.getstack(repo)
+    baserev = _stack.first()
+
+    # TODO doesn't yet handle case where wdir is a draft merge
     if baserev is None:
         baserev = wdirctx.rev()
         stackrevs = {wdirctx.rev()}
     else:
-        stackrevs = set(repo.revs('%d::.', baserev))
+        stackrevs = set(_stack)
 
     ctx = repo[baserev]
     if ctx.p1().rev() != nullrev: