mercurial/dispatch.py
changeset 28622 527cf881d000
parent 28621 d856e85a8a7a
child 28623 38dc3f28f478
equal deleted inserted replaced
28621:d856e85a8a7a 28622:527cf881d000
   744     if cmd and util.safehasattr(fn, 'shell'):
   744     if cmd and util.safehasattr(fn, 'shell'):
   745         d = lambda: fn(ui, *args[1:])
   745         d = lambda: fn(ui, *args[1:])
   746         return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
   746         return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
   747                                   [], {})
   747                                   [], {})
   748 
   748 
       
   749 def _cmdattr(ui, cmd, func, attr):
       
   750     return getattr(func, attr)
       
   751 
   749 _loaded = set()
   752 _loaded = set()
   750 
   753 
   751 # list of (objname, loadermod, loadername) tuple:
   754 # list of (objname, loadermod, loadername) tuple:
   752 # - objname is the name of an object in extension module, from which
   755 # - objname is the name of an object in extension module, from which
   753 #   extra information is loaded
   756 #   extra information is loaded
   872     elif not cmd:
   875     elif not cmd:
   873         return commands.help_(ui, 'shortlist')
   876         return commands.help_(ui, 'shortlist')
   874 
   877 
   875     repo = None
   878     repo = None
   876     cmdpats = args[:]
   879     cmdpats = args[:]
   877     if not func.norepo:
   880     if not _cmdattr(ui, cmd, func, 'norepo'):
   878         # use the repo from the request only if we don't have -R
   881         # use the repo from the request only if we don't have -R
   879         if not rpath and not cwd:
   882         if not rpath and not cwd:
   880             repo = req.repo
   883             repo = req.repo
   881 
   884 
   882         if repo:
   885         if repo:
   893             except error.RequirementError:
   896             except error.RequirementError:
   894                 raise
   897                 raise
   895             except error.RepoError:
   898             except error.RepoError:
   896                 if rpath and rpath[-1]: # invalid -R path
   899                 if rpath and rpath[-1]: # invalid -R path
   897                     raise
   900                     raise
   898                 if not func.optionalrepo:
   901                 if not _cmdattr(ui, cmd, func, 'optionalrepo'):
   899                     if func.inferrepo and args and not path:
   902                     if (_cmdattr(ui, cmd, func, 'inferrepo') and
       
   903                         args and not path):
   900                         # try to infer -R from command args
   904                         # try to infer -R from command args
   901                         repos = map(cmdutil.findrepo, args)
   905                         repos = map(cmdutil.findrepo, args)
   902                         guess = repos[0]
   906                         guess = repos[0]
   903                         if guess and repos.count(guess) == len(repos):
   907                         if guess and repos.count(guess) == len(repos):
   904                             req.args = ['--repository', guess] + fullargs
   908                             req.args = ['--repository', guess] + fullargs