261 if topic: |
261 if topic: |
262 with repo.wlock(): |
262 with repo.wlock(): |
263 with repo.vfs.open('topic', 'w') as f: |
263 with repo.vfs.open('topic', 'w') as f: |
264 f.write(topic) |
264 f.write(topic) |
265 return |
265 return |
266 _listtopics(ui, repo) |
266 _listtopics(ui, repo, opts) |
267 |
267 |
268 @command('stack [TOPIC]', [] + commands.formatteropts) |
268 @command('stack [TOPIC]', [] + commands.formatteropts) |
269 def cmdstack(ui, repo, topic='', **opts): |
269 def cmdstack(ui, repo, topic='', **opts): |
270 """list all changesets in a topic |
270 """list all changesets in a topic |
271 |
271 |
272 List the current topic by default.""" |
272 List the current topic by default.""" |
273 return stack.showstack(ui, repo, topic, opts) |
273 return stack.showstack(ui, repo, topic, opts) |
274 |
274 |
275 def _listtopics(ui, repo): |
275 def _listtopics(ui, repo, opts): |
276 current = repo.currenttopic |
276 fm = ui.formatter('bookmarks', opts) |
277 for t in sorted(repo.topics): |
277 activetopic = repo.currenttopic |
278 marker = '*' if t == current else ' ' |
278 for topic in sorted(repo.topics): |
279 ui.write(' %s %s\n' % (marker, t)) |
279 fm.startitem() |
|
280 marker = ' ' |
|
281 label = 'topic' |
|
282 active = (topic == activetopic) |
|
283 if active: |
|
284 marker = '*' |
|
285 label = 'topic.active' |
|
286 if not ui.quiet: |
|
287 # registering the active data is made explicitly later |
|
288 fm.plain(' %s ' % marker, label=label) |
|
289 fm.write('topic', '%s', topic, label=label) |
|
290 fm.data(active=active) |
|
291 fm.plain('\n') |
|
292 fm.end() |
280 |
293 |
281 def summaryhook(ui, repo): |
294 def summaryhook(ui, repo): |
282 t = repo.currenttopic |
295 t = repo.currenttopic |
283 if not t: |
296 if not t: |
284 return |
297 return |