129 ui.write(_("topic: %s\n") % t) |
129 ui.write(_("topic: %s\n") % t) |
130 |
130 |
131 def updatewrap(orig, ui, repo, *args, **kwargs): |
131 def updatewrap(orig, ui, repo, *args, **kwargs): |
132 ret = orig(ui, repo, *args, **kwargs) |
132 ret = orig(ui, repo, *args, **kwargs) |
133 pctx = repo['.'] |
133 pctx = repo['.'] |
|
134 ot = repo.currenttopic |
134 if pctx.phase() == phases.public and repo.vfs.exists('topic'): |
135 if pctx.phase() == phases.public and repo.vfs.exists('topic'): |
135 repo.vfs.unlink('topic') |
136 repo.vfs.unlink('topic') |
136 else: |
137 else: |
137 # inherit the topic of the parent revision |
138 # inherit the topic of the parent revision |
138 t = pctx.extra().get(constants.extrakey, '') |
139 t = pctx.extra().get(constants.extrakey, '') |
139 if t and pctx.phase() > phases.public: |
140 if t and pctx.phase() > phases.public: |
140 with repo.vfs.open('topic', 'w') as f: |
141 with repo.vfs.open('topic', 'w') as f: |
141 f.write(t) |
142 f.write(t) |
|
143 if t != ot: |
|
144 ui.status(_("switching to topic %s\n") % t) |
142 return ret |
145 return ret |
143 |
146 |
144 extensions.wrapcommand(commands.table, 'update', updatewrap) |
147 extensions.wrapcommand(commands.table, 'update', updatewrap) |
145 topicrevset.modsetup() |
148 topicrevset.modsetup() |
146 cmdutil.summaryhooks.add('topic', summaryhook) |
149 cmdutil.summaryhooks.add('topic', summaryhook) |