Patchwork D22: rebase: extract ctx description logic to a function

login
register
mail settings
Submitter phabricator
Date Aug. 16, 2017, 6:07 a.m.
Message ID <1495c63c6b11b03dd983b6a054eb4ca7@localhost.localdomain>
Download mbox | patch
Permalink /patch/23072/
State Not Applicable
Headers show

Comments

phabricator - Aug. 16, 2017, 6:07 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG35fc5e919675: rebase: extract ctx description logic to a function (authored by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D22?vs=38&id=974

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS




To: quark, phillco, durin42
Cc: durin42, mercurial-devel

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -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: