[PATCH] merge: add option to return successful exit code on a 'no-op merge'

Bernhard Urban lewurm at gmail.com
Tue Nov 4 10:08:22 CST 2014


# HG changeset patch
# User Bernhard Urban <lewurm at gmail.com>
# Date 1415116918 -3600
#      Tue Nov 04 17:01:58 2014 +0100
# Node ID 5c6b2329f67f18a6f2bf9fff2ef86f04337b25ff
# Parent  30e0dcd7c5ffd99fb9c2474e9d73ca01a7d292fa
merge: add option to return successful exit code on a 'no-op merge'

diff -r 30e0dcd7c5ff -r 5c6b2329f67f mercurial/commands.py
--- a/mercurial/commands.py	Thu Oct 16 23:15:35 2014 -0700
+++ b/mercurial/commands.py	Tue Nov 04 17:01:58 2014 +0100
@@ -4530,10 +4530,12 @@
     [('f', 'force', None,
       _('force a merge including outstanding changes (DEPRECATED)')),
     ('r', 'rev', '', _('revision to merge'), _('REV')),
+    ('a', 'acceptnothing', None,
+     _('if the merge has no effect, the exit code is still 0')),
     ('P', 'preview', None,
      _('review revisions to merge (no merge is performed)'))
      ] + mergetoolopts,
-    _('[-P] [-f] [[-r] REV]'))
+    _('[-P] [-a] [-f] [[-r] REV]'))
 def merge(ui, repo, node=None, **opts):
     """merge working directory with another revision
 
@@ -4613,6 +4615,8 @@
             msg, hint = _('nothing to merge'), None
             if parent != repo.lookup(branch):
                 hint = _("use 'hg update' instead")
+            elif opts.get('acceptnothing'):
+                return 0
             raise util.Abort(msg, hint=hint)
 
         if parent not in bheads:
diff -r 30e0dcd7c5ff -r 5c6b2329f67f tests/test-merge-default.t
--- a/tests/test-merge-default.t	Thu Oct 16 23:15:35 2014 -0700
+++ b/tests/test-merge-default.t	Tue Nov 04 17:01:58 2014 +0100
@@ -69,6 +69,10 @@
   abort: nothing to merge
   [255]
 
+Should succeed because --acceptnothing is provided:
+
+  $ hg merge -a
+
   $ hg up 0
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 


More information about the Mercurial-devel mailing list