Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 23655:79235b46062c
merge: extract method for checking for conflicting untracked file
Now that the functionality is collected in one place, let's extract it
to a method.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sat, 13 Dec 2014 23:52:22 -0800 |
parents | 9d56be47b5d6 |
children | d3e137c91f94 |
comparison
equal
deleted
inserted
replaced
23654:9d56be47b5d6 | 23655:79235b46062c |
---|---|
302 f2 = f | 302 f2 = f |
303 return (os.path.isfile(repo.wjoin(f)) | 303 return (os.path.isfile(repo.wjoin(f)) |
304 and repo.wopener.audit.check(f) | 304 and repo.wopener.audit.check(f) |
305 and repo.dirstate.normalize(f) not in repo.dirstate | 305 and repo.dirstate.normalize(f) not in repo.dirstate |
306 and mctx[f2].cmp(wctx[f])) | 306 and mctx[f2].cmp(wctx[f])) |
307 | |
308 def _checkunknownfiles(repo, wctx, mctx, force, actions): | |
309 """ | |
310 Considers any actions that care about the presence of conflicting unknown | |
311 files. For some actions, the result is to abort; for others, it is to | |
312 choose a different action. | |
313 """ | |
314 aborts = [] | |
315 if not force: | |
316 for f, (m, args, msg) in actions.iteritems(): | |
317 if m in ('c', 'dc'): | |
318 if _checkunknownfile(repo, wctx, mctx, f): | |
319 aborts.append(f) | |
320 elif m == 'dg': | |
321 if _checkunknownfile(repo, wctx, mctx, f, args[0]): | |
322 aborts.append(f) | |
323 | |
324 for f in sorted(aborts): | |
325 repo.ui.warn(_("%s: untracked file differs\n") % f) | |
326 if aborts: | |
327 raise util.Abort(_("untracked files in working directory differ " | |
328 "from files in requested revision")) | |
329 | |
330 for f, (m, args, msg) in actions.iteritems(): | |
331 if m == 'c': | |
332 actions[f] = ('g', args, msg) | |
333 elif m == 'cm': | |
334 fl2, anc = args | |
335 different = _checkunknownfile(repo, wctx, mctx, f) | |
336 if different: | |
337 actions[f] = ('m', (f, f, None, False, anc), | |
338 "remote differs from untracked local") | |
339 else: | |
340 actions[f] = ('g', (fl2,), "remote created") | |
307 | 341 |
308 def _forgetremoved(wctx, mctx, branchmerge): | 342 def _forgetremoved(wctx, mctx, branchmerge): |
309 """ | 343 """ |
310 Forget removed files | 344 Forget removed files |
311 | 345 |
507 if acceptremote: | 541 if acceptremote: |
508 actions[f] = ('c', (fl2,), "remote recreating") | 542 actions[f] = ('c', (fl2,), "remote recreating") |
509 else: | 543 else: |
510 actions[f] = ('dc', (fl2,), "prompt deleted/changed") | 544 actions[f] = ('dc', (fl2,), "prompt deleted/changed") |
511 | 545 |
512 aborts = [] | 546 _checkunknownfiles(repo, wctx, p2, force, actions) |
513 if not force: | |
514 for f, (m, args, msg) in actions.iteritems(): | |
515 if m in ('c', 'dc'): | |
516 if _checkunknownfile(repo, wctx, p2, f): | |
517 aborts.append(f) | |
518 elif m == 'dg': | |
519 if _checkunknownfile(repo, wctx, p2, f, args[0]): | |
520 aborts.append(f) | |
521 | |
522 for f in sorted(aborts): | |
523 repo.ui.warn(_("%s: untracked file differs\n") % f) | |
524 if aborts: | |
525 raise util.Abort(_("untracked files in working directory differ " | |
526 "from files in requested revision")) | |
527 | |
528 for f, (m, args, msg) in actions.iteritems(): | |
529 if m == 'c': | |
530 actions[f] = ('g', args, msg) | |
531 elif m == 'cm': | |
532 fl2, anc = args | |
533 different = _checkunknownfile(repo, wctx, p2, f) | |
534 if different: | |
535 actions[f] = ('m', (f, f, None, False, anc), | |
536 "remote differs from untracked local") | |
537 else: | |
538 actions[f] = ('g', (fl2,), "remote created") | |
539 | 547 |
540 return actions, diverge, renamedelete | 548 return actions, diverge, renamedelete |
541 | 549 |
542 def _resolvetrivial(repo, wctx, mctx, ancestor, actions): | 550 def _resolvetrivial(repo, wctx, mctx, ancestor, actions): |
543 """Resolves false conflicts where the nodeid changed but the content | 551 """Resolves false conflicts where the nodeid changed but the content |