mercurial/revlog.py
changeset 13258 c2661863f16f
parent 13254 5ef5eb1f3515
child 13259 3b616dfa4b17
equal deleted inserted replaced
13257:d1245ce817a8 13258:c2661863f16f
   219         self._cache = None
   219         self._cache = None
   220         self._chunkcache = (0, '')
   220         self._chunkcache = (0, '')
   221         self.index = []
   221         self.index = []
   222         self._shallowroot = shallowroot
   222         self._shallowroot = shallowroot
   223         self._parentdelta = 0
   223         self._parentdelta = 0
       
   224         self._pcache = {}
   224 
   225 
   225         v = REVLOG_DEFAULT_VERSION
   226         v = REVLOG_DEFAULT_VERSION
   226         if hasattr(opener, 'options') and 'defversion' in opener.options:
   227         if hasattr(opener, 'options') and 'defversion' in opener.options:
   227             v = opener.options['defversion']
   228             v = opener.options['defversion']
   228             if v & REVLOGNG:
   229             if v & REVLOGNG:
   701                 return node
   702                 return node
   702             except (TypeError, LookupError):
   703             except (TypeError, LookupError):
   703                 pass
   704                 pass
   704 
   705 
   705     def _partialmatch(self, id):
   706     def _partialmatch(self, id):
       
   707         if id in self._pcache:
       
   708             return self._pcache[id]
       
   709 
   706         if len(id) < 40:
   710         if len(id) < 40:
   707             try:
   711             try:
   708                 # hex(node)[:...]
   712                 # hex(node)[:...]
   709                 l = len(id) // 2  # grab an even number of digits
   713                 l = len(id) // 2  # grab an even number of digits
   710                 bin_id = bin(id[:l * 2])
   714                 bin_id = bin(id[:l * 2])
   711                 nl = [n for n in self.nodemap if n[:l] == bin_id]
   715                 nl = [n for n in self.nodemap if n[:l] == bin_id]
   712                 nl = [n for n in nl if hex(n).startswith(id)]
   716                 nl = [n for n in nl if hex(n).startswith(id)]
   713                 if len(nl) > 0:
   717                 if len(nl) > 0:
   714                     if len(nl) == 1:
   718                     if len(nl) == 1:
       
   719                         self._pcache[id] = nl[0]
   715                         return nl[0]
   720                         return nl[0]
   716                     raise LookupError(id, self.indexfile,
   721                     raise LookupError(id, self.indexfile,
   717                                       _('ambiguous identifier'))
   722                                       _('ambiguous identifier'))
   718                 return None
   723                 return None
   719             except TypeError:
   724             except TypeError: