hgext3rd/serverminitopic.py
branchstable
changeset 5353 f32d4c7f8fb7
parent 5193 a4d081923c81
equal deleted inserted replaced
5298:a828c7a7ace1 5353:f32d4c7f8fb7
    21     node,
    21     node,
    22     registrar,
    22     registrar,
    23     util,
    23     util,
    24 )
    24 )
    25 
    25 
    26 # hg <= 4.5 (b4d85bc122bd)
    26 from mercurial import wireprotov1server
    27 try:
       
    28     from mercurial import wireproto  # pytype: disable=import-error
       
    29     wireproto.branchmap
       
    30 except ImportError:
       
    31     from mercurial import wireprotov1server as wireproto
       
    32 
    27 
    33 if util.safehasattr(registrar, 'configitem'):
    28 if util.safehasattr(registrar, 'configitem'):
    34 
    29 
    35     configtable = {}
    30     configtable = {}
    36     configitem = registrar.configitem(configtable)
    31     configitem = registrar.configitem(configtable)
   161     def copy(self):
   156     def copy(self):
   162         """return an deep copy of the branchcache object"""
   157         """return an deep copy of the branchcache object"""
   163         if util.safehasattr(self, '_entries'):
   158         if util.safehasattr(self, '_entries'):
   164             _entries = self._entries
   159             _entries = self._entries
   165         else:
   160         else:
   166             # hg <= 4.9 (624d6683c705, b137a6793c51)
   161             # hg <= 4.9 (624d6683c705+b137a6793c51)
   167             _entries = self
   162             _entries = self
   168         new = self.__class__(_entries, self.tipnode, self.tiprev,
   163         new = self.__class__(_entries, self.tipnode, self.tiprev,
   169                              self.filteredhash, self._closednodes)
   164                              self.filteredhash, self._closednodes)
   170         new.phaseshash = self.phaseshash
   165         new.phaseshash = self.phaseshash
   171         return new
   166         return new
   235     assert issubclass(current, new), (current, new, targetclass)
   230     assert issubclass(current, new), (current, new, targetclass)
   236 
   231 
   237 def uisetup(ui):
   232 def uisetup(ui):
   238     wrapclass(branchmap, 'branchcache', _topiccache)
   233     wrapclass(branchmap, 'branchcache', _topiccache)
   239     try:
   234     try:
   240         # Mercurial 4.8 and older
   235         # hg <= 4.9 (3461814417f3)
   241         extensions.wrapfunction(branchmap, 'read', wrapread)
   236         extensions.wrapfunction(branchmap, 'read', wrapread)
   242     except AttributeError:
   237     except AttributeError:
   243         # Mercurial 4.9; branchcache.fromfile now takes care of this
   238         # Mercurial 5.0; branchcache.fromfile now takes care of this
   244         # which is alredy defined on _topiccache
   239         # which is alredy defined on _topiccache
   245         pass
   240         pass
   246     extensions.wrapfunction(wireproto, '_capabilities', wireprotocaps)
   241     extensions.wrapfunction(wireprotov1server, '_capabilities', wireprotocaps)
   247     extensions.wrapfunction(context.changectx, 'branch', topicbranch)
   242     extensions.wrapfunction(context.changectx, 'branch', topicbranch)