Patchwork [2,of,6] rebase: extract ctx description logic to a function

login
register
mail settings
Submitter Jun Wu
Date July 9, 2017, 7:14 p.m.
Message ID <85aa943fb16e8fe9f8fe.1499627689@x1c>
Download mbox | patch
Permalink /patch/22177/
State Superseded
Headers show

Comments

Jun Wu - July 9, 2017, 7:14 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1499569552 25200
#      Sat Jul 08 20:05:52 2017 -0700
# Node ID 85aa943fb16e8fe9f8fed13871a28bdd20ff31b0
# Parent  5a13cf09bacd7912367c4f15b73920fadaf0a457
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 85aa943fb16e
rebase: extract ctx description logic to a function

The function will be used in a later patch.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -123,4 +123,14 @@  def _revsetdestrebase(repo, subset, 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"""
@@ -378,9 +388,5 @@  class rebaseruntime(object):
         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)