merge: improve error messages for path conflicts during update
Differential Revision: https://phab.mercurial-scm.org/D782
--- a/mercurial/merge.py Mon Oct 02 14:05:30 2017 -0700
+++ b/mercurial/merge.py Mon Oct 02 14:05:30 2017 -0700
@@ -741,13 +741,23 @@
actions[f] = ('g', (fl2, True), "remote created")
for f in sorted(abortconflicts):
- repo.ui.warn(_("%s: untracked file differs\n") % f)
+ warn = repo.ui.warn
+ if f in pathconflicts:
+ if repo.wvfs.isfileorlink(f):
+ warn(_("%s: untracked file conflicts with directory\n") % f)
+ else:
+ warn(_("%s: untracked directory conflicts with file\n") % f)
+ else:
+ warn(_("%s: untracked file differs\n") % f)
if abortconflicts:
raise error.Abort(_("untracked files in working directory "
"differ from files in requested revision"))
for f in sorted(warnconflicts):
- repo.ui.warn(_("%s: replacing untracked file\n") % f)
+ if repo.wvfs.isfileorlink(f):
+ repo.ui.warn(_("%s: replacing untracked file\n") % f)
+ else:
+ repo.ui.warn(_("%s: replacing untracked files in directory\n") % f)
for f, (m, args, msg) in actions.iteritems():
if m == 'c':
--- a/tests/test-merge1.t Mon Oct 02 14:05:30 2017 -0700
+++ b/tests/test-merge1.t Mon Oct 02 14:05:30 2017 -0700
@@ -30,7 +30,7 @@
$ mkdir b && touch b/nonempty
$ hg up
- b: untracked file differs
+ b: untracked directory conflicts with file
abort: untracked files in working directory differ from files in requested revision
[255]
$ hg ci
--- a/tests/test-pathconflicts-basic.t Mon Oct 02 14:05:30 2017 -0700
+++ b/tests/test-pathconflicts-basic.t Mon Oct 02 14:05:30 2017 -0700
@@ -37,7 +37,7 @@
$ mkdir a
$ echo 3 > a/b
$ hg up file
- a: untracked file differs
+ a: untracked directory conflicts with file
abort: untracked files in working directory differ from files in requested revision
[255]
$ hg up --clean file
--- a/tests/test-update-names.t Mon Oct 02 14:05:30 2017 -0700
+++ b/tests/test-update-names.t Mon Oct 02 14:05:30 2017 -0700
@@ -50,7 +50,7 @@
$ hg st
? name/file
$ hg up 1
- name: untracked file differs
+ name: untracked directory conflicts with file
abort: untracked files in working directory differ from files in requested revision
[255]
$ cd ..