topic: explicitly pass topic as a keyword argument
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 28 Jun 2017 01:58:09 +0200
changeset 2668 1d2c66dc4ee3
parent 2667 e7079bba383d
child 2669 b933a8068c17
topic: explicitly pass topic as a keyword argument This clarify all callers before adding more logic related to bare branch in stack.
hgext3rd/topic/__init__.py
hgext3rd/topic/revset.py
hgext3rd/topic/stack.py
--- a/hgext3rd/topic/__init__.py	Tue Jun 27 15:21:38 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Wed Jun 28 01:58:09 2017 +0200
@@ -129,7 +129,7 @@
         topic = repo.currenttopic
         if not topic:
             raise error.Abort(_('cannot resolve "%s": no active topic') % name)
-        revs = list(stack.getstack(repo, topic))
+        revs = list(stack.getstack(repo, topic=topic))
         try:
             r = revs[idx - 1]
         except IndexError:
@@ -312,7 +312,7 @@
         topic = repo.currenttopic
     if not topic:
         raise error.Abort(_('no active topic to list'))
-    return stack.showstack(ui, repo, topic, opts)
+    return stack.showstack(ui, repo, topic=topic, opts=opts)
 
 def _changecurrenttopic(repo, newtopic):
     """changes the current topic."""
@@ -420,7 +420,7 @@
         fm.data(active=active)
         if ui.verbose:
             # XXX we should include the data even when not verbose
-            data = stack.stackdata(repo, topic)
+            data = stack.stackdata(repo, topic=topic)
             fm.plain(' (')
             fm.write('branches+', 'on branch: %s',
                      '+'.join(data['branches']), # XXX use list directly after 4.0 is released
--- a/hgext3rd/topic/revset.py	Tue Jun 27 15:21:38 2017 +0200
+++ b/hgext3rd/topic/revset.py	Wed Jun 28 01:58:09 2017 +0200
@@ -75,7 +75,7 @@
     if not topic:
         raise error.Abort(_('no active topic to list'))
     # ordering hack, boo
-    return revset.baseset(stack.getstack(repo, topic)) & subset
+    return revset.baseset(stack.getstack(repo, topic=topic)) & subset
 
 
 def modsetup(ui):
--- a/hgext3rd/topic/stack.py	Tue Jun 27 15:21:38 2017 +0200
+++ b/hgext3rd/topic/stack.py	Wed Jun 28 01:58:09 2017 +0200
@@ -10,7 +10,7 @@
 )
 from .evolvebits import builddependencies, _orderrevs, _singlesuccessor
 
-def getstack(repo, topic):
+def getstack(repo, topic=None):
     # XXX need sorting
     trevs = repo.revs("topic(%s) - obsolete()", topic)
     return _orderrevs(repo, trevs)
@@ -21,7 +21,9 @@
     """
     return ' '.join(prefix % suffix for suffix in labelssuffix)
 
-def showstack(ui, repo, topic, opts):
+def showstack(ui, repo, topic=None, opts=None):
+    if opts is None:
+        opts = {}
 
     if topic not in repo.topics:
         raise error.Abort(_('cannot resolve "%s": no such topic found') % topic)
@@ -35,7 +37,7 @@
     if topic == repo.currenttopic:
         label = 'topic.active'
 
-    data = stackdata(repo, topic)
+    data = stackdata(repo, topic=topic)
     fm.plain(_('### topic: %s') % ui.label(topic, label),
              label='topic.stack.summary.topic')
 
@@ -56,7 +58,7 @@
         fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount')
     fm.plain('\n')
 
-    for idx, r in enumerate(getstack(repo, topic), 1):
+    for idx, r in enumerate(getstack(repo, topic=topic), 1):
         ctx = repo[r]
         p1 = ctx.p1()
         if p1.obsolete():
@@ -111,7 +113,7 @@
         fm.plain('\n')
     fm.end()
 
-def stackdata(repo, topic):
+def stackdata(repo, topic=None):
     """get various data about a stack
 
     :changesetcount: number of non-obsolete changesets in the stack