Patchwork D582: rebase: add a changes flag to rebase which will show the hash changes

login
register
mail settings
Submitter phabricator
Date Aug. 31, 2017, 5:03 p.m.
Message ID <fe08a9711d4b0faa255de3b25e103b15@localhost.localdomain>
Download mbox | patch
Permalink /patch/23544/
State Not Applicable
Headers show

Comments

phabricator - Aug. 31, 2017, 5:03 p.m.
pulkit updated this revision to Diff 1475.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D582?vs=1472&id=1475

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

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

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: 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)
+  a701fddfacec -> 003ba25ccc56
+  abc67d0cf023 -> 2e4b11ea9404
+
+  $ 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": "38bd5f90ba6afc7ea705c11010eeef01bd3fb2f8",
+    "oldnode": "003ba25ccc5677a25f8a186751b789f2da5aad53"
+   },
+   {
+    "newnode": "583565ab89ac6de0871825d399e305b01d364312",
+    "oldnode": "2e4b11ea9404550c296bd4d3aedf1f22fdd1af8b"
+   }
+  ]
+
   $ cd ..
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -523,12 +523,19 @@ 
             ui.note(_("update back to initial working directory parent\n"))
             hg.updaterepo(repo, newwd, False)
 
+        fm = None
+        if opts.get('changes'):
+            fm = ui.formatter('rebase', opts)
+
         if not self.keepf:
             collapsedas = None
             if self.collapsef:
                 collapsedas = newnode
             clearrebased(ui, repo, self.destmap, self.state, self.skipped,
-                         collapsedas)
+                         collapsedas, fm=fm)
+
+        if fm:
+            fm.end()
 
         clearstatus(repo)
         clearcollapsemsg(repo)
@@ -566,6 +573,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]'))
@@ -1492,7 +1500,7 @@ 
             state[rev] = rev
     return originalwd, destmap, state
 
-def clearrebased(ui, repo, destmap, state, skipped, collapsedas=None):
+def clearrebased(ui, repo, destmap, state, skipped, collapsedas=None, fm=None):
     """dispose of rebased revision at the end of the rebase
 
     If `collapsedas` is not None, the rebase was a collapse whose result if the
@@ -1517,7 +1525,7 @@ 
             else:
                 succs = (tonode(newrev),)
             mapping[tonode(rev)] = succs
-    scmutil.cleanupnodes(repo, mapping, 'rebase')
+    scmutil.cleanupnodes(repo, mapping, 'rebase', fm=fm)
 
 def pullrebase(orig, ui, repo, *args, **opts):
     'Call rebase after pull if the latter has been invoked with --rebase'