hgext/strip.py
changeset 34621 5613fb1583d6
parent 34574 05c2a9f37a1d
child 35824 011ca2d795d6
--- 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