Add revlog.LookupError exception, and use it instead of RevlogError.
Remove repo.LookupError, which devolves to the revlog version.
--- a/mercurial/bundlerepo.py Sun Dec 17 22:16:57 2006 -0600
+++ b/mercurial/bundlerepo.py Mon Dec 18 12:22:43 2006 -0800
@@ -49,7 +49,7 @@
continue
for p in (p1, p2):
if not p in self.nodemap:
- raise revlog.RevlogError(_("unknown parent %s") % short(p1))
+ raise revlog.LookupError(_("unknown parent %s") % short(p1))
if linkmapper is None:
link = n
else:
--- a/mercurial/commands.py Sun Dec 17 22:16:57 2006 -0600
+++ b/mercurial/commands.py Mon Dec 18 12:22:43 2006 -0800
@@ -2450,9 +2450,10 @@
hexfunc = ui.debugflag and hex or short
for t, n in l:
try:
+ hn = hexfunc(n)
r = "%5d:%s" % (repo.changelog.rev(n), hexfunc(n))
- except KeyError:
- r = " ?:?"
+ except revlog.LookupError:
+ r = " ?:%s" % hn
if ui.quiet:
ui.write("%s\n" % t)
else:
--- a/mercurial/context.py Sun Dec 17 22:16:57 2006 -0600
+++ b/mercurial/context.py Mon Dec 18 12:22:43 2006 -0800
@@ -83,13 +83,13 @@
try:
return self._manifest[path]
except KeyError:
- raise repo.LookupError(_("'%s' not found in manifest") % path)
+ raise revlog.LookupError(_("'%s' not found in manifest") % path)
if '_manifestdelta' in self.__dict__ or path in self.files():
if path in self._manifestdelta:
return self._manifestdelta[path]
node, flag = self._repo.manifest.find(self._changeset[0], path)
if not node:
- raise repo.LookupError(_("'%s' not found in manifest") % path)
+ raise revlog.LookupError(_("'%s' not found in manifest") % path)
return node
@@ -149,13 +149,10 @@
self._changeid = self._filelog.linkrev(self._filenode)
return self._changeid
elif name == '_filenode':
- try:
- if '_fileid' in self.__dict__:
- self._filenode = self._filelog.lookup(self._fileid)
- else:
- self._filenode = self._changectx.filenode(self._path)
- except revlog.RevlogError, inst:
- raise repo.LookupError(str(inst))
+ if '_fileid' in self.__dict__:
+ self._filenode = self._filelog.lookup(self._fileid)
+ else:
+ self._filenode = self._changectx.filenode(self._path)
return self._filenode
elif name == '_filerev':
self._filerev = self._filelog.rev(self._filenode)
@@ -167,7 +164,7 @@
try:
n = self._filenode
return True
- except repo.LookupError:
+ except revlog.LookupError:
# file is missing
return False
--- a/mercurial/localrepo.py Sun Dec 17 22:16:57 2006 -0600
+++ b/mercurial/localrepo.py Mon Dec 18 12:22:43 2006 -0800
@@ -317,7 +317,7 @@
rev = c.rev()
try:
fnode = c.filenode('.hgtags')
- except repo.LookupError:
+ except revlog.LookupError:
continue
ret.append((rev, node, fnode))
if fnode in last:
--- a/mercurial/repo.py Sun Dec 17 22:16:57 2006 -0600
+++ b/mercurial/repo.py Mon Dec 18 12:22:43 2006 -0800
@@ -9,9 +9,6 @@
class RepoError(Exception):
pass
-class LookupError(RepoError):
- pass
-
class repository(object):
def capable(self, name):
'''tell whether repo supports named capability.
--- a/mercurial/revlog.py Sun Dec 17 22:16:57 2006 -0600
+++ b/mercurial/revlog.py Mon Dec 18 12:22:43 2006 -0800
@@ -281,6 +281,7 @@
del self.p.map[key]
class RevlogError(Exception): pass
+class LookupError(RevlogError): pass
class revlog(object):
"""
@@ -471,7 +472,7 @@
try:
return self.nodemap[node]
except KeyError:
- raise RevlogError(_('%s: no node %s') % (self.indexfile, hex(node)))
+ raise LookupError(_('%s: no node %s') % (self.indexfile, hex(node)))
def linkrev(self, node):
return (node == nullid) and nullrev or self.index[self.rev(node)][-4]
def parents(self, node):
@@ -766,7 +767,7 @@
node = id
r = self.rev(node) # quick search the index
return node
- except RevlogError:
+ except LookupError:
pass # may be partial hex id
try:
# str(rev)
@@ -795,7 +796,7 @@
for n in self.nodemap:
if n.startswith(bin_id) and hex(n).startswith(id):
if node is not None:
- raise RevlogError(_("Ambiguous identifier"))
+ raise LookupError(_("Ambiguous identifier"))
node = n
if node is not None:
return node
@@ -815,7 +816,7 @@
if n:
return n
- raise RevlogError(_("No match found"))
+ raise LookupError(_("No match found"))
def cmp(self, node, text):
"""compare text with a given file revision"""
@@ -1155,13 +1156,13 @@
for p in (p1, p2):
if not p in self.nodemap:
- raise RevlogError(_("unknown parent %s") % short(p))
+ raise LookupError(_("unknown parent %s") % short(p))
if not chain:
# retrieve the parent revision of the delta chain
chain = p1
if not chain in self.nodemap:
- raise RevlogError(_("unknown base %s") % short(chain[:4]))
+ raise LookupError(_("unknown base %s") % short(chain[:4]))
# full versions are inserted when the needed deltas become
# comparable to the uncompressed text or when the previous