Mercurial > hg
changeset 2777:81d7db1aa0fb
revlog.lookup optimization
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 03 Aug 2006 21:24:19 -0500 |
parents | 557ea210fd9f |
children | fdc232d8a193 |
files | mercurial/revlog.py |
diffstat | 1 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Thu Aug 03 20:06:05 2006 -0500 +++ b/mercurial/revlog.py Thu Aug 03 21:24:19 2006 -0500 @@ -744,8 +744,6 @@ def lookup(self, id): """locate a node based on revision number or subset of hex nodeid""" - if id in self.nodemap: - return id if type(id) == type(0): return self.node(id) try: @@ -760,10 +758,13 @@ if hex(n).startswith(id): c.append(n) if len(c) > 1: raise RevlogError(_("Ambiguous identifier")) - if len(c) < 1: raise RevlogError(_("No match found")) - return c[0] + if len(c) == 1: return c[0] - return None + # might need fixing if we change hash lengths + if len(id) == 20 and id in self.nodemap: + return id + + raise RevlogError(_("No match found")) def diff(self, a, b): """return a delta between two revisions"""