Mercurial > public > mercurial-scm > hg
comparison mercurial/dispatch.py @ 10021:0022f5c5459e
help: don't display bogus help messages for invalid aliases
author | Brodie Rao <me+hg@dackz.net> |
---|---|
date | Sat, 05 Dec 2009 23:26:27 -0500 |
parents | 931d2c757627 |
children | d6512b3e9ac0 |
comparison
equal
deleted
inserted
replaced
10020:d7c23f4a14c7 | 10021:0022f5c5459e |
---|---|
175 self.definition = definition | 175 self.definition = definition |
176 self.args = [] | 176 self.args = [] |
177 self.opts = [] | 177 self.opts = [] |
178 self.help = '' | 178 self.help = '' |
179 self.norepo = True | 179 self.norepo = True |
180 self.badalias = False | |
180 | 181 |
181 try: | 182 try: |
182 cmdutil.findcmd(self.name, cmdtable, True) | 183 cmdutil.findcmd(self.name, cmdtable, True) |
183 self.shadows = True | 184 self.shadows = True |
184 except error.UnknownCommand: | 185 except error.UnknownCommand: |
187 if not self.definition: | 188 if not self.definition: |
188 def fn(ui, *args): | 189 def fn(ui, *args): |
189 ui.warn(_("no definition for alias '%s'\n") % self.name) | 190 ui.warn(_("no definition for alias '%s'\n") % self.name) |
190 return 1 | 191 return 1 |
191 self.fn = fn | 192 self.fn = fn |
193 self.badalias = True | |
192 | 194 |
193 return | 195 return |
194 | 196 |
195 args = shlex.split(self.definition) | 197 args = shlex.split(self.definition) |
196 cmd = args.pop(0) | 198 cmd = args.pop(0) |
215 def fn(ui, *args): | 217 def fn(ui, *args): |
216 ui.warn(_("alias '%s' resolves to unknown command '%s'\n") \ | 218 ui.warn(_("alias '%s' resolves to unknown command '%s'\n") \ |
217 % (self.name, cmd)) | 219 % (self.name, cmd)) |
218 return 1 | 220 return 1 |
219 self.fn = fn | 221 self.fn = fn |
222 self.badalias = True | |
220 except error.AmbiguousCommand: | 223 except error.AmbiguousCommand: |
221 def fn(ui, *args): | 224 def fn(ui, *args): |
222 ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \ | 225 ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \ |
223 % (self.name, cmd)) | 226 % (self.name, cmd)) |
224 return 1 | 227 return 1 |
225 self.fn = fn | 228 self.fn = fn |
229 self.badalias = True | |
226 | 230 |
227 def __call__(self, ui, *args, **opts): | 231 def __call__(self, ui, *args, **opts): |
228 if self.shadows: | 232 if self.shadows: |
229 ui.debug("alias '%s' shadows command\n" % self.name) | 233 ui.debug("alias '%s' shadows command\n" % self.name) |
230 | 234 |