changeset 21552:61151f429a5f

update: introduce --tool for controlling the merge tool Update is a kind of merge and may also need a merge tool and should have the options described in the merge-tools help.
author Mads Kiilerich <madski@unity3d.com>
date Mon, 19 May 2014 01:53:34 +0200
parents bde505f47141
children bee0e1cffdd3
files mercurial/commands.py tests/test-completion.t tests/test-merge-tools.t
diffstat 3 files changed, 55 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri May 02 01:09:14 2014 +0200
+++ b/mercurial/commands.py	Mon May 19 01:53:34 2014 +0200
@@ -5797,9 +5797,11 @@
     ('c', 'check', None,
      _('update across branches if no uncommitted changes')),
     ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
-    ('r', 'rev', '', _('revision'), _('REV'))],
+    ('r', 'rev', '', _('revision'), _('REV'))
+     ] + mergetoolopts,
     _('[-c] [-C] [-d DATE] [[-r] REV]'))
-def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
+def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
+           tool=None):
     """update working directory (or switch revisions)
 
     Update the repository's working directory to the specified
@@ -5880,6 +5882,8 @@
             rev = repo[repo[None].branch()].rev()
         mergemod._checkunknown(repo, repo[None], repo[rev])
 
+    repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
+
     if clean:
         ret = hg.clean(repo, rev)
     else:
--- a/tests/test-completion.t	Fri May 02 01:09:14 2014 +0200
+++ b/tests/test-completion.t	Mon May 19 01:53:34 2014 +0200
@@ -212,7 +212,7 @@
   serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
   status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos
   summary: remote
-  update: clean, check, date, rev
+  update: clean, check, date, rev, tool
   addremove: similarity, include, exclude, dry-run
   archive: no-decode, prefix, rev, type, subrepos, include, exclude
   backout: merge, parent, rev, tool, include, exclude, message, logfile, date, user
--- a/tests/test-merge-tools.t	Fri May 02 01:09:14 2014 +0200
+++ b/tests/test-merge-tools.t	Mon May 19 01:53:34 2014 +0200
@@ -587,6 +587,54 @@
 
   $ unset HGMERGE # make sure HGMERGE doesn't interfere with remaining tests
 
+update is a merge ...
+
+  $ beforemerge
+  [merge-tools]
+  false.whatever=
+  true.priority=1
+  true.executable=cat
+  # hg update -C 1
+  $ hg debugsetparent 0
+  $ hg update -r 2
+  merging f
+  revision 1
+  space
+  revision 0
+  space
+  revision 2
+  space
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  $ aftermerge
+  # cat f
+  revision 1
+  space
+  # hg stat
+  M f
+
+update should also have --tool
+
+  $ beforemerge
+  [merge-tools]
+  false.whatever=
+  true.priority=1
+  true.executable=cat
+  # hg update -C 1
+  $ hg debugsetparent 0
+  $ hg update -r 2 --tool false
+  merging f
+  merging f failed!
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges
+  [1]
+  $ aftermerge
+  # cat f
+  revision 1
+  space
+  # hg stat
+  M f
+  ? f.orig
+
 Default is silent simplemerge:
 
   $ beforemerge