comparison mercurial/dispatch.py @ 12092:4982fa38e544

alias: print what command is being shadowed in debug message
author Brodie Rao <brodie@bitheap.org>
date Fri, 27 Aug 2010 20:45:11 -0400
parents fddacca3202e
children cd895084a4cd
comparison
equal deleted inserted replaced
12091:339bd18c772f 12092:4982fa38e544
188 return [] 188 return []
189 189
190 class cmdalias(object): 190 class cmdalias(object):
191 def __init__(self, name, definition, cmdtable): 191 def __init__(self, name, definition, cmdtable):
192 self.name = self.cmd = name 192 self.name = self.cmd = name
193 self.cmdname = ''
193 self.definition = definition 194 self.definition = definition
194 self.args = [] 195 self.args = []
195 self.opts = [] 196 self.opts = []
196 self.help = '' 197 self.help = ''
197 self.norepo = True 198 self.norepo = True
232 return util.system(cmd, environ=env) 233 return util.system(cmd, environ=env)
233 self.fn = fn 234 self.fn = fn
234 return 235 return
235 236
236 args = shlex.split(self.definition) 237 args = shlex.split(self.definition)
237 cmd = args.pop(0) 238 self.cmdname = cmd = args.pop(0)
238 args = map(util.expandpath, args) 239 args = map(util.expandpath, args)
239 240
240 for invalidarg in ("--cwd", "-R", "--repository", "--repo"): 241 for invalidarg in ("--cwd", "-R", "--repository", "--repo"):
241 if _earlygetopt([invalidarg], args): 242 if _earlygetopt([invalidarg], args):
242 def fn(ui, *args): 243 def fn(ui, *args):
284 self.fn = fn 285 self.fn = fn
285 self.badalias = True 286 self.badalias = True
286 287
287 def __call__(self, ui, *args, **opts): 288 def __call__(self, ui, *args, **opts):
288 if self.shadows: 289 if self.shadows:
289 ui.debug("alias '%s' shadows command\n" % self.name) 290 ui.debug("alias '%s' shadows command '%s'\n" %
291 (self.name, self.cmdname))
290 292
291 if self.definition.startswith('!'): 293 if self.definition.startswith('!'):
292 return self.fn(ui, *args, **opts) 294 return self.fn(ui, *args, **opts)
293 else: 295 else:
294 return util.checksignature(self.fn)(ui, *args, **opts) 296 return util.checksignature(self.fn)(ui, *args, **opts)