mercurial/branchmap.py
changeset 42003 7546bf46bfcd
parent 42002 662ffdde5adf
child 42004 0bd730fbcc2b
equal deleted inserted replaced
42002:662ffdde5adf 42003:7546bf46bfcd
   169     def __setitem__(self, key, value):
   169     def __setitem__(self, key, value):
   170         self.entries[key] = value
   170         self.entries[key] = value
   171 
   171 
   172     def __getitem__(self, key):
   172     def __getitem__(self, key):
   173         return self.entries[key]
   173         return self.entries[key]
   174 
       
   175     def setdefault(self, *args):
       
   176         return self.entries.setdefault(*args)
       
   177 
   174 
   178     def iteritems(self):
   175     def iteritems(self):
   179         return self.entries.iteritems()
   176         return self.entries.iteritems()
   180 
   177 
   181     @classmethod
   178     @classmethod
   227             label = encoding.tolocal(label.strip())
   224             label = encoding.tolocal(label.strip())
   228             node = bin(node)
   225             node = bin(node)
   229             if not cl.hasnode(node):
   226             if not cl.hasnode(node):
   230                 raise ValueError(
   227                 raise ValueError(
   231                     r'node %s does not exist' % pycompat.sysstr(hex(node)))
   228                     r'node %s does not exist' % pycompat.sysstr(hex(node)))
   232             self.setdefault(label, []).append(node)
   229             self.entries.setdefault(label, []).append(node)
   233             if state == 'c':
   230             if state == 'c':
   234                 self._closednodes.add(node)
   231                 self._closednodes.add(node)
   235 
   232 
   236     @staticmethod
   233     @staticmethod
   237     def _filename(repo):
   234     def _filename(repo):
   341 
   338 
   342         # if older branchheads are reachable from new ones, they aren't
   339         # if older branchheads are reachable from new ones, they aren't
   343         # really branchheads. Note checking parents is insufficient:
   340         # really branchheads. Note checking parents is insufficient:
   344         # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
   341         # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
   345         for branch, newheadrevs in newbranches.iteritems():
   342         for branch, newheadrevs in newbranches.iteritems():
   346             bheads = self.setdefault(branch, [])
   343             bheads = self.entries.setdefault(branch, [])
   347             bheadset = set(cl.rev(node) for node in bheads)
   344             bheadset = set(cl.rev(node) for node in bheads)
   348 
   345 
   349             # This have been tested True on all internal usage of this function.
   346             # This have been tested True on all internal usage of this function.
   350             # run it again in case of doubt
   347             # run it again in case of doubt
   351             # assert not (set(bheadrevs) & set(newheadrevs))
   348             # assert not (set(bheadrevs) & set(newheadrevs))