def clone(source=None, dest=None, noupdate=False, updaterev=None, rev=None, branch=None, pull=False, uncompressed=False, ssh=None, remotecmd=None, insecure=False, encoding=None, configs=None): args = util.cmdbuilder('clone', source, dest, noupdate=noupdate, updaterev=updaterev, rev=rev, branch=branch, pull=pull, uncompresses=uncompressed, e=ssh, remotecmd=remotecmd, insecure=insecure) args.insert(0, HGPATH) proc = util.popen(args) out, err = proc.communicate() if proc.returncode: raise error.CommandError(args, proc.returncode, out, err) return client.hgclient(dest, encoding, configs, connect=False)
def openrevlog(repo, cmd, file_, opts): """opens the changelog, manifest, a filelog or a given revlog""" cl = opts['changelog'] mf = opts['manifest'] msg = None if cl and mf: msg = _('cannot specify --changelog and --manifest at the same time') elif cl or mf: if file_: msg = _('cannot specify filename with --changelog or --manifest') elif not repo: msg = _('cannot specify --changelog or --manifest ' 'without a repository') if msg: raise util.Abort(msg) r = None if repo: if cl: r = repo.changelog elif mf: r = repo.manifest elif file_: filelog = repo.file(file_) if len(filelog): r = filelog if not r: if not file_: raise error.CommandError(cmd, _('invalid arguments')) if not os.path.isfile(file_): raise util.Abort(_("revlog '%s' not found") % file_) r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_[:-2] + ".i") return r
def _parse(ui, args): options = {} cmdoptions = {} try: args = fancyopts.fancyopts(args, commands.globalopts, options) except fancyopts.getopt.GetoptError, inst: raise error.CommandError(None, inst)
def init(dest=None, ssh=None, remotecmd=None, insecure=False, encoding=None, configs=None): args = util.cmdbuilder('init', dest, e=ssh, remotecmd=remotecmd, insecure=insecure) args.insert(0, HGPATH) proc = util.popen(args) out, err = proc.communicate() if proc.returncode: raise error.CommandError(args, proc.returncode, out, err) return client.hgclient(dest, encoding, configs, connect=False)
def _parse(ui, args): options = {} cmdoptions = {} try: args = fancyopts.fancyopts(args, commands.globalopts, options) except fancyopts.getopt.GetoptError as inst: raise error.CommandError(None, inst) if args: cmd, args = args[0], args[1:] aliases, entry = cmdutil.findcmd(cmd, commands.table, ui.configbool("ui", "strict")) cmd = aliases[0] args = aliasargs(entry[0], args) defaults = ui.config("defaults", cmd) if defaults: args = map(util.expandpath, shlex.split(defaults)) + args c = list(entry[1]) else: cmd = None c = [] # combine global options into local for o in commands.globalopts: c.append((o[0], o[1], options[o[1]], o[3])) try: args = fancyopts.fancyopts(args, c, cmdoptions, True) except fancyopts.getopt.GetoptError as inst: raise error.CommandError(cmd, inst) # separate global options back out for o in commands.globalopts: n = o[1] options[n] = cmdoptions[n] del cmdoptions[n] return (cmd, cmd and entry[0] or None, args, options, cmdoptions)
def checkargs(): try: return cmdfunc() except error.SignatureError: raise error.CommandError(cmd, _("invalid arguments"))
defaults = ui.config("defaults", cmd) if defaults: args = map(util.expandpath, shlex.split(defaults)) + args c = list(entry[1]) else: cmd = None c = [] # combine global options into local for o in commands.globalopts: c.append((o[0], o[1], options[o[1]], o[3])) try: args = fancyopts.fancyopts(args, c, cmdoptions, True) except fancyopts.getopt.GetoptError, inst: raise error.CommandError(cmd, inst) # separate global options back out for o in commands.globalopts: n = o[1] options[n] = cmdoptions[n] del cmdoptions[n] return (cmd, cmd and entry[0] or None, args, options, cmdoptions) def _parseconfig(ui, config): """parse the --config options from the command line""" configs = [] for cfg in config:
def __call__(self, ret, out, err): self.ret = ret if ret not in self.allowed: raise error.CommandError(self.args, ret, out, err) return out