##// END OF EJS Templates
help: don't display bogus help messages for invalid aliases
Brodie Rao -
r10021:0022f5c5 default
parent child Browse files
Show More
@@ -1486,6 +1486,11 def help_(ui, name=None, with_version=Fa
1486 1486 helplist(_('list of commands:\n\n'), select)
1487 1487 return
1488 1488
1489 # check if it's an invalid alias and display its error if it is
1490 if getattr(entry[0], 'badalias', False):
1491 entry[0](ui)
1492 return
1493
1489 1494 # synopsis
1490 1495 if len(entry) > 2:
1491 1496 if entry[2].startswith('hg'):
@@ -177,6 +177,7 class cmdalias(object):
177 177 self.opts = []
178 178 self.help = ''
179 179 self.norepo = True
180 self.badalias = False
180 181
181 182 try:
182 183 cmdutil.findcmd(self.name, cmdtable, True)
@@ -189,6 +190,7 class cmdalias(object):
189 190 ui.warn(_("no definition for alias '%s'\n") % self.name)
190 191 return 1
191 192 self.fn = fn
193 self.badalias = True
192 194
193 195 return
194 196
@@ -217,12 +219,14 class cmdalias(object):
217 219 % (self.name, cmd))
218 220 return 1
219 221 self.fn = fn
222 self.badalias = True
220 223 except error.AmbiguousCommand:
221 224 def fn(ui, *args):
222 225 ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \
223 226 % (self.name, cmd))
224 227 return 1
225 228 self.fn = fn
229 self.badalias = True
226 230
227 231 def __call__(self, ui, *args, **opts):
228 232 if self.shadows:
@@ -25,15 +25,19 hg myinit alias
25 25
26 26 echo '% unknown'
27 27 hg unknown
28 hg help unknown
28 29
29 30 echo '% ambiguous'
30 31 hg ambiguous
32 hg help ambiguous
31 33
32 34 echo '% recursive'
33 35 hg recursive
36 hg help recursive
34 37
35 38 echo '% no definition'
36 39 hg nodef
40 hg help nodef
37 41
38 42 cd alias
39 43
@@ -1,12 +1,16
1 1 % basic
2 2 % unknown
3 3 alias 'unknown' resolves to unknown command 'bargle'
4 alias 'unknown' resolves to unknown command 'bargle'
4 5 % ambiguous
5 6 alias 'ambiguous' resolves to ambiguous command 's'
7 alias 'ambiguous' resolves to ambiguous command 's'
6 8 % recursive
7 9 alias 'recursive' resolves to unknown command 'recursive'
10 alias 'recursive' resolves to unknown command 'recursive'
8 11 % no definition
9 12 no definition for alias 'nodefinition'
13 no definition for alias 'nodefinition'
10 14 % no usage
11 15 no rollback information available
12 16 adding foo
General Comments 0
You need to be logged in to leave comments. Login now