comparison mercurial/merge.py @ 23651:72da02d7f126

merge: collect checking for unknown files at end of manifestmerge() The 'c' and 'dc' actions include creating a file on disk and we need to check that no conflicting file exists unless force=True. Move two of the calls to _checkunknownfile() to a single place at the end of manifestmerge(). This removes some of the reading of filelogs from the heart of manifestmerge() and collects it in one place close to where its output (entries in the 'aborts' list) is used. Note that this removes the unnecessary call to _checkunknownfile() when force=True in one of the code paths.
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 19 Nov 2014 11:51:31 -0800
parents b85c548ab14d
children 6fcc3669e483
comparison
equal deleted inserted replaced
23650:b85c548ab14d 23651:72da02d7f126
399 for s in sorted(wctx.substate): 399 for s in sorted(wctx.substate):
400 if wctx.sub(s).dirty(): 400 if wctx.sub(s).dirty():
401 m1['.hgsubstate'] += '+' 401 m1['.hgsubstate'] += '+'
402 break 402 break
403 403
404 aborts = []
405 # Compare manifests 404 # Compare manifests
406 diff = m1.diff(m2) 405 diff = m1.diff(m2)
407 406
408 actions = {} 407 actions = {}
409 for f, ((n1, fl1), (n2, fl2)) in diff.iteritems(): 408 for f, ((n1, fl1), (n2, fl2)) in diff.iteritems():
486 elif f not in ma: 485 elif f not in ma:
487 # local unknown, remote created: the logic is described by the 486 # local unknown, remote created: the logic is described by the
488 # following table: 487 # following table:
489 # 488 #
490 # force branchmerge different | action 489 # force branchmerge different | action
491 # n * n | create 490 # n * * | create
492 # n * y | abort
493 # y n * | create 491 # y n * | create
494 # y y n | create 492 # y y n | create
495 # y y y | merge 493 # y y y | merge
496 # 494 #
497 # Checking whether the files are different is expensive, so we 495 # Checking whether the files are different is expensive, so we
498 # don't do that when we can avoid it. 496 # don't do that when we can avoid it.
499 if not force: 497 if not force:
500 different = _checkunknownfile(repo, wctx, p2, f) 498 actions[f] = ('c', (fl2,), "remote created")
501 if different:
502 aborts.append((f, "ud"))
503 else:
504 actions[f] = ('c', (fl2,), "remote created")
505 elif not branchmerge: 499 elif not branchmerge:
506 actions[f] = ('c', (fl2,), "remote created") 500 actions[f] = ('c', (fl2,), "remote created")
507 else: 501 else:
508 different = _checkunknownfile(repo, wctx, p2, f) 502 different = _checkunknownfile(repo, wctx, p2, f)
509 if different: 503 if different:
510 actions[f] = ('m', (f, f, None, False, pa.node()), 504 actions[f] = ('m', (f, f, None, False, pa.node()),
511 "remote differs from untracked local") 505 "remote differs from untracked local")
512 else: 506 else:
513 actions[f] = ('g', (fl2,), "remote created") 507 actions[f] = ('g', (fl2,), "remote created")
514 elif n2 != ma[f]: 508 elif n2 != ma[f]:
515 different = _checkunknownfile(repo, wctx, p2, f) 509 if acceptremote:
516 if not force and different: 510 actions[f] = ('c', (fl2,), "remote recreating")
517 aborts.append((f, 'ud'))
518 else: 511 else:
519 if acceptremote: 512 actions[f] = ('dc', (fl2,), "prompt deleted/changed")
520 actions[f] = ('c', (fl2,), "remote recreating") 513
521 else: 514 aborts = []
522 actions[f] = ('dc', (fl2,), "prompt deleted/changed") 515 if not force:
516 for f, (m, args, msg) in actions.iteritems():
517 if m in ('c', 'dc'):
518 if _checkunknownfile(repo, wctx, p2, f):
519 aborts.append((f, "ud"))
523 520
524 for f, m in sorted(aborts): 521 for f, m in sorted(aborts):
525 if m == 'ud': 522 if m == 'ud':
526 repo.ui.warn(_("%s: untracked file differs\n") % f) 523 repo.ui.warn(_("%s: untracked file differs\n") % f)
527 else: assert False, m 524 else: assert False, m