# HG changeset patch # User Matt Mackall # Date 1205275349 18000 # Node ID c0c4c7b1e8d36ee9de59b3c8192be971b5bbdf85 # Parent 4c1aa6affe6099f8dcb912588ef589abe4bfafc3 revlog: report node and file when lookup fails diff -r 4c1aa6affe60 -r c0c4c7b1e8d3 hgext/imerge.py --- a/hgext/imerge.py Tue Mar 11 17:42:26 2008 -0500 +++ b/hgext/imerge.py Tue Mar 11 17:42:29 2008 -0500 @@ -79,7 +79,8 @@ try: parents = [self.repo.changectx(n) for n in status[:2]] except revlog.LookupError, e: - raise util.Abort('merge parent %s not in repository' % e.name) + raise util.Abort(_('merge parent %s not in repository') % + short(e.name)) status = status[2:] conflicts = int(status.pop(0)) * 3 diff -r 4c1aa6affe60 -r c0c4c7b1e8d3 mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py Tue Mar 11 17:42:26 2008 -0500 +++ b/mercurial/bundlerepo.py Tue Mar 11 17:42:29 2008 -0500 @@ -48,7 +48,8 @@ continue for p in (p1, p2): if not p in self.nodemap: - raise revlog.LookupError(hex(p1), _("unknown parent %s") % short(p1)) + raise revlog.LookupError(p1, self.indexfile, + _("unknown parent")) if linkmapper is None: link = n else: diff -r 4c1aa6affe60 -r c0c4c7b1e8d3 mercurial/context.py --- a/mercurial/context.py Tue Mar 11 17:42:26 2008 -0500 +++ b/mercurial/context.py Tue Mar 11 17:42:29 2008 -0500 @@ -100,13 +100,15 @@ try: return self._manifest[path], self._manifest.flags(path) except KeyError: - raise revlog.LookupError(path, _("'%s' not found in manifest") % path) + raise revlog.LookupError(self._node, path, + _('not found in manifest')) if '_manifestdelta' in self.__dict__ or path in self.files(): if path in self._manifestdelta: return self._manifestdelta[path], self._manifestdelta.flags(path) node, flag = self._repo.manifest.find(self._changeset[0], path) if not node: - raise revlog.LookupError(path, _("'%s' not found in manifest") % path) + raise revlog.LookupError(self._node, path, + _('not found in manifest')) return node, flag diff -r 4c1aa6affe60 -r c0c4c7b1e8d3 mercurial/revlog.py --- a/mercurial/revlog.py Tue Mar 11 17:42:26 2008 -0500 +++ b/mercurial/revlog.py Tue Mar 11 17:42:29 2008 -0500 @@ -33,11 +33,11 @@ pass class LookupError(RevlogError): - def __init__(self, name, message=None): - if message is None: - message = _('not found: %s') % name - RevlogError.__init__(self, message) + def __init__(self, name, index, message): self.name = name + if isinstance(name, str) and len(name) == 20: + name = short(name) + RevlogError.__init__(self, _('%s@%s: %s') % (index, name, message)) def getoffset(q): return int(q >> 16) @@ -519,7 +519,7 @@ try: return self.nodemap[node] except KeyError: - raise LookupError(hex(node), _('%s: no node %s') % (self.indexfile, hex(node))) + raise LookupError(node, self.indexfile, _('no node')) def node(self, rev): return self.index[rev][7] def linkrev(self, node): @@ -839,8 +839,8 @@ for n in self.nodemap: if n.startswith(bin_id) and hex(n).startswith(id): if node is not None: - raise LookupError(hex(node), - _("Ambiguous identifier")) + raise LookupError(id, self.indexfile, + _('ambiguous identifier')) node = n if node is not None: return node @@ -859,7 +859,7 @@ if n: return n - raise LookupError(id, _("No match found")) + raise LookupError(id, self.indexfile, _('no match found')) def cmp(self, node, text): """compare text with a given file revision""" @@ -1170,13 +1170,13 @@ for p in (p1, p2): if not p in self.nodemap: - raise LookupError(hex(p), _("unknown parent %s") % short(p)) + raise LookupError(p, self.indexfile, _('unknown parent')) if not chain: # retrieve the parent revision of the delta chain chain = p1 if not chain in self.nodemap: - raise LookupError(hex(chain), _("unknown base %s") % short(chain[:4])) + raise LookupError(chain, self.indexfile, _('unknown base')) # full versions are inserted when the needed deltas become # comparable to the uncompressed text or when the previous diff -r 4c1aa6affe60 -r c0c4c7b1e8d3 tests/test-bundle-r.out --- a/tests/test-bundle-r.out Tue Mar 11 17:42:26 2008 -0500 +++ b/tests/test-bundle-r.out Tue Mar 11 17:42:29 2008 -0500 @@ -168,7 +168,7 @@ adding changesets transaction abort! rollback completed -abort: unknown parent ac69c658229d! +abort: 00changelog.i@ac69c658229d: unknown parent! % 2 2:d62976ca1e50 adding changesets diff -r 4c1aa6affe60 -r c0c4c7b1e8d3 tests/test-diffdir.out --- a/tests/test-diffdir.out Tue Mar 11 17:42:26 2008 -0500 +++ b/tests/test-diffdir.out Tue Mar 11 17:42:29 2008 -0500 @@ -18,5 +18,5 @@ +++ b/b @@ -0,0 +1,1 @@ +123 -abort: Ambiguous identifier! -abort: Ambiguous identifier! +abort: 00changelog.i@: ambiguous identifier! +abort: 00changelog.i@: ambiguous identifier! diff -r 4c1aa6affe60 -r c0c4c7b1e8d3 tests/test-imerge.out --- a/tests/test-imerge.out Tue Mar 11 17:42:26 2008 -0500 +++ b/tests/test-imerge.out Tue Mar 11 17:42:29 2008 -0500 @@ -47,4 +47,4 @@ % nothing to merge abort: there is nothing to merge - use "hg update" instead % load unknown parent -abort: merge parent e6da4671640124fe5d3d70d2f54441d6cd76ae35 not in repository +abort: merge parent e6da46716401 not in repository diff -r 4c1aa6affe60 -r c0c4c7b1e8d3 tests/test-log.out --- a/tests/test-log.out Tue Mar 11 17:42:26 2008 -0500 +++ b/tests/test-log.out Tue Mar 11 17:42:29 2008 -0500 @@ -220,4 +220,4 @@ summary: b1 % log -r "" -abort: Ambiguous identifier! +abort: 00changelog.i@: ambiguous identifier!