D778: merge: backup conflicting directories when getting files
mbthomas (Mark Thomas)
phabricator at mercurial-scm.org
Fri Sep 22 09:28:17 UTC 2017
mbthomas created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
During batchget, if a target file conflicts with a directory, or if the
directory a target file is in conflicts with a file, backup and remove the
conflicting file or directory before performing the get.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D778
AFFECTED FILES
mercurial/merge.py
CHANGE DETAILS
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1163,14 +1163,18 @@
repo.ui.note(_("getting %s\n") % f)
if backup:
+ # If a file or directory exists with the same name, back that
+ # up. Otherwise, look to see if there is a file that conflicts
+ # with a directory this file is in, and if so, back that up.
absf = repo.wjoin(f)
+ if not repo.wvfs.lexists(f):
+ for p in util.finddirs(f):
+ if repo.wvfs.isfileorlink(p):
+ absf = repo.wjoin(p)
+ break
orig = scmutil.origpath(ui, repo, absf)
- try:
- if repo.wvfs.isfileorlink(f):
- util.rename(absf, orig)
- except OSError as e:
- if e.errno != errno.ENOENT:
- raise
+ if repo.wvfs.lexists(absf):
+ util.rename(absf, orig)
wctx[f].clearunknown()
wctx[f].write(fctx(f).data(), flags, backgroundclose=True)
if i == 100:
To: mbthomas, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list