changeset 18855:50c922c1b514 stable 2.5.3

hgweb: show correct error message for i18n environment If exception is error.LookupError and running in i18n environment, below condition is always true. Because msg is translated and dosen't contain 'manifest'. if util.safehasattr(err, 'name') and 'manifest' not in msg: This patch creates a new exception class and uses it instead of string match.
author Takumi IINO <trot.thunder@gmail.com>
date Fri, 15 Feb 2013 18:07:14 +0900
parents afab180307be
children c9d1241ba11d
files mercurial/context.py mercurial/error.py mercurial/hgweb/hgweb_mod.py
diffstat 3 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Mon Apr 01 18:48:12 2013 -0300
+++ b/mercurial/context.py	Fri Feb 15 18:07:14 2013 +0900
@@ -291,16 +291,16 @@
             try:
                 return self._manifest[path], self._manifest.flags(path)
             except KeyError:
-                raise error.LookupError(self._node, path,
-                                        _('not found in manifest'))
+                raise error.ManifestLookupError(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 error.LookupError(self._node, path,
-                                    _('not found in manifest'))
+            raise error.ManifestLookupError(self._node, path,
+                                            _('not found in manifest'))
 
         return node, flag
 
--- a/mercurial/error.py	Mon Apr 01 18:48:12 2013 -0300
+++ b/mercurial/error.py	Fri Feb 15 18:07:14 2013 +0900
@@ -27,6 +27,9 @@
     def __str__(self):
         return RevlogError.__str__(self)
 
+class ManifestLookupError(LookupError):
+    pass
+
 class CommandError(Exception):
     """Exception raised on errors in parsing the command line."""
 
--- a/mercurial/hgweb/hgweb_mod.py	Mon Apr 01 18:48:12 2013 -0300
+++ b/mercurial/hgweb/hgweb_mod.py	Fri Feb 15 18:07:14 2013 +0900
@@ -245,7 +245,8 @@
         except (error.LookupError, error.RepoLookupError), err:
             req.respond(HTTP_NOT_FOUND, ctype)
             msg = str(err)
-            if util.safehasattr(err, 'name') and 'manifest' not in msg:
+            if (util.safehasattr(err, 'name') and
+                not isinstance(err,  error.ManifestLookupError)):
                 msg = 'revision not found: %s' % err.name
             return tmpl('error', error=msg)
         except (error.RepoError, error.RevlogError), inst: