@@ -733,12 +733,13 @@
* none: don't check (merge working directory changes into destination)
* linear: check that update is linear before merging working directory
changes into destination
+ * noconflict: check that the update does not result in file merges
This returns whether conflict is detected at updating or not.
"""
if updatecheck is None:
updatecheck = ui.config('experimental', 'updatecheck')
- if updatecheck not in ('abort', 'none', 'linear'):
+ if updatecheck not in ('abort', 'none', 'linear', 'noconflict'):
# If not configured, or invalid value configured
updatecheck = 'linear'
with repo.wlock():
@@ -1501,7 +1501,7 @@
# updatecheck='abort' to better suppport some of these callers.
if updatecheck is None:
updatecheck = 'linear'
- assert updatecheck in ('none', 'linear')
+ assert updatecheck in ('none', 'linear', 'noconflict')
# If we're doing a partial update, we need to skip updating
# the dirstate, so make a note of any partial-ness to the
# update here.
@@ -1596,6 +1596,13 @@
repo, wc, p2, pas, branchmerge, force, mergeancestor,
followcopies, matcher=matcher, mergeforce=mergeforce)
+ if updatecheck == 'noconflict':
+ for f, (m, args, msg) in actionbyfile.iteritems():
+ if m not in ('g', 'k', 'r'):
+ msg = _("uncommitted changes")
+ hint = _("commit or update --merge to allow merge")
+ raise error.Abort(msg, hint=hint)
+
# Prompt and create actions. Most of this is in the resolve phase
# already, but we can't handle .hgsubstate in filemerge or
# subrepo.submerge yet so we have to keep prompting for it.
@@ -253,6 +253,65 @@
>>>>>>> destination: d047485b3896 b1 - test: 4
$ rm a.orig
+ $ echo 'updatecheck = noconflict' >> .hg/hgrc
+
+ $ revtest 'none dirty cross' dirty 3 4
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ parent=4
+ M foo
+
+ $ revtest 'none dirty linear' dirty 1 2
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ parent=2
+ M foo
+
+ $ revtest 'none dirty linear' dirty 1 2 -c
+ abort: uncommitted changes
+ parent=1
+ M foo
+
+ $ revtest 'none dirty linear' dirty 1 2 -C
+ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ parent=2
+
+Locally added file is allowed
+ $ hg up -qC 3
+ $ echo a > bar
+ $ hg add bar
+ $ hg up -q 4
+ $ hg st
+ A bar
+ $ hg forget bar
+ $ rm bar
+
+Locally removed file is allowed
+ $ hg up -qC 3
+ $ hg rm a
+ $ hg up -q 4
+ abort: uncommitted changes
+ (commit or update --merge to allow merge)
+ [255]
+
+File conflict is not allowed
+ $ hg up -qC 3
+ $ echo dirty >> a
+ $ hg up -q 4
+ abort: uncommitted changes
+ (commit or update --merge to allow merge)
+ [255]
+ $ hg up -m 4
+ merging a
+ warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+ 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+ use 'hg resolve' to retry unresolved file merges
+ [1]
+ $ rm a.orig
+
+Change/delete conflict is not allowed
+ $ hg up -qC 3
+ $ hg rm foo
+ $ hg up -q 4
+
Uses default value of "linear" when value is misspelled
$ echo 'updatecheck = linyar' >> .hg/hgrc