D525: rebase: add a changes flag which will tell about the hash changes

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Sat Aug 26 11:52:15 UTC 2017


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-base.t

CHANGE DETAILS

diff --git a/tests/test-rebase-base.t b/tests/test-rebase-base.t
--- a/tests/test-rebase-base.t
+++ b/tests/test-rebase-base.t
@@ -415,4 +415,47 @@
   |
   o  0: A
   
+Enabling obsolete markers
+
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > stabilization=createmarkers,exchange
+  > EOF
+
+Testing the --changes flag
+
+  $ hg rebase -s 4 -d 2 --changes
+  rebasing 4:abc67d0cf023 "C"
+  rebasing 5:a701fddfacec "D" (tip)
+  abc67d0cf023 is changed to 2e4b11ea9404
+  a701fddfacec is changed to 003ba25ccc56
+
+  $ hg tglog
+  o  7: D
+  |
+  o  6: C
+  |
+  | o  3: B
+  |/
+  o  2: Z
+  |
+  o  1: Y
+  |
+  o  0: A
+  
+
+Only json output using `--changes -q -Tjson`
+
+  $ hg rebase -s 6 -d 3 --changes -q -Tjson
+  [
+   {
+    "newnode": "583565ab89ac",
+    "oldnode": "2e4b11ea9404"
+   },
+   {
+    "newnode": "38bd5f90ba6a",
+    "oldnode": "003ba25ccc56"
+   }
+  ]
+
   $ cd ..
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -479,6 +479,17 @@
             ui.note(_("update back to initial working directory parent\n"))
             hg.updaterepo(repo, newwd, False)
 
+        if opts.get('changes'):
+            fm = ui.formatter('rebase', opts)
+            label = 'rebase.nodes'
+            for oldrev, newrev in self.state.iteritems():
+                fm.startitem()
+                oldhash = short(repo[oldrev].node())
+                newhash = short(repo[newrev].node())
+                fm.write('oldnode', '%s is changed to ', oldhash, label=label)
+                fm.write('newnode', '%s\n', newhash, label=label)
+            fm.end()
+
         if not self.keepf:
             collapsedas = None
             if self.collapsef:
@@ -522,6 +533,7 @@
     ('i', 'interactive', False, _('(DEPRECATED)')),
     ('t', 'tool', '', _('specify merge tool')),
     ('c', 'continue', False, _('continue an interrupted rebase')),
+    ('', 'changes', False, _('show the node changes (EXPERIMENTAl)')),
     ('a', 'abort', False, _('abort an interrupted rebase'))] +
      templateopts,
     _('[-s REV | -b REV] [-d REV] [OPTION]'))



To: pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list