hgext3rd/topic/__init__.py
changeset 2662 9c0b293c2785
parent 2657 58719183d383
child 2664 ed6fb5f20b24
equal deleted inserted replaced
2661:914757c70217 2662:9c0b293c2785
   286             raise error.Abort('changing topic requires a topic name or --clear')
   286             raise error.Abort('changing topic requires a topic name or --clear')
   287         if any(not c.mutable() for c in repo.set('%r and public()', rev)):
   287         if any(not c.mutable() for c in repo.set('%r and public()', rev)):
   288             raise error.Abort("can't change topic of a public change")
   288             raise error.Abort("can't change topic of a public change")
   289         _changetopics(ui, repo, rev, topic)
   289         _changetopics(ui, repo, rev, topic)
   290     if clear:
   290     if clear:
   291         if repo.vfs.exists('topic'):
   291         return _changecurrenttopic(repo, None)
   292             repo.vfs.unlink('topic')
   292 
   293         return
       
   294     if topic:
   293     if topic:
   295         with repo.wlock():
   294         return _changecurrenttopic(repo, topic)
   296             with repo.vfs.open('topic', 'w') as f:
   295 
   297                 f.write(topic)
       
   298         return
       
   299     _listtopics(ui, repo, opts)
   296     _listtopics(ui, repo, opts)
   300 
   297 
   301 @command('stack [TOPIC]', [] + commands.formatteropts)
   298 @command('stack [TOPIC]', [] + commands.formatteropts)
   302 def cmdstack(ui, repo, topic='', **opts):
   299 def cmdstack(ui, repo, topic='', **opts):
   303     """list all changesets in a topic and other information
   300     """list all changesets in a topic and other information
   306     if not topic:
   303     if not topic:
   307         topic = repo.currenttopic
   304         topic = repo.currenttopic
   308     if not topic:
   305     if not topic:
   309         raise error.Abort(_('no active topic to list'))
   306         raise error.Abort(_('no active topic to list'))
   310     return stack.showstack(ui, repo, topic, opts)
   307     return stack.showstack(ui, repo, topic, opts)
       
   308 
       
   309 def _changecurrenttopic(repo, newtopic):
       
   310     """changes the current topic."""
       
   311 
       
   312     if newtopic:
       
   313         with repo.wlock():
       
   314             with repo.vfs.open('topic', 'w') as f:
       
   315                 f.write(newtopic)
       
   316     else:
       
   317         if repo.vfs.exists('topic'):
       
   318             repo.vfs.unlink('topic')
   311 
   319 
   312 def _changetopics(ui, repo, revset, newtopic):
   320 def _changetopics(ui, repo, revset, newtopic):
   313     rewrote = 0
   321     rewrote = 0
   314     needevolve = False
   322     needevolve = False
   315     wl = l = txn = None
   323     wl = l = txn = None