310 @command('topics', [ |
310 @command('topics', [ |
311 ('', 'clear', False, 'clear active topic if any'), |
311 ('', 'clear', False, 'clear active topic if any'), |
312 ('r', 'rev', '', 'revset of existing revisions', _('REV')), |
312 ('r', 'rev', '', 'revset of existing revisions', _('REV')), |
313 ('l', 'list', False, 'show the stack of changeset in the topic'), |
313 ('l', 'list', False, 'show the stack of changeset in the topic'), |
314 ('', 'age', False, 'show when you last touched the topics'), |
314 ('', 'age', False, 'show when you last touched the topics'), |
|
315 ('', 'current', None, 'display the current topic only'), |
315 ] + commands.formatteropts, |
316 ] + commands.formatteropts, |
316 _('hg topics [TOPIC]')) |
317 _('hg topics [TOPIC]')) |
317 def topics(ui, repo, topic='', clear=False, rev=None, list=False, **opts): |
318 def topics(ui, repo, topic='', clear=False, rev=None, list=False, **opts): |
318 """View current topic, set current topic, change topic for a set of revisions, or see all topics. |
319 """View current topic, set current topic, change topic for a set of revisions, or see all topics. |
319 |
320 |
336 `hg topic --age` |
337 `hg topic --age` |
337 |
338 |
338 The active topic (if any) will be prepended with a "*". |
339 The active topic (if any) will be prepended with a "*". |
339 |
340 |
340 The --verbose version of this command display various information on the state of each topic.""" |
341 The --verbose version of this command display various information on the state of each topic.""" |
|
342 |
|
343 current = opts.get('current') |
|
344 if current and topic: |
|
345 raise error.Abort(_("cannot use --current when setting a topic")) |
|
346 if current and clear: |
|
347 raise error.Abort(_("cannot use --current and --clear")) |
|
348 |
341 if list: |
349 if list: |
342 if clear or rev: |
350 if clear or rev: |
343 raise error.Abort(_("cannot use --clear or --rev with --list")) |
351 raise error.Abort(_("cannot use --clear or --rev with --list")) |
344 if not topic: |
352 if not topic: |
345 topic = repo.currenttopic |
353 topic = repo.currenttopic |
373 return _changecurrenttopic(repo, None) |
381 return _changecurrenttopic(repo, None) |
374 |
382 |
375 if topic: |
383 if topic: |
376 return _changecurrenttopic(repo, topic) |
384 return _changecurrenttopic(repo, topic) |
377 |
385 |
378 _listtopics(ui, repo, opts) |
386 # `hg topic --current` |
|
387 ret = 0 |
|
388 if current and not repo.currenttopic: |
|
389 ui.write_err(_('no active topic\n')) |
|
390 ret = 1 |
|
391 elif current: |
|
392 fm = ui.formatter('topic', opts) |
|
393 namemask = '%s\n' |
|
394 label = 'topic.active' |
|
395 fm.startitem() |
|
396 fm.write('topic', namemask, repo.currenttopic, label=label) |
|
397 fm.end() |
|
398 else: |
|
399 _listtopics(ui, repo, opts) |
|
400 return ret |
379 |
401 |
380 @command('stack', [ |
402 @command('stack', [ |
381 ] + commands.formatteropts, |
403 ] + commands.formatteropts, |
382 _('hg stack [TOPIC]')) |
404 _('hg stack [TOPIC]')) |
383 def cmdstack(ui, repo, topic='', **opts): |
405 def cmdstack(ui, repo, topic='', **opts): |