Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 34549:a991e1d6bc82
merge: backup conflicting directories when getting files
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.
Differential Revision: https://phab.mercurial-scm.org/D778
author | Mark Thomas <mbthomas@fb.com> |
---|---|
date | Mon, 02 Oct 2017 14:05:30 -0700 |
parents | b4955650eb57 |
children | 53e4bcab346b |
comparison
equal
deleted
inserted
replaced
34548:b4955650eb57 | 34549:a991e1d6bc82 |
---|---|
1165 repo.ui.debug(" %s: %s -> g\n" % (f, msg)) | 1165 repo.ui.debug(" %s: %s -> g\n" % (f, msg)) |
1166 if verbose: | 1166 if verbose: |
1167 repo.ui.note(_("getting %s\n") % f) | 1167 repo.ui.note(_("getting %s\n") % f) |
1168 | 1168 |
1169 if backup: | 1169 if backup: |
1170 # If a file or directory exists with the same name, back that | |
1171 # up. Otherwise, look to see if there is a file that conflicts | |
1172 # with a directory this file is in, and if so, back that up. | |
1170 absf = repo.wjoin(f) | 1173 absf = repo.wjoin(f) |
1174 if not repo.wvfs.lexists(f): | |
1175 for p in util.finddirs(f): | |
1176 if repo.wvfs.isfileorlink(p): | |
1177 absf = repo.wjoin(p) | |
1178 break | |
1171 orig = scmutil.origpath(ui, repo, absf) | 1179 orig = scmutil.origpath(ui, repo, absf) |
1172 try: | 1180 if repo.wvfs.lexists(absf): |
1173 if repo.wvfs.isfileorlink(f): | 1181 util.rename(absf, orig) |
1174 util.rename(absf, orig) | |
1175 except OSError as e: | |
1176 if e.errno != errno.ENOENT: | |
1177 raise | |
1178 wctx[f].clearunknown() | 1182 wctx[f].clearunknown() |
1179 wctx[f].write(fctx(f).data(), flags, backgroundclose=True) | 1183 wctx[f].write(fctx(f).data(), flags, backgroundclose=True) |
1180 if i == 100: | 1184 if i == 100: |
1181 yield i, f | 1185 yield i, f |
1182 i = 0 | 1186 i = 0 |