hgext3rd/topic/__init__.py
changeset 2988 62201935e1a7
parent 2987 d59d6413bb68
child 2990 c2102598adf5
equal deleted inserted replaced
2987:d59d6413bb68 2988:62201935e1a7
   316             ctr = self.currenttransaction()
   316             ctr = self.currenttransaction()
   317             tr = super(topicrepo, self).transaction(*a, **k)
   317             tr = super(topicrepo, self).transaction(*a, **k)
   318             if ctr is not None:
   318             if ctr is not None:
   319                 return tr
   319                 return tr
   320 
   320 
       
   321             # real transaction start
       
   322             ct = self.currenttopic
       
   323             if not ct:
       
   324                 return tr
       
   325             ctwasempty = stack.stackdata(self, topic=ct)['changesetcount'] == 0
       
   326 
   321             reporef = weakref.ref(self)
   327             reporef = weakref.ref(self)
   322 
   328 
   323             def currenttopicempty(tr):
   329             def currenttopicempty(tr):
   324                 # check active topic emptyness
   330                 # check active topic emptyness
   325                 ct = self.currenttopic
       
   326                 if not ct:
       
   327                     return
       
   328                 repo = reporef()
   331                 repo = reporef()
   329                 empty = stack.stackdata(repo, topic=ct)['changesetcount'] == 0
   332                 csetcount = stack.stackdata(repo, topic=ct)['changesetcount']
   330                 if empty:
   333                 empty = csetcount == 0
       
   334                 if empty and not ctwasempty:
   331                     ui.status('active topic %r is now empty\n' % ct)
   335                     ui.status('active topic %r is now empty\n' % ct)
       
   336                 if ctwasempty and not empty:
       
   337                     if csetcount == 1:
       
   338                         msg = _('active topic %r grew its first changeset\n')
       
   339                         ui.status(msg % ct)
       
   340                     else:
       
   341                         msg = _('active topic %r grew its %s first changesets\n')
       
   342                         ui.status(msg % (ct, csetcount))
   332 
   343 
   333             tr.addpostclose('signalcurrenttopicempty', currenttopicempty)
   344             tr.addpostclose('signalcurrenttopicempty', currenttopicempty)
   334             return tr
   345             return tr
   335 
   346 
   336     repo.__class__ = topicrepo
   347     repo.__class__ = topicrepo