Mercurial > public > mercurial-scm > hg-stable
diff mercurial/merge.py @ 23653:0297d8469350
merge: don't overwrite untracked file at directory rename target
When a directory was renamed and a new untracked file was added in the
new directory and the remote directory added a file by the same name
in the old directory, the local untracked file gets overwritten, as
demonstrated by the broken test case in test-rename-dir-merge.
Fix by checking for unknown files for 'dg' actions too. Since
_checkunknownfile() currently expects the same filename in both
contexts, we need to add a new parameter for the remote filename to
it.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 12 Dec 2014 23:18:36 -0800 |
parents | 6fcc3669e483 |
children | 9d56be47b5d6 |
line wrap: on
line diff
--- a/mercurial/merge.py Tue Nov 18 20:29:25 2014 -0800 +++ b/mercurial/merge.py Fri Dec 12 23:18:36 2014 -0800 @@ -297,11 +297,13 @@ self.mark(dfile, 'r') return r -def _checkunknownfile(repo, wctx, mctx, f): +def _checkunknownfile(repo, wctx, mctx, f, f2=None): + if f2 is None: + f2 = f return (os.path.isfile(repo.wjoin(f)) and repo.wopener.audit.check(f) and repo.dirstate.normalize(f) not in repo.dirstate - and mctx[f].cmp(wctx[f])) + and mctx[f2].cmp(wctx[f])) def _forgetremoved(wctx, mctx, branchmerge): """ @@ -517,6 +519,9 @@ if m in ('c', 'dc'): if _checkunknownfile(repo, wctx, p2, f): aborts.append(f) + elif m == 'dg': + if _checkunknownfile(repo, wctx, p2, f, args[0]): + aborts.append(f) for f in sorted(aborts): repo.ui.warn(_("%s: untracked file differs\n") % f)