comparison hgext/transplant.py @ 19027:3f5fac4b1cfa

transplant: clarify what --branch do - it has nothing to do with branches --branch specifies heads and has nothing to do with named branches, and it only deals with topological branches to the same extent as all other DAG operations do.
author Mads Kiilerich <madski@unity3d.com>
date Tue, 16 Apr 2013 19:18:38 +0200
parents 8deaa703a622
children b512934988d4
comparison
equal deleted inserted replaced
19026:1dc393614e61 19027:3f5fac4b1cfa
491 displayer.close() 491 displayer.close()
492 return (transplants, merges) 492 return (transplants, merges)
493 493
494 @command('transplant', 494 @command('transplant',
495 [('s', 'source', '', _('pull patches from REPO'), _('REPO')), 495 [('s', 'source', '', _('pull patches from REPO'), _('REPO')),
496 ('b', 'branch', [], 496 ('b', 'branch', [], _('use this source changeset as head'), _('REV')),
497 _('pull patches from branch BRANCH'), _('BRANCH')), 497 ('a', 'all', None, _('pull all changesets up to the --branch revisions')),
498 ('a', 'all', None, _('pull all changesets up to BRANCH')),
499 ('p', 'prune', [], _('skip over REV'), _('REV')), 498 ('p', 'prune', [], _('skip over REV'), _('REV')),
500 ('m', 'merge', [], _('merge at REV'), _('REV')), 499 ('m', 'merge', [], _('merge at REV'), _('REV')),
501 ('', 'parent', '', 500 ('', 'parent', '',
502 _('parent to choose when transplanting merge'), _('REV')), 501 _('parent to choose when transplanting merge'), _('REV')),
503 ('e', 'edit', False, _('invoke editor on commit messages')), 502 ('e', 'edit', False, _('invoke editor on commit messages')),
525 You can rewrite the changelog message with the --filter option. 524 You can rewrite the changelog message with the --filter option.
526 Its argument will be invoked with the current changelog message as 525 Its argument will be invoked with the current changelog message as
527 $1 and the patch as $2. 526 $1 and the patch as $2.
528 527
529 If --source/-s is specified, selects changesets from the named 528 If --source/-s is specified, selects changesets from the named
530 repository. If --branch/-b is specified, selects changesets from 529 repository.
531 the branch holding the named revision, up to that revision. If 530 If --branch/-b is specified, these revisions will be used as
532 --all/-a is specified, all changesets on the branch will be 531 heads when deciding which changsets to transplant, just as if only
533 transplanted, otherwise you will be prompted to select the 532 these revisions had been pulled.
534 changesets you want. 533 If --all/-a is specified, all the revisions up to the heads specified
535 534 with --branch will be transplanted.
536 :hg:`transplant --branch REV --all` will transplant the 535
537 selected branch (up to the named revision) onto your current 536 Example:
538 working directory. 537
538 - transplant all changes up to REV on top of your current revision::
539
540 hg transplant --branch REV --all
539 541
540 You can optionally mark selected transplanted changesets as merge 542 You can optionally mark selected transplanted changesets as merge
541 changesets. You will not be prompted to transplant any ancestors 543 changesets. You will not be prompted to transplant any ancestors
542 of a merged transplant, and you can merge descendants of them 544 of a merged transplant, and you can merge descendants of them
543 normally instead of transplanting them. 545 normally instead of transplanting them.
555 def incwalk(repo, csets, match=util.always): 557 def incwalk(repo, csets, match=util.always):
556 for node in csets: 558 for node in csets:
557 if match(node): 559 if match(node):
558 yield node 560 yield node
559 561
560 def transplantwalk(repo, root, branches, match=util.always): 562 def transplantwalk(repo, dest, heads, match=util.always):
561 if not branches: 563 '''Yield all nodes that are ancestors of a head but not ancestors
562 branches = repo.heads() 564 of dest.
565 If no heads are specified, the heads of repo will be used.'''
566 if not heads:
567 heads = repo.heads()
563 ancestors = [] 568 ancestors = []
564 for branch in branches: 569 for head in heads:
565 ancestors.append(repo.changelog.ancestor(root, branch)) 570 ancestors.append(repo.changelog.ancestor(dest, head))
566 for node in repo.changelog.nodesbetween(ancestors, branches)[0]: 571 for node in repo.changelog.nodesbetween(ancestors, heads)[0]:
567 if match(node): 572 if match(node):
568 yield node 573 yield node
569 574
570 def checkopts(opts, revs): 575 def checkopts(opts, revs):
571 if opts.get('continue'): 576 if opts.get('continue'):
573 raise util.Abort(_('--continue is incompatible with ' 578 raise util.Abort(_('--continue is incompatible with '
574 'branch, all or merge')) 579 'branch, all or merge'))
575 return 580 return
576 if not (opts.get('source') or revs or 581 if not (opts.get('source') or revs or
577 opts.get('merge') or opts.get('branch')): 582 opts.get('merge') or opts.get('branch')):
578 raise util.Abort(_('no source URL, branch tag or revision ' 583 raise util.Abort(_('no source URL, branch revision or revision '
579 'list provided')) 584 'list provided'))
580 if opts.get('all'): 585 if opts.get('all'):
581 if not opts.get('branch'): 586 if not opts.get('branch'):
582 raise util.Abort(_('--all requires a branch revision')) 587 raise util.Abort(_('--all requires a branch revision'))
583 if revs: 588 if revs:
606 raise util.Abort(_('outstanding local changes')) 611 raise util.Abort(_('outstanding local changes'))
607 612
608 sourcerepo = opts.get('source') 613 sourcerepo = opts.get('source')
609 if sourcerepo: 614 if sourcerepo:
610 peer = hg.peer(repo, opts, ui.expandpath(sourcerepo)) 615 peer = hg.peer(repo, opts, ui.expandpath(sourcerepo))
611 branches = map(peer.lookup, opts.get('branch', ())) 616 heads = map(peer.lookup, opts.get('branch', ()))
612 source, csets, cleanupfn = bundlerepo.getremotechanges(ui, repo, peer, 617 source, csets, cleanupfn = bundlerepo.getremotechanges(ui, repo, peer,
613 onlyheads=branches, force=True) 618 onlyheads=heads, force=True)
614 else: 619 else:
615 source = repo 620 source = repo
616 branches = map(source.lookup, opts.get('branch', ())) 621 heads = map(source.lookup, opts.get('branch', ()))
617 cleanupfn = None 622 cleanupfn = None
618 623
619 try: 624 try:
620 if opts.get('continue'): 625 if opts.get('continue'):
621 tp.resume(repo, source, opts) 626 tp.resume(repo, source, opts)
635 revmap[int(r)] = source.lookup(r) 640 revmap[int(r)] = source.lookup(r)
636 elif opts.get('all') or not merges: 641 elif opts.get('all') or not merges:
637 if source != repo: 642 if source != repo:
638 alltransplants = incwalk(source, csets, match=matchfn) 643 alltransplants = incwalk(source, csets, match=matchfn)
639 else: 644 else:
640 alltransplants = transplantwalk(source, p1, branches, 645 alltransplants = transplantwalk(source, p1, heads,
641 match=matchfn) 646 match=matchfn)
642 if opts.get('all'): 647 if opts.get('all'):
643 revs = alltransplants 648 revs = alltransplants
644 else: 649 else:
645 revs, newmerges = browserevs(ui, source, alltransplants, opts) 650 revs, newmerges = browserevs(ui, source, alltransplants, opts)