# HG changeset patch # User Pulkit Goyal <7895pul...@gmail.com> # Date 1497736426 -19800 # Sun Jun 18 03:23:46 2017 +0530 # Node ID 3c6e013ffb8cb4e76b1e496bf8c34ebf790a506d # Parent 522b3457c765d271d8029a92dc3d8590b6679c6b topics: make sure we commit on new parents while changing topics (issue5441)
While changing topics of a set of linear commits, we used to commit our new changesets with new topic on parents of its predecessor i.e. changeset before the topic change. If the topic of parent was also changed, that parent will become obsolete and hence resulting the cnew commit in unstable state. For a set of linear commits this repeats and we end up in a tree state as mentioned in the bug. This patch fixes the bug by checking whether the parent was obsoleted and if yes, commit on the new parent. diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py +++ b/hgext3rd/topic/__init__.py @@ -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],))]) diff --git a/tests/test-topic.t b/tests/test-topic.t --- a/tests/test-topic.t +++ b/tests/test-topic.t @@ -679,30 +679,28 @@ changed topic on 2 changes please run hg evolve --rev "topic(changewat)" now $ hg log -Gr 'draft()' - o changeset: 21:3c7d84fcabcd + o changeset: 21:58e15a6365ca | tag: tip | topic: changewat - | parent: 13:d91cd8fd490e | user: test | date: Thu Jan 01 00:00:00 1970 +0000 - | trouble: unstable | summary: fran? | - | o changeset: 20:a96ac830b62e - | | topic: changewat - | | parent: 3:a53952faf762 + o changeset: 20:a96ac830b62e + | topic: changewat + | parent: 3:a53952faf762 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: start on fran + | + | @ changeset: 19:b72b86a1f96b + | | topic: watwat + | | parent: 13:d91cd8fd490e | | user: test | | date: Thu Jan 01 00:00:00 1970 +0000 - | | summary: start on fran + | | summary: fran? | | - +---@ changeset: 19:b72b86a1f96b - | | topic: watwat - | | parent: 13:d91cd8fd490e - | | user: test - | | date: Thu Jan 01 00:00:00 1970 +0000 - | | summary: fran? - | | - x | changeset: 13:d91cd8fd490e + | x changeset: 13:d91cd8fd490e |/ topic: wat | parent: 3:a53952faf762 | user: test _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel