Patchwork [3,of,6] revset: store full detail into revsetalias.error for error source distinction

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Jan. 8, 2015, 10:37 a.m.
Message ID <680a889529a06d499935.1420713431@feefifofum>
Download mbox | patch
Permalink /patch/7381/
State Superseded
Commit ddf2172e901d6334fdd03f631146a016b4125def
Headers show

Comments

Katsunori FUJIWARA - Jan. 8, 2015, 10:37 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1420712143 -32400
#      Thu Jan 08 19:15:43 2015 +0900
# Node ID 680a889529a06d4999357c2d2b73e8f9e9735dc7
# Parent  e59d44be965eacc949a9124dfc2ee7bd248c1e9f
revset: store full detail into revsetalias.error for error source distinction

Before this patch, any errors in the declaration of revset alias
aren't detected at all, and there is no information about error source
in the error message.

As a part of preparation for parsing alias declarations and
definitions more strictly, this patch stores full detail into
"revsetalias.error" for error source distinction.

This makes raising "Abort" and warning potential errors just use
"revsetalias.error" without any message composing.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2100,7 +2100,8 @@ 
             # Check for placeholder injection
             _checkaliasarg(self.replacement, self.args)
         except error.ParseError, inst:
-            self.error = parseerrordetail(inst)
+            self.error = _('failed to parse the definition of revset alias'
+                           ' "%s": %s') % (self.name, parseerrordetail(inst))
 
 def _getalias(aliases, tree):
     """If tree looks like an unexpanded alias, return it. Return None
@@ -2143,8 +2144,7 @@ 
     alias = _getalias(aliases, tree)
     if alias is not None:
         if alias.error:
-            raise util.Abort(_('failed to parse revset alias "%s": %s') %
-                             (alias.name, alias.error))
+            raise util.Abort(alias.error)
         if alias in expanding:
             raise error.ParseError(_('infinite expansion of revset alias "%s" '
                                      'detected') % alias.name)
@@ -2177,9 +2177,7 @@ 
         # warn about problematic (but not referred) aliases
         for name, alias in sorted(aliases.iteritems()):
             if alias.error and not alias.warned:
-                msg = _('failed to parse revset alias "%s": %s'
-                        ) % (name, alias.error)
-                showwarning(_('warning: %s\n') % (msg))
+                showwarning(_('warning: %s\n') % (alias.error))
                 alias.warned = True
     return tree
 
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -956,12 +956,12 @@ 
     (range
       ('symbol', '2')
       ('symbol', '5')))
-  abort: failed to parse revset alias "injectparamasstring2": not a function: _aliasarg
+  abort: failed to parse the definition of revset alias "injectparamasstring2": not a function: _aliasarg
   [255]
   $ hg debugrevspec --debug --config revsetalias.anotherbadone='branch(' "tip"
   ('symbol', 'tip')
-  warning: failed to parse revset alias "anotherbadone": at 7: not a prefix: end
-  warning: failed to parse revset alias "injectparamasstring2": not a function: _aliasarg
+  warning: failed to parse the definition of revset alias "anotherbadone": at 7: not a prefix: end
+  warning: failed to parse the definition of revset alias "injectparamasstring2": not a function: _aliasarg
   9
   >>> data = file('.hg/hgrc', 'rb').read()
   >>> file('.hg/hgrc', 'wb').write(data.replace('_aliasarg', ''))