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

login
register
mail settings
Submitter phabricator
Date Aug. 29, 2017, 4:06 p.m.
Message ID <51c8279575fd94c41093085d903e009c@localhost.localdomain>
Download mbox | patch
Permalink /patch/23478/
State Not Applicable
Headers show

Comments

phabricator - Aug. 29, 2017, 4:06 p.m.
pulkit updated this revision to Diff 1406.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D525?vs=1321&id=1406

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

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

CHANGE DETAILS




To: pulkit, #hg-reviewers, durin42
Cc: yuja, durin42, quark, mercurial-devel

Patch

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": "583565ab89ac6de0871825d399e305b01d364312",
+    "oldnode": "2e4b11ea9404550c296bd4d3aedf1f22fdd1af8b"
+   },
+   {
+    "newnode": "38bd5f90ba6afc7ea705c11010eeef01bd3fb2f8",
+    "oldnode": "003ba25ccc5677a25f8a186751b789f2da5aad53"
+   }
+  ]
+
   $ cd ..
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -479,6 +479,19 @@ 
             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()
+                hexfunc = fm.hexfunc
+                oldhash = repo[oldrev].node()
+                newhash = repo[newrev].node()
+                fm.write('oldnode', '%s is changed to ', hexfunc(oldhash),
+                            label=label)
+                fm.write('newnode', '%s\n', hexfunc(newhash), label=label)
+            fm.end()
+
         if not self.keepf:
             collapsedas = None
             if self.collapsef:
@@ -522,6 +535,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]'))