hgext/transplant.py
changeset 45942 89a2afe31e82
parent 45840 527ce85c2e60
child 46113 59fa3890d40a
equal deleted inserted replaced
45941:346af7687c6f 45942:89a2afe31e82
    60 
    60 
    61 configtable = {}
    61 configtable = {}
    62 configitem = registrar.configitem(configtable)
    62 configitem = registrar.configitem(configtable)
    63 
    63 
    64 configitem(
    64 configitem(
    65     b'transplant', b'filter', default=None,
    65     b'transplant',
       
    66     b'filter',
       
    67     default=None,
    66 )
    68 )
    67 configitem(
    69 configitem(
    68     b'transplant', b'log', default=None,
    70     b'transplant',
       
    71     b'log',
       
    72     default=None,
    69 )
    73 )
    70 
    74 
    71 
    75 
    72 class transplantentry(object):
    76 class transplantentry(object):
    73     def __init__(self, lnode, rnode):
    77     def __init__(self, lnode, rnode):
   138             )
   142             )
   139 
   143 
   140         self.getcommiteditor = getcommiteditor
   144         self.getcommiteditor = getcommiteditor
   141 
   145 
   142     def applied(self, repo, node, parent):
   146     def applied(self, repo, node, parent):
   143         '''returns True if a node is already an ancestor of parent
   147         """returns True if a node is already an ancestor of parent
   144         or is parent or has already been transplanted'''
   148         or is parent or has already been transplanted"""
   145         if hasnode(repo, parent):
   149         if hasnode(repo, parent):
   146             parentrev = repo.changelog.rev(parent)
   150             parentrev = repo.changelog.rev(parent)
   147         if hasnode(repo, node):
   151         if hasnode(repo, node):
   148             rev = repo.changelog.rev(node)
   152             rev = repo.changelog.rev(node)
   149             reachable = repo.changelog.ancestors(
   153             reachable = repo.changelog.ancestors(
   680         b'[-m REV] [REV]...'
   684         b'[-m REV] [REV]...'
   681     ),
   685     ),
   682     helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
   686     helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
   683 )
   687 )
   684 def transplant(ui, repo, *revs, **opts):
   688 def transplant(ui, repo, *revs, **opts):
   685     '''transplant changesets from another branch
   689     """transplant changesets from another branch
   686 
   690 
   687     Selected changesets will be applied on top of the current working
   691     Selected changesets will be applied on top of the current working
   688     directory with the log of the original changeset. The changesets
   692     directory with the log of the original changeset. The changesets
   689     are copied and will thus appear twice in the history with different
   693     are copied and will thus appear twice in the history with different
   690     identities.
   694     identities.
   729     start an interactive changeset browser.
   733     start an interactive changeset browser.
   730 
   734 
   731     If a changeset application fails, you can fix the merge by hand
   735     If a changeset application fails, you can fix the merge by hand
   732     and then resume where you left off by calling :hg:`transplant
   736     and then resume where you left off by calling :hg:`transplant
   733     --continue/-c`.
   737     --continue/-c`.
   734     '''
   738     """
   735     with repo.wlock():
   739     with repo.wlock():
   736         return _dotransplant(ui, repo, *revs, **opts)
   740         return _dotransplant(ui, repo, *revs, **opts)
   737 
   741 
   738 
   742 
   739 def _dotransplant(ui, repo, *revs, **opts):
   743 def _dotransplant(ui, repo, *revs, **opts):
   741         for node in csets:
   745         for node in csets:
   742             if match(node):
   746             if match(node):
   743                 yield node
   747                 yield node
   744 
   748 
   745     def transplantwalk(repo, dest, heads, match=util.always):
   749     def transplantwalk(repo, dest, heads, match=util.always):
   746         '''Yield all nodes that are ancestors of a head but not ancestors
   750         """Yield all nodes that are ancestors of a head but not ancestors
   747         of dest.
   751         of dest.
   748         If no heads are specified, the heads of repo will be used.'''
   752         If no heads are specified, the heads of repo will be used."""
   749         if not heads:
   753         if not heads:
   750             heads = repo.heads()
   754             heads = repo.heads()
   751         ancestors = []
   755         ancestors = []
   752         ctx = repo[dest]
   756         ctx = repo[dest]
   753         for head in heads:
   757         for head in heads:
   884 revsetpredicate = registrar.revsetpredicate()
   888 revsetpredicate = registrar.revsetpredicate()
   885 
   889 
   886 
   890 
   887 @revsetpredicate(b'transplanted([set])')
   891 @revsetpredicate(b'transplanted([set])')
   888 def revsettransplanted(repo, subset, x):
   892 def revsettransplanted(repo, subset, x):
   889     """Transplanted changesets in set, or all transplanted changesets.
   893     """Transplanted changesets in set, or all transplanted changesets."""
   890     """
       
   891     if x:
   894     if x:
   892         s = revset.getset(repo, subset, x)
   895         s = revset.getset(repo, subset, x)
   893     else:
   896     else:
   894         s = subset
   897         s = subset
   895     return smartset.baseset(
   898     return smartset.baseset(