changeset 33862:35fc5e919675

rebase: extract ctx description logic to a function The function will be used in a later patch. Differential Revision: https://phab.mercurial-scm.org/D22
author Jun Wu <quark@fb.com>
date Sat, 08 Jul 2017 20:05:52 -0700
parents 627cb36b537f
children 30573b3d2ebc
files hgext/rebase.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Thu Jul 27 00:00:15 2017 -0400
+++ b/hgext/rebase.py	Sat Jul 08 20:05:52 2017 -0700
@@ -122,6 +122,16 @@
         sourceset = revset.getset(repo, smartset.fullreposet(repo), x)
     return subset & smartset.baseset([_destrebase(repo, sourceset)])
 
+def _ctxdesc(ctx):
+    """short description for a context"""
+    desc = '%d:%s "%s"' % (ctx.rev(), ctx,
+                           ctx.description().split('\n', 1)[0])
+    repo = ctx.repo()
+    names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
+    if names:
+        desc += ' (%s)' % ' '.join(names)
+    return desc
+
 class rebaseruntime(object):
     """This class is a container for rebase runtime state"""
     def __init__(self, repo, ui, opts=None):
@@ -377,11 +387,7 @@
         pos = 0
         for rev in sortedrevs:
             ctx = repo[rev]
-            desc = '%d:%s "%s"' % (ctx.rev(), ctx,
-                                   ctx.description().split('\n', 1)[0])
-            names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
-            if names:
-                desc += ' (%s)' % ' '.join(names)
+            desc = _ctxdesc(ctx)
             if self.state[rev] == rev:
                 ui.status(_('already rebased %s\n') % desc)
             elif self.state[rev] == revtodo: