Merge.
--- 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
--- 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