comparison mercurial/merge.py @ 23650:b85c548ab14d

merge: introduce 'c' action like 'g', but with additional safety _checkunknownfile() reads the filelog of the remote side's file. For narrow clones, the filelog will not exist for all files and we need a way to avoid reading them. While it would be easier for the narrow extension to just override _checkunknownfile() and make it ignore files outside the narrow clone, it seems cleaner to have manifestmerge() not care about filelogs (considering its name). In order to move the calls to _checkunknownfile() out, we need to be able to tell in which cases we should check for unknown files. Let's start by introducing a new action distinct from 'g' for this purpose. Specifically, the new action will be just like 'g' except that it will check that for conflicting unknown files first. For now, just add the new action type and convert it to 'g'.
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 19 Nov 2014 11:48:30 -0800
parents 18ab5e5955df
children 72da02d7f126
comparison
equal deleted inserted replaced
23649:18ab5e5955df 23650:b85c548ab14d
486 elif f not in ma: 486 elif f not in ma:
487 # local unknown, remote created: the logic is described by the 487 # local unknown, remote created: the logic is described by the
488 # following table: 488 # following table:
489 # 489 #
490 # force branchmerge different | action 490 # force branchmerge different | action
491 # n * n | get 491 # n * n | create
492 # n * y | abort 492 # n * y | abort
493 # y n * | get 493 # y n * | create
494 # y y n | get 494 # y y n | create
495 # y y y | merge 495 # y y y | merge
496 # 496 #
497 # Checking whether the files are different is expensive, so we 497 # Checking whether the files are different is expensive, so we
498 # don't do that when we can avoid it. 498 # don't do that when we can avoid it.
499 if not force: 499 if not force:
500 different = _checkunknownfile(repo, wctx, p2, f) 500 different = _checkunknownfile(repo, wctx, p2, f)
501 if different: 501 if different:
502 aborts.append((f, "ud")) 502 aborts.append((f, "ud"))
503 else: 503 else:
504 actions[f] = ('g', (fl2,), "remote created") 504 actions[f] = ('c', (fl2,), "remote created")
505 elif not branchmerge: 505 elif not branchmerge:
506 actions[f] = ('g', (fl2,), "remote created") 506 actions[f] = ('c', (fl2,), "remote created")
507 else: 507 else:
508 different = _checkunknownfile(repo, wctx, p2, f) 508 different = _checkunknownfile(repo, wctx, p2, f)
509 if different: 509 if different:
510 actions[f] = ('m', (f, f, None, False, pa.node()), 510 actions[f] = ('m', (f, f, None, False, pa.node()),
511 "remote differs from untracked local") 511 "remote differs from untracked local")
515 different = _checkunknownfile(repo, wctx, p2, f) 515 different = _checkunknownfile(repo, wctx, p2, f)
516 if not force and different: 516 if not force and different:
517 aborts.append((f, 'ud')) 517 aborts.append((f, 'ud'))
518 else: 518 else:
519 if acceptremote: 519 if acceptremote:
520 actions[f] = ('g', (fl2,), "remote recreating") 520 actions[f] = ('c', (fl2,), "remote recreating")
521 else: 521 else:
522 actions[f] = ('dc', (fl2,), "prompt deleted/changed") 522 actions[f] = ('dc', (fl2,), "prompt deleted/changed")
523 523
524 for f, m in sorted(aborts): 524 for f, m in sorted(aborts):
525 if m == 'ud': 525 if m == 'ud':
526 repo.ui.warn(_("%s: untracked file differs\n") % f) 526 repo.ui.warn(_("%s: untracked file differs\n") % f)
527 else: assert False, m 527 else: assert False, m
528 if aborts: 528 if aborts:
529 raise util.Abort(_("untracked files in working directory differ " 529 raise util.Abort(_("untracked files in working directory differ "
530 "from files in requested revision")) 530 "from files in requested revision"))
531
532 for f, (m, args, msg) in actions.iteritems():
533 if m == 'c':
534 actions[f] = ('g', args, msg)
531 535
532 return actions, diverge, renamedelete 536 return actions, diverge, renamedelete
533 537
534 def _resolvetrivial(repo, wctx, mctx, ancestor, actions): 538 def _resolvetrivial(repo, wctx, mctx, ancestor, actions):
535 """Resolves false conflicts where the nodeid changed but the content 539 """Resolves false conflicts where the nodeid changed but the content