Show More
@@ -243,6 +243,7 b' class cmdalias(object):' | |||
|
243 | 243 | self.opts = [] |
|
244 | 244 | self.help = '' |
|
245 | 245 | self.norepo = True |
|
246 | self.optionalrepo = False | |
|
246 | 247 | self.badalias = False |
|
247 | 248 | |
|
248 | 249 | try: |
@@ -312,6 +313,8 b' class cmdalias(object):' | |||
|
312 | 313 | self.args = aliasargs(self.fn, args) |
|
313 | 314 | if cmd not in commands.norepo.split(' '): |
|
314 | 315 | self.norepo = False |
|
316 | if cmd in commands.optionalrepo.split(' '): | |
|
317 | self.optionalrepo = True | |
|
315 | 318 | if self.help.startswith("hg " + cmd): |
|
316 | 319 | # drop prefix in old-style help lines so hg shows the alias |
|
317 | 320 | self.help = self.help[4 + len(cmd):] |
@@ -370,6 +373,8 b' def addaliases(ui, cmdtable):' | |||
|
370 | 373 | cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help) |
|
371 | 374 | if aliasdef.norepo: |
|
372 | 375 | commands.norepo += ' %s' % alias |
|
376 | if aliasdef.optionalrepo: | |
|
377 | commands.optionalrepo += ' %s' % alias | |
|
373 | 378 | |
|
374 | 379 | def _parse(ui, args): |
|
375 | 380 | options = {} |
@@ -495,7 +500,6 b' def _getlocal(ui, rpath):' | |||
|
495 | 500 | return path, lui |
|
496 | 501 | |
|
497 | 502 | def _checkshellalias(lui, ui, args): |
|
498 | norepo = commands.norepo | |
|
499 | 503 | options = {} |
|
500 | 504 | |
|
501 | 505 | try: |
@@ -506,6 +510,12 b' def _checkshellalias(lui, ui, args):' | |||
|
506 | 510 | if not args: |
|
507 | 511 | return |
|
508 | 512 | |
|
513 | norepo = commands.norepo | |
|
514 | optionalrepo = commands.optionalrepo | |
|
515 | def restorecommands(): | |
|
516 | commands.norepo = norepo | |
|
517 | commands.optionalrepo = optionalrepo | |
|
518 | ||
|
509 | 519 | cmdtable = commands.table.copy() |
|
510 | 520 | addaliases(lui, cmdtable) |
|
511 | 521 | |
@@ -514,7 +524,7 b' def _checkshellalias(lui, ui, args):' | |||
|
514 | 524 | aliases, entry = cmdutil.findcmd(cmd, cmdtable, |
|
515 | 525 | lui.configbool("ui", "strict")) |
|
516 | 526 | except (error.AmbiguousCommand, error.UnknownCommand): |
|
517 | commands.norepo = norepo | |
|
527 | restorecommands() | |
|
518 | 528 | return |
|
519 | 529 | |
|
520 | 530 | cmd = aliases[0] |
@@ -524,7 +534,7 b' def _checkshellalias(lui, ui, args):' | |||
|
524 | 534 | d = lambda: fn(ui, *args[1:]) |
|
525 | 535 | return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {}) |
|
526 | 536 | |
|
527 | commands.norepo = norepo | |
|
537 | restorecommands() | |
|
528 | 538 | |
|
529 | 539 | _loaded = set() |
|
530 | 540 | def _dispatch(req): |
@@ -9,6 +9,7 b'' | |||
|
9 | 9 | > # should clobber ci but not commit (issue2993) |
|
10 | 10 | > ci = version |
|
11 | 11 | > myinit = init |
|
12 | > optionalrepo = showconfig alias.myinit | |
|
12 | 13 | > cleanstatus = status -c |
|
13 | 14 | > unknown = bargle |
|
14 | 15 | > ambiguous = s |
@@ -108,8 +109,17 b' invalid options' | |||
|
108 | 109 | $ hg help no--repository |
|
109 | 110 | error in definition for alias 'no--repository': --repository may only be given on the command line |
|
110 | 111 | |
|
112 | optional repository | |
|
113 | ||
|
114 | $ hg optionalrepo | |
|
115 | init | |
|
111 | 116 | $ cd alias |
|
112 | ||
|
117 | $ cat > .hg/hgrc <<EOF | |
|
118 | > [alias] | |
|
119 | > myinit = init -q | |
|
120 | > EOF | |
|
121 | $ hg optionalrepo | |
|
122 | init -q | |
|
113 | 123 | |
|
114 | 124 | no usage |
|
115 | 125 |
General Comments 0
You need to be logged in to leave comments.
Login now