hgext3rd/topic/__init__.py
changeset 2985 f63c97c01f92
parent 2984 30f6030dca8f
child 2986 4746b92cc1f8
equal deleted inserted replaced
2984:30f6030dca8f 2985:f63c97c01f92
   435         finally:
   435         finally:
   436             lockmod.release(txn, l, wl)
   436             lockmod.release(txn, l, wl)
   437             repo.invalidate()
   437             repo.invalidate()
   438         return
   438         return
   439 
   439 
       
   440     ct = repo.currenttopic
   440     if clear:
   441     if clear:
   441         ct = repo.currenttopic
       
   442         empty = stack.stackdata(repo, topic=ct)['changesetcount'] == 0
   442         empty = stack.stackdata(repo, topic=ct)['changesetcount'] == 0
   443         if empty:
   443         if empty:
   444             if ct:
   444             if ct:
   445                 ui.status(_('clearing empty topic "%s"\n') % ct)
   445                 ui.status(_('clearing empty topic "%s"\n') % ct)
   446         return _changecurrenttopic(repo, None)
   446         return _changecurrenttopic(repo, None)
   447 
   447 
   448     if topic:
   448     if topic:
       
   449         if not ct:
       
   450             ui.status(_('marked working directory as topic: %s\n') % topic)
   449         return _changecurrenttopic(repo, topic)
   451         return _changecurrenttopic(repo, topic)
   450 
   452 
   451     # `hg topic --current`
   453     # `hg topic --current`
   452     ret = 0
   454     ret = 0
   453     if current and not repo.currenttopic:
   455     if current and not ct:
   454         ui.write_err(_('no active topic\n'))
   456         ui.write_err(_('no active topic\n'))
   455         ret = 1
   457         ret = 1
   456     elif current:
   458     elif current:
   457         fm = ui.formatter('topic', opts)
   459         fm = ui.formatter('topic', opts)
   458         namemask = '%s\n'
   460         namemask = '%s\n'
   459         label = 'topic.active'
   461         label = 'topic.active'
   460         fm.startitem()
   462         fm.startitem()
   461         fm.write('topic', namemask, repo.currenttopic, label=label)
   463         fm.write('topic', namemask, ct, label=label)
   462         fm.end()
   464         fm.end()
   463     else:
   465     else:
   464         _listtopics(ui, repo, opts)
   466         _listtopics(ui, repo, opts)
   465     return ret
   467     return ret
   466 
   468