492 |
492 |
493 If a changeset application fails, you can fix the merge by hand |
493 If a changeset application fails, you can fix the merge by hand |
494 and then resume where you left off by calling :hg:`transplant |
494 and then resume where you left off by calling :hg:`transplant |
495 --continue/-c`. |
495 --continue/-c`. |
496 ''' |
496 ''' |
497 def incwalk(repo, commmon, branches, match=util.always): |
497 def incwalk(repo, csets, match=util.always): |
498 if not branches: |
498 for node in csets: |
499 branches = None |
|
500 for node in repo.changelog.findmissing(common, branches): |
|
501 if match(node): |
499 if match(node): |
502 yield node |
500 yield node |
503 |
501 |
504 def transplantwalk(repo, root, branches, match=util.always): |
502 def transplantwalk(repo, root, branches, match=util.always): |
505 if not branches: |
503 if not branches: |
545 raise util.Abort(_('outstanding uncommitted merges')) |
543 raise util.Abort(_('outstanding uncommitted merges')) |
546 m, a, r, d = repo.status()[:4] |
544 m, a, r, d = repo.status()[:4] |
547 if m or a or r or d: |
545 if m or a or r or d: |
548 raise util.Abort(_('outstanding local changes')) |
546 raise util.Abort(_('outstanding local changes')) |
549 |
547 |
550 bundle = None |
548 sourcerepo = opts.get('source') |
551 source = opts.get('source') |
549 if sourcerepo: |
552 if source: |
550 source = hg.repository(ui, ui.expandpath(sourcerepo)) |
553 sourcerepo = ui.expandpath(source) |
551 branches = map(source.lookup, opts.get('branch', ())) |
554 source = hg.repository(ui, sourcerepo) |
552 source, csets, cleanupfn = bundlerepo.getremotechanges(ui, repo, source, |
555 source, common, anyinc, bundle = bundlerepo.getremotechanges(ui, repo, |
553 onlyheads=branches, force=True) |
556 source, force=True) |
|
557 else: |
554 else: |
558 source = repo |
555 source = repo |
|
556 branches = map(source.lookup, opts.get('branch', ())) |
|
557 cleanupfn = None |
559 |
558 |
560 try: |
559 try: |
561 if opts.get('continue'): |
560 if opts.get('continue'): |
562 tp.resume(repo, source, opts) |
561 tp.resume(repo, source, opts) |
563 return |
562 return |
567 prune = [source.lookup(r) |
566 prune = [source.lookup(r) |
568 for r in cmdutil.revrange(source, opts.get('prune'))] |
567 for r in cmdutil.revrange(source, opts.get('prune'))] |
569 matchfn = lambda x: tf(x) and x not in prune |
568 matchfn = lambda x: tf(x) and x not in prune |
570 else: |
569 else: |
571 matchfn = tf |
570 matchfn = tf |
572 branches = map(source.lookup, opts.get('branch', ())) |
|
573 merges = map(source.lookup, opts.get('merge', ())) |
571 merges = map(source.lookup, opts.get('merge', ())) |
574 revmap = {} |
572 revmap = {} |
575 if revs: |
573 if revs: |
576 for r in cmdutil.revrange(source, revs): |
574 for r in cmdutil.revrange(source, revs): |
577 revmap[int(r)] = source.lookup(r) |
575 revmap[int(r)] = source.lookup(r) |
578 elif opts.get('all') or not merges: |
576 elif opts.get('all') or not merges: |
579 if source != repo: |
577 if source != repo: |
580 alltransplants = incwalk(source, common, branches, |
578 alltransplants = incwalk(source, csets, match=matchfn) |
581 match=matchfn) |
|
582 else: |
579 else: |
583 alltransplants = transplantwalk(source, p1, branches, |
580 alltransplants = transplantwalk(source, p1, branches, |
584 match=matchfn) |
581 match=matchfn) |
585 if opts.get('all'): |
582 if opts.get('all'): |
586 revs = alltransplants |
583 revs = alltransplants |
592 for r in merges: |
589 for r in merges: |
593 revmap[source.changelog.rev(r)] = r |
590 revmap[source.changelog.rev(r)] = r |
594 |
591 |
595 tp.apply(repo, source, revmap, merges, opts) |
592 tp.apply(repo, source, revmap, merges, opts) |
596 finally: |
593 finally: |
597 if bundle: |
594 if cleanupfn: |
598 source.close() |
595 cleanupfn() |
599 os.unlink(bundle) |
|
600 |
596 |
601 def revsettransplanted(repo, subset, x): |
597 def revsettransplanted(repo, subset, x): |
602 """``transplanted(set)`` |
598 """``transplanted(set)`` |
603 Transplanted changesets in set. |
599 Transplanted changesets in set. |
604 """ |
600 """ |