--- a/hgext3rd/topic/__init__.py Sun Jun 18 03:20:52 2017 +0530
+++ b/hgext3rd/topic/__init__.py Sun Jun 18 03:23:46 2017 +0530
@@ -282,6 +282,10 @@
l = repo.lock()
txn = repo.transaction('rewrite-topics')
try:
+ newp = None
+ oldp = None
+ p1 = None
+ p2 = None
for c in repo.set('%r', change):
def filectxfn(repo, ctx, path):
try:
@@ -309,11 +313,25 @@
ui.debug('changing topic of %s from %s to %s\n' % (
c, oldtopic, newtopic))
ui.debug('fixedextra: %r\n' % fixedextra)
+ # While changing topic of set of linear commits, make sure that
+ # we base our commits on new parent rather than old parent which
+ # was obsoleted while changing the topic
+ if newp and c.p1().node() == oldp:
+ p1 = newp
+ p2 = c.p2().node()
+ elif newp and c.p2().node() == oldp:
+ p1 = c.p1().node()
+ p2 = newp
+ else:
+ p1 = c.p1().node()
+ p2 = c.p2().node()
mc = context.memctx(
- repo, (c.p1().node(), c.p2().node()), c.description(),
+ repo, (p1, p2), c.description(),
c.files(), filectxfn,
user=c.user(), date=c.date(), extra=fixedextra)
newnode = repo.commitctx(mc)
+ oldp = c.node()
+ newp = newnode
ui.debug('new node id is %s\n' % node.hex(newnode))
needevolve = needevolve or (len(c.children()) > 0)
obsolete.createmarkers(repo, [(c, (repo[newnode],))])