Patchwork [4,of,5] summary: indicate if a rebase is underway

login
register
mail settings
Submitter Bryan O'Sullivan
Date May 14, 2013, 6:24 p.m.
Message ID <00bf6cf86e28c01b1201.1368555870@australite.thefacebook.com>
Download mbox | patch
Permalink /patch/1640/
State Accepted
Commit 0250047a365e7419026dca811cd3a8f1aafd56ad
Headers show

Comments

Bryan O'Sullivan - May 14, 2013, 6:24 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1368555797 25200
#      Tue May 14 11:23:17 2013 -0700
# Node ID 00bf6cf86e28c01b1201bb2255003ebf043f84f0
# Parent  24450ae0028e41faea548c0b12a425709e7e0cc3
summary: indicate if a rebase is underway

Patch

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -60,6 +60,9 @@  Default effects may be overridden from y
   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 @@  except ImportError:
            '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',
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -779,6 +779,17 @@  def pullrebase(orig, ui, repo, *args, **
             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 @@  def uisetup(ui):
                      _("rebase working directory to branch head")))
     entry[1].append(('t', 'tool', '',
                      _("specify merge tool for rebase")))
+    cmdutil.summaryhooks.add('rebase', summaryhook)
diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t
--- a/tests/test-rebase-parameters.t
+++ b/tests/test-rebase-parameters.t
@@ -427,6 +427,7 @@  Test --tool parameter:
   branch: default
   commit: 1 modified, 1 unresolved (merge)
   update: (current)
+  rebase: 0 rebased, 1 remaining (rebase --continue)
 
   $ hg resolve -l
   U c2