##// END OF EJS Templates
revlog: introduce a cache for partial lookups...
Matt Mackall -
r13258:c2661863 default
parent child Browse files
Show More
@@ -221,6 +221,7 b' class revlog(object):'
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:
@@ -703,6 +704,9 b' class revlog(object):'
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)[:...]
@@ -712,6 +716,7 b' class revlog(object):'
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'))
General Comments 0
You need to be logged in to leave comments. Login now