hgext/strip.py
changeset 34621 5613fb1583d6
parent 34574 05c2a9f37a1d
child 35824 011ca2d795d6
equal deleted inserted replaced
34620:b799f11644d8 34621:5613fb1583d6
    58             raise error.Abort(_("local changed subrepos found" + excsuffix))
    58             raise error.Abort(_("local changed subrepos found" + excsuffix))
    59     return s
    59     return s
    60 
    60 
    61 def _findupdatetarget(repo, nodes):
    61 def _findupdatetarget(repo, nodes):
    62     unode, p2 = repo.changelog.parents(nodes[0])
    62     unode, p2 = repo.changelog.parents(nodes[0])
       
    63     currentbranch = repo[None].branch()
    63 
    64 
    64     if (util.safehasattr(repo, 'mq') and p2 != nullid
    65     if (util.safehasattr(repo, 'mq') and p2 != nullid
    65         and p2 in [x.node for x in repo.mq.applied]):
    66         and p2 in [x.node for x in repo.mq.applied]):
    66         unode = p2
    67         unode = p2
       
    68     elif currentbranch != repo[unode].branch():
       
    69         pwdir = 'parents(wdir())'
       
    70         revset = 'max(((parents(%ln::%r) + %r) - %ln::%r) and branch(%s))'
       
    71         branchtarget = repo.revs(revset, nodes, pwdir, pwdir, nodes, pwdir,
       
    72                                  currentbranch)
       
    73         if branchtarget:
       
    74             cl = repo.changelog
       
    75             unode = cl.node(branchtarget.first())
    67 
    76 
    68     return unode
    77     return unode
    69 
    78 
    70 def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None):
    79 def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None):
    71     with repo.wlock(), repo.lock():
    80     with repo.wlock(), repo.lock():