# HG changeset patch # User Augie Fackler # Date 1449857543 18000 # Node ID 594ca2f3d1de274a512c131e87d4fac4f1f15876 # Parent 9eba8561870b7d814994724acc232c1362629305# Parent ec28b6c3414aedf3988f5a9b790fa9a25f8096e0 Merge. diff -r 9eba8561870b -r 594ca2f3d1de src/topic/__init__.py --- a/src/topic/__init__.py Fri Dec 11 13:09:29 2015 -0500 +++ b/src/topic/__init__.py Fri Dec 11 13:12:23 2015 -0500 @@ -21,6 +21,7 @@ from mercurial import lock from mercurial import merge from mercurial import namespaces +from mercurial import node from mercurial import obsolete from mercurial import patch from mercurial import phases @@ -120,19 +121,32 @@ except error.ManifestLookupError: return None fixedextra = dict(c.extra()) + ui.debug('old node id is %s\n' % node.hex(c.node())) + ui.debug('origextra: %r\n' % fixedextra) newtopic = None if clear else topic - if fixedextra.get(constants.extrakey, '') == topic: + oldtopic = fixedextra.get(constants.extrakey, None) + if oldtopic == newtopic: continue - if clear and constants.extrakey in fixedextra: + if clear: del fixedextra[constants.extrakey] else: fixedextra[constants.extrakey] = topic - c.parents() + if 'amend_source' in fixedextra: + # TODO: right now the commitctx wrapper in + # topicrepo overwrites the topic in extra if + # amend_source is set to support 'hg commit + # --amend'. Support for amend should be adjusted + # to not be so invasive. + del fixedextra['amend_source'] + ui.debug('changing topic of %s from %s to %s\n' % ( + c, oldtopic, newtopic)) + ui.debug('fixedextra: %r\n' % fixedextra) mc = context.memctx( repo, (c.p1().node(), c.p2().node()), c.description(), c.files(), filectxfn, user=c.user(), date=c.date(), extra=fixedextra) newnode = repo.commitctx(mc) + ui.debug('new node id is %s\n' % node.hex(newnode)) needevolve = needevolve or (len(c.children()) > 0) obsolete.createmarkers(repo, [(c, (repo[newnode],))]) rewrote += 1 diff -r 9eba8561870b -r 594ca2f3d1de tests/test-topic.t --- a/tests/test-topic.t Fri Dec 11 13:09:29 2015 -0500 +++ b/tests/test-topic.t Fri Dec 11 13:12:23 2015 -0500 @@ -637,3 +637,6 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: fran? +Readding the same topic with topic --change should work: + $ hg topic --change . watwat + changed topic on 1 changes