Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 23844:ddf2172e901d
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.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 10 Jan 2015 23:18:11 +0900 |
parents | c4d0c3d05721 |
children | 0a7fd54d4e60 |
comparison
equal
deleted
inserted
replaced
23843:c4d0c3d05721 | 23844:ddf2172e901d |
---|---|
2152 if pos != len(value): | 2152 if pos != len(value): |
2153 raise error.ParseError(_('invalid token'), pos) | 2153 raise error.ParseError(_('invalid token'), pos) |
2154 # Check for placeholder injection | 2154 # Check for placeholder injection |
2155 _checkaliasarg(self.replacement, self.args) | 2155 _checkaliasarg(self.replacement, self.args) |
2156 except error.ParseError, inst: | 2156 except error.ParseError, inst: |
2157 self.error = parseerrordetail(inst) | 2157 self.error = _('failed to parse the definition of revset alias' |
2158 ' "%s": %s') % (self.name, parseerrordetail(inst)) | |
2158 | 2159 |
2159 def _getalias(aliases, tree): | 2160 def _getalias(aliases, tree): |
2160 """If tree looks like an unexpanded alias, return it. Return None | 2161 """If tree looks like an unexpanded alias, return it. Return None |
2161 otherwise. | 2162 otherwise. |
2162 """ | 2163 """ |
2195 # Do not expand raw strings | 2196 # Do not expand raw strings |
2196 return tree | 2197 return tree |
2197 alias = _getalias(aliases, tree) | 2198 alias = _getalias(aliases, tree) |
2198 if alias is not None: | 2199 if alias is not None: |
2199 if alias.error: | 2200 if alias.error: |
2200 raise util.Abort(_('failed to parse revset alias "%s": %s') % | 2201 raise util.Abort(alias.error) |
2201 (alias.name, alias.error)) | |
2202 if alias in expanding: | 2202 if alias in expanding: |
2203 raise error.ParseError(_('infinite expansion of revset alias "%s" ' | 2203 raise error.ParseError(_('infinite expansion of revset alias "%s" ' |
2204 'detected') % alias.name) | 2204 'detected') % alias.name) |
2205 expanding.append(alias) | 2205 expanding.append(alias) |
2206 if alias.name not in cache: | 2206 if alias.name not in cache: |
2229 tree = _expandaliases(aliases, tree, [], {}) | 2229 tree = _expandaliases(aliases, tree, [], {}) |
2230 if showwarning: | 2230 if showwarning: |
2231 # warn about problematic (but not referred) aliases | 2231 # warn about problematic (but not referred) aliases |
2232 for name, alias in sorted(aliases.iteritems()): | 2232 for name, alias in sorted(aliases.iteritems()): |
2233 if alias.error and not alias.warned: | 2233 if alias.error and not alias.warned: |
2234 msg = _('failed to parse revset alias "%s": %s' | 2234 showwarning(_('warning: %s\n') % (alias.error)) |
2235 ) % (name, alias.error) | |
2236 showwarning(_('warning: %s\n') % (msg)) | |
2237 alias.warned = True | 2235 alias.warned = True |
2238 return tree | 2236 return tree |
2239 | 2237 |
2240 def foldconcat(tree): | 2238 def foldconcat(tree): |
2241 """Fold elements to be concatenated by `##` | 2239 """Fold elements to be concatenated by `##` |