Show More
@@ -3560,12 +3560,11 def extsetup(ui): | |||||
3560 | entry = extensions.wrapcommand(commands.table, 'init', mqinit) |
|
3560 | entry = extensions.wrapcommand(commands.table, 'init', mqinit) | |
3561 | entry[1].extend(mqopt) |
|
3561 | entry[1].extend(mqopt) | |
3562 |
|
3562 | |||
3563 | nowrap = set(commands.norepo.split(" ")) |
|
|||
3564 |
|
||||
3565 | def dotable(cmdtable): |
|
3563 | def dotable(cmdtable): | |
3566 |
for cmd in cmdtable. |
|
3564 | for cmd, entry in cmdtable.iteritems(): | |
3567 | cmd = cmdutil.parsealiases(cmd)[0] |
|
3565 | cmd = cmdutil.parsealiases(cmd)[0] | |
3568 |
|
|
3566 | func = entry[0] | |
|
3567 | if func.norepo: | |||
3569 | continue |
|
3568 | continue | |
3570 | entry = extensions.wrapcommand(cmdtable, cmd, mqcommand) |
|
3569 | entry = extensions.wrapcommand(cmdtable, cmd, mqcommand) | |
3571 | entry[1].extend(mqopt) |
|
3570 | entry[1].extend(mqopt) |
@@ -3270,24 +3270,13 def command(table): | |||||
3270 | def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False, |
|
3270 | def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False, | |
3271 | inferrepo=False): |
|
3271 | inferrepo=False): | |
3272 | def decorator(func): |
|
3272 | def decorator(func): | |
|
3273 | func.norepo = norepo | |||
|
3274 | func.optionalrepo = optionalrepo | |||
|
3275 | func.inferrepo = inferrepo | |||
3273 | if synopsis: |
|
3276 | if synopsis: | |
3274 | table[name] = func, list(options), synopsis |
|
3277 | table[name] = func, list(options), synopsis | |
3275 | else: |
|
3278 | else: | |
3276 | table[name] = func, list(options) |
|
3279 | table[name] = func, list(options) | |
3277 |
|
||||
3278 | if norepo: |
|
|||
3279 | # Avoid import cycle. |
|
|||
3280 | import commands |
|
|||
3281 | commands.norepo += ' %s' % ' '.join(parsealiases(name)) |
|
|||
3282 |
|
||||
3283 | if optionalrepo: |
|
|||
3284 | import commands |
|
|||
3285 | commands.optionalrepo += ' %s' % ' '.join(parsealiases(name)) |
|
|||
3286 |
|
||||
3287 | if inferrepo: |
|
|||
3288 | import commands |
|
|||
3289 | commands.inferrepo += ' %s' % ' '.join(parsealiases(name)) |
|
|||
3290 |
|
||||
3291 | return func |
|
3280 | return func | |
3292 | return decorator |
|
3281 | return decorator | |
3293 |
|
3282 |
@@ -29,18 +29,6 table = {} | |||||
29 |
|
29 | |||
30 | command = cmdutil.command(table) |
|
30 | command = cmdutil.command(table) | |
31 |
|
31 | |||
32 | # Space delimited list of commands that don't require local repositories. |
|
|||
33 | # This should be populated by passing norepo=True into the @command decorator. |
|
|||
34 | norepo = '' |
|
|||
35 | # Space delimited list of commands that optionally require local repositories. |
|
|||
36 | # This should be populated by passing optionalrepo=True into the @command |
|
|||
37 | # decorator. |
|
|||
38 | optionalrepo = '' |
|
|||
39 | # Space delimited list of commands that will examine arguments looking for |
|
|||
40 | # a repository. This should be populated by passing inferrepo=True into the |
|
|||
41 | # @command decorator. |
|
|||
42 | inferrepo = '' |
|
|||
43 |
|
||||
44 | # label constants |
|
32 | # label constants | |
45 | # until 3.5, bookmarks.current was the advertised name, not |
|
33 | # until 3.5, bookmarks.current was the advertised name, not | |
46 | # bookmarks.active, so we must use both to avoid breaking old |
|
34 | # bookmarks.active, so we must use both to avoid breaking old |
@@ -496,11 +496,11 class cmdalias(object): | |||||
496 | self.fn, self.opts = tableentry |
|
496 | self.fn, self.opts = tableentry | |
497 |
|
497 | |||
498 | self.args = aliasargs(self.fn, args) |
|
498 | self.args = aliasargs(self.fn, args) | |
499 |
if |
|
499 | if not self.fn.norepo: | |
500 | self.norepo = False |
|
500 | self.norepo = False | |
501 |
if |
|
501 | if self.fn.optionalrepo: | |
502 | self.optionalrepo = True |
|
502 | self.optionalrepo = True | |
503 |
if |
|
503 | if self.fn.inferrepo: | |
504 | self.inferrepo = True |
|
504 | self.inferrepo = True | |
505 | if self.help.startswith("hg " + cmd): |
|
505 | if self.help.startswith("hg " + cmd): | |
506 | # drop prefix in old-style help lines so hg shows the alias |
|
506 | # drop prefix in old-style help lines so hg shows the alias | |
@@ -556,12 +556,6 def addaliases(ui, cmdtable): | |||||
556 | pass |
|
556 | pass | |
557 |
|
557 | |||
558 | cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help) |
|
558 | cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help) | |
559 | if aliasdef.norepo: |
|
|||
560 | commands.norepo += ' %s' % alias |
|
|||
561 | if aliasdef.optionalrepo: |
|
|||
562 | commands.optionalrepo += ' %s' % alias |
|
|||
563 | if aliasdef.inferrepo: |
|
|||
564 | commands.inferrepo += ' %s' % alias |
|
|||
565 |
|
559 | |||
566 | def _parse(ui, args): |
|
560 | def _parse(ui, args): | |
567 | options = {} |
|
561 | options = {} | |
@@ -728,26 +722,16 def _checkshellalias(lui, ui, args, prec | |||||
728 |
|
722 | |||
729 | if precheck: |
|
723 | if precheck: | |
730 | strict = True |
|
724 | strict = True | |
731 | norepo = commands.norepo |
|
|||
732 | optionalrepo = commands.optionalrepo |
|
|||
733 | inferrepo = commands.inferrepo |
|
|||
734 | def restorecommands(): |
|
|||
735 | commands.norepo = norepo |
|
|||
736 | commands.optionalrepo = optionalrepo |
|
|||
737 | commands.inferrepo = inferrepo |
|
|||
738 | cmdtable = commands.table.copy() |
|
725 | cmdtable = commands.table.copy() | |
739 | addaliases(lui, cmdtable) |
|
726 | addaliases(lui, cmdtable) | |
740 | else: |
|
727 | else: | |
741 | strict = False |
|
728 | strict = False | |
742 | def restorecommands(): |
|
|||
743 | pass |
|
|||
744 | cmdtable = commands.table |
|
729 | cmdtable = commands.table | |
745 |
|
730 | |||
746 | cmd = args[0] |
|
731 | cmd = args[0] | |
747 | try: |
|
732 | try: | |
748 | aliases, entry = cmdutil.findcmd(cmd, cmdtable, strict) |
|
733 | aliases, entry = cmdutil.findcmd(cmd, cmdtable, strict) | |
749 | except (error.AmbiguousCommand, error.UnknownCommand): |
|
734 | except (error.AmbiguousCommand, error.UnknownCommand): | |
750 | restorecommands() |
|
|||
751 | return |
|
735 | return | |
752 |
|
736 | |||
753 | cmd = aliases[0] |
|
737 | cmd = aliases[0] | |
@@ -758,8 +742,6 def _checkshellalias(lui, ui, args, prec | |||||
758 | return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, |
|
742 | return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, | |
759 | [], {}) |
|
743 | [], {}) | |
760 |
|
744 | |||
761 | restorecommands() |
|
|||
762 |
|
||||
763 | _loaded = set() |
|
745 | _loaded = set() | |
764 | def _dispatch(req): |
|
746 | def _dispatch(req): | |
765 | args = req.args |
|
747 | args = req.args | |
@@ -876,7 +858,7 def _dispatch(req): | |||||
876 |
|
858 | |||
877 | repo = None |
|
859 | repo = None | |
878 | cmdpats = args[:] |
|
860 | cmdpats = args[:] | |
879 |
if |
|
861 | if not func.norepo: | |
880 | # use the repo from the request only if we don't have -R |
|
862 | # use the repo from the request only if we don't have -R | |
881 | if not rpath and not cwd: |
|
863 | if not rpath and not cwd: | |
882 | repo = req.repo |
|
864 | repo = req.repo | |
@@ -897,9 +879,9 def _dispatch(req): | |||||
897 | except error.RepoError: |
|
879 | except error.RepoError: | |
898 | if rpath and rpath[-1]: # invalid -R path |
|
880 | if rpath and rpath[-1]: # invalid -R path | |
899 | raise |
|
881 | raise | |
900 |
if |
|
882 | if not func.optionalrepo: | |
901 |
if |
|
883 | if func.inferrepo and args and not path: | |
902 |
|
|
884 | # try to infer -R from command args | |
903 | repos = map(cmdutil.findrepo, args) |
|
885 | repos = map(cmdutil.findrepo, args) | |
904 | guess = repos[0] |
|
886 | guess = repos[0] | |
905 | if guess and repos.count(guess) == len(repos): |
|
887 | if guess and repos.count(guess) == len(repos): |
General Comments 0
You need to be logged in to leave comments.
Login now