Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
23652:6fcc3669e483 | 23653:0297d8469350 |
---|---|
295 self._dirty = True | 295 self._dirty = True |
296 elif not r: | 296 elif not r: |
297 self.mark(dfile, 'r') | 297 self.mark(dfile, 'r') |
298 return r | 298 return r |
299 | 299 |
300 def _checkunknownfile(repo, wctx, mctx, f): | 300 def _checkunknownfile(repo, wctx, mctx, f, f2=None): |
301 if f2 is None: | |
302 f2 = f | |
301 return (os.path.isfile(repo.wjoin(f)) | 303 return (os.path.isfile(repo.wjoin(f)) |
302 and repo.wopener.audit.check(f) | 304 and repo.wopener.audit.check(f) |
303 and repo.dirstate.normalize(f) not in repo.dirstate | 305 and repo.dirstate.normalize(f) not in repo.dirstate |
304 and mctx[f].cmp(wctx[f])) | 306 and mctx[f2].cmp(wctx[f])) |
305 | 307 |
306 def _forgetremoved(wctx, mctx, branchmerge): | 308 def _forgetremoved(wctx, mctx, branchmerge): |
307 """ | 309 """ |
308 Forget removed files | 310 Forget removed files |
309 | 311 |
515 if not force: | 517 if not force: |
516 for f, (m, args, msg) in actions.iteritems(): | 518 for f, (m, args, msg) in actions.iteritems(): |
517 if m in ('c', 'dc'): | 519 if m in ('c', 'dc'): |
518 if _checkunknownfile(repo, wctx, p2, f): | 520 if _checkunknownfile(repo, wctx, p2, f): |
519 aborts.append(f) | 521 aborts.append(f) |
522 elif m == 'dg': | |
523 if _checkunknownfile(repo, wctx, p2, f, args[0]): | |
524 aborts.append(f) | |
520 | 525 |
521 for f in sorted(aborts): | 526 for f in sorted(aborts): |
522 repo.ui.warn(_("%s: untracked file differs\n") % f) | 527 repo.ui.warn(_("%s: untracked file differs\n") % f) |
523 if aborts: | 528 if aborts: |
524 raise util.Abort(_("untracked files in working directory differ " | 529 raise util.Abort(_("untracked files in working directory differ " |