Patchwork [3,of,3,unshelve] unshelve: add support for custom merge tools

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 18, 2015, 11:20 p.m.
Message ID <7695d092615fafae9337.1447888859@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11496/
State Accepted
Headers show

Comments

Siddharth Agarwal - Nov. 18, 2015, 11:20 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447888283 28800
#      Wed Nov 18 15:11:23 2015 -0800
# Node ID 7695d092615fafae933758ca8074b8d30a6fa866
# Parent  bcb5b0e95269d5797fcdd1ba5610afa681c62d47
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 7695d092615f
unshelve: add support for custom merge tools

For parity with merge --tool, rebase --tool etc.

rebase.rebase overwrites the tool in repo.ui, so we need to explicitly pass it
down there too.
Pierre-Yves David - Nov. 19, 2015, 5:51 a.m.
On 11/18/2015 03:20 PM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1447888283 28800
> #      Wed Nov 18 15:11:23 2015 -0800
> # Node ID 7695d092615fafae933758ca8074b8d30a6fa866
> # Parent  bcb5b0e95269d5797fcdd1ba5610afa681c62d47
> # Available At http://42.netv6.net/sid0-wip/hg/
> #              hg pull http://42.netv6.net/sid0-wip/hg/ -r 7695d092615f
> unshelve: add support for custom merge tools

This is gold. Thanks. Pushed to the clowncopter.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -574,6 +574,7 @@  def unshelvecontinue(ui, repo, state, op
            _('continue an incomplete unshelve operation')),
           ('k', 'keep', None,
            _('keep shelve after unshelving')),
+          ('t', 'tool', '', _('specify merge tool')),
           ('', 'date', '',
            _('set date for temporary commits (DEPRECATED)'), _('DATE'))],
          _('hg unshelve [SHELVED]'))
@@ -620,6 +621,8 @@  def unshelve(ui, repo, *shelved, **opts)
         if shelved:
             raise error.Abort(_('cannot combine abort/continue with '
                                'naming a shelved change'))
+        if abortf and opts.get('tool', False):
+            ui.warn(_('tool option will be ignored\n'))
 
         try:
             state = shelvedstate.load(repo)
@@ -648,7 +651,9 @@  def unshelve(ui, repo, *shelved, **opts)
 
     oldquiet = ui.quiet
     wlock = lock = tr = None
+    forcemerge = ui.backupconfig('ui', 'forcemerge')
     try:
+        ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'unshelve')
         wlock = repo.wlock()
         lock = repo.lock()
 
@@ -706,6 +711,7 @@  def unshelve(ui, repo, *shelved, **opts)
                     'rev' : [shelvectx.rev()],
                     'dest' : str(tmpwctx.rev()),
                     'keep' : True,
+                    'tool' : opts.get('tool', ''),
                 })
             except error.InterventionRequired:
                 tr.close()
@@ -744,6 +750,7 @@  def unshelve(ui, repo, *shelved, **opts)
         if tr:
             tr.release()
         lockmod.release(lock, wlock)
+        ui.restoreconfig(forcemerge)
 
 @command('shelve',
          [('A', 'addremove', None,
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -469,6 +469,29 @@  set up another conflict between a commit
 
 if we resolve a conflict while unshelving, the unshelve should succeed
 
+  $ hg unshelve --tool :merge-other --keep
+  unshelving change 'default'
+  temporarily committing pending changes (restore with 'hg unshelve --abort')
+  rebasing shelved changes
+  rebasing 6:c5e6910e7601 "changes to 'second'" (tip)
+  merging a/a
+  $ hg parents -q
+  4:33f7f61e6c5e
+  $ hg shelve -l
+  default         (*)* changes to 'second' (glob)
+  $ hg status
+  M a/a
+  A foo/foo
+  $ cat a/a
+  a
+  c
+  a
+  $ cat > a/a << EOF
+  > a
+  > c
+  > x
+  > EOF
+
   $ HGMERGE=true hg unshelve
   unshelving change 'default'
   temporarily committing pending changes (restore with 'hg unshelve --abort')
@@ -730,7 +753,8 @@  unshelve and conflicts with tracked and 
   >>>>>>> source: 23b29cada8ba - shelve: changes to 'commit stuff'
   $ cat f.orig
   g
-  $ hg unshelve --abort
+  $ hg unshelve --abort -t false
+  tool option will be ignored
   rebase aborted
   unshelve of 'default' aborted
   $ hg st