stack: add a --children flag to stack
If a commit in the stack has been merged outside the current topic, show a trailing status of (external-children)
--- a/CHANGELOG Sun Dec 02 16:52:14 2018 +0100
+++ b/CHANGELOG Fri Sep 21 11:44:34 2018 -0400
@@ -8,8 +8,8 @@
* next: evolve aspiring children by default (use --no-evolve to skip)
* next: pick lower part of a split as destination
* compat: drop compatibility with Mercurial 4.3
- i* topics: improve the message around topic changing
-
+ * topics: improve the message around topic changing
+ * stack: introduce a --children flag (see help for details)
8.3.2 --2017-11-27
-------------------
--- a/hgext3rd/topic/__init__.py Sun Dec 02 16:52:14 2018 +0100
+++ b/hgext3rd/topic/__init__.py Fri Sep 21 11:44:34 2018 -0400
@@ -721,6 +721,8 @@
return ret
@command('stack', [
+ ('c', 'children', None,
+ _('display data about children outside of the stack'))
] + commands.formatteropts,
_('hg stack [TOPIC]'))
def cmdstack(ui, repo, topic='', **opts):
--- a/hgext3rd/topic/stack.py Sun Dec 02 16:52:14 2018 +0100
+++ b/hgext3rd/topic/stack.py Fri Sep 21 11:44:34 2018 -0400
@@ -329,15 +329,32 @@
symbol = None
states = []
+ msg = ''
iscurrentrevision = repo.revs('%d and parents()', ctx.rev())
+ if opts.get('children'):
+ if branch:
+ t_msg = '-branch("%s")' % branch
+ if topic:
+ t_msg = '-topic("%s")' % topic
+ rev_msg = 'children(%s) and merge() %s'
+ revisions = repo.revs(rev_msg % (ctx.rev(), t_msg))
+ len_rev = len(revisions)
+ if len_rev > 0:
+ msg = 'external-children'
if iscurrentrevision:
- states.append('current')
symbol = '@'
+ if msg:
+ states.append('current - ' + msg)
+ else:
+ states.append('current')
if ctx.orphan():
symbol = '$'
- states.append('unstable')
+ if msg:
+ states.append('unstable - ' + msg)
+ else:
+ states.append('unstable')
if not isentry:
symbol = '^'
@@ -347,7 +364,10 @@
# none of the above if statments get executed
if not symbol:
symbol = ':'
- states.append('clean')
+ if msg:
+ states.append(msg)
+ else:
+ states.append('clean')
states.sort()
--- a/tests/test-topic-stack.t Sun Dec 02 16:52:14 2018 +0100
+++ b/tests/test-topic-stack.t Fri Sep 21 11:44:34 2018 -0400
@@ -229,8 +229,52 @@
s1: c_c
s0^ c_b (base)
+merge case (displaying info about external)
+-------------------------------------------
+
+ $ hg up default
+ 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
+ $ hg topics zzz
+ marked working directory as topic: zzz
+ $ echo zzz > zzz
+ $ hg add zzz
+ $ hg commit -m zzz_a
+ active topic 'zzz' grew its first changeset
+ (see 'hg help topics' for more information)
+ $ hg merge foo
+ 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ (branch merge, don't forget to commit)
+ $ hg commit -m "merged foo"
+
+stack -m display data about child
+
+ $ hg stack foo
+ ### topic: foo
+ ### target: default (branch)
+ s4: c_f
+ s3: c_e
+ s2: c_d
+ s1: c_c
+ s0^ c_b (base)
+
+ $ hg stack foo --children
+ ### topic: foo
+ ### target: default (branch)
+ s4: c_f (external-children)
+ s3: c_e
+ s2: c_d
+ s1: c_c
+ s0^ c_b (base)
+
error case, nothing to list
+ $ hg strip --config extensions.strip= t1 --no-backup
+ 0 files updated, 0 files merged, 5 files removed, 0 files unresolved
+
+ $ hg up foo
+ switching to topic foo
+ 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
$ hg topic --clear
$ hg stack
### target: default (branch)