Mercurial > public > mercurial-scm > hg
diff hgext/strip.py @ 34621:5613fb1583d6
strip: take branch into account when selecting update target (issue5540)
Test contributed by Matt Harbison
Keep the same behavior in most cases (i.e. first parent of the first root of
stripped changsets), but if the branch differs from wdir's, try to find another
parent of stripped commits that is on the same branch.
author | Paul Morelle <paul.morelle@octobus.net> |
---|---|
date | Thu, 05 Oct 2017 16:13:05 +0200 |
parents | 05c2a9f37a1d |
children | 011ca2d795d6 |
line wrap: on
line diff
--- a/hgext/strip.py Wed Oct 04 18:49:09 2017 +0200 +++ b/hgext/strip.py Thu Oct 05 16:13:05 2017 +0200 @@ -60,10 +60,19 @@ def _findupdatetarget(repo, nodes): unode, p2 = repo.changelog.parents(nodes[0]) + currentbranch = repo[None].branch() if (util.safehasattr(repo, 'mq') and p2 != nullid and p2 in [x.node for x in repo.mq.applied]): unode = p2 + elif currentbranch != repo[unode].branch(): + pwdir = 'parents(wdir())' + revset = 'max(((parents(%ln::%r) + %r) - %ln::%r) and branch(%s))' + branchtarget = repo.revs(revset, nodes, pwdir, pwdir, nodes, pwdir, + currentbranch) + if branchtarget: + cl = repo.changelog + unode = cl.node(branchtarget.first()) return unode