summary: indicate if a rebase is underway
authorBryan O'Sullivan <bryano@fb.com>
Tue, 14 May 2013 11:23:17 -0700
changeset 19214 0250047a365e
parent 19213 f324a9b8d4bf
child 19215 f184fe1e2ac5
summary: indicate if a rebase is underway
hgext/color.py
hgext/rebase.py
tests/test-rebase-parameters.t
--- a/hgext/color.py	Tue May 14 11:23:17 2013 -0700
+++ b/hgext/color.py	Tue May 14 11:23:17 2013 -0700
@@ -60,6 +60,9 @@
   tags.normal = green
   tags.local = black bold
 
+  rebase.rebased = blue
+  rebase.remaining = red bold
+
 The available effects in terminfo mode are 'blink', 'bold', 'dim',
 'inverse', 'invisible', 'italic', 'standout', and 'underline'; in
 ECMA-48 mode, the options are 'bold', 'inverse', 'italic', and
@@ -250,6 +253,8 @@
            'diffstat.inserted': 'green',
            'ui.prompt': 'yellow',
            'log.changeset': 'yellow',
+           'rebase.rebased': 'blue',
+           'rebase.remaining': 'red bold',
            'resolve.resolved': 'green bold',
            'resolve.unresolved': 'red bold',
            'status.added': 'green bold',
--- a/hgext/rebase.py	Tue May 14 11:23:17 2013 -0700
+++ b/hgext/rebase.py	Tue May 14 11:23:17 2013 -0700
@@ -779,6 +779,17 @@
             raise util.Abort(_('--tool can only be used with --rebase'))
         orig(ui, repo, *args, **opts)
 
+def summaryhook(ui, repo):
+    if not os.path.exists(repo.join('rebasestate')):
+        return
+    state = restorestatus(repo)[2]
+    numrebased = len([i for i in state.itervalues() if i != -1])
+    # i18n: column positioning for "hg summary"
+    ui.write(_('rebase: %s, %s (rebase --continue)\n') %
+             (ui.label(_('%d rebased'), 'rebase.rebased') % numrebased,
+              ui.label(_('%d remaining'), 'rebase.remaining') %
+              (len(state) - numrebased)))
+
 def uisetup(ui):
     'Replace pull with a decorator to provide --rebase option'
     entry = extensions.wrapcommand(commands.table, 'pull', pullrebase)
@@ -786,3 +797,4 @@
                      _("rebase working directory to branch head")))
     entry[1].append(('t', 'tool', '',
                      _("specify merge tool for rebase")))
+    cmdutil.summaryhooks.add('rebase', summaryhook)
--- a/tests/test-rebase-parameters.t	Tue May 14 11:23:17 2013 -0700
+++ b/tests/test-rebase-parameters.t	Tue May 14 11:23:17 2013 -0700
@@ -427,6 +427,7 @@
   branch: default
   commit: 1 modified, 1 unresolved (merge)
   update: (current)
+  rebase: 0 rebased, 1 remaining (rebase --continue)
 
   $ hg resolve -l
   U c2