Exemplo n.º 1
0
def catfile(ui, repo, type=None, r=None, **opts):
    """cat a specific revision"""
    # in stdin mode, every line except the commit is prefixed with two
    # spaces.  This way the our caller can find the commit without magic
    # strings
    #
    prefix = ""
    if opts[r'stdin']:
        line = ui.fin.readline()
        if not line:
            return
        (type, r) = line.rstrip(pycompat.oslinesep).split(b' ')
        prefix = "    "
    else:
        if not type or not r:
            ui.warn(_("cat-file: type or revision not supplied\n"))
            commands.help_(ui, 'cat-file')

    while r:
        if type != "commit":
            ui.warn(_("aborting hg cat-file only understands commits\n"))
            return 1
        n = repo.lookup(r)
        catcommit(ui, repo, n, prefix)
        if opts[r'stdin']:
            line = ui.fin.readline()
            if not line:
                break
            (type, r) = line.rstrip(pycompat.oslinesep).split(b' ')
        else:
            break
Exemplo n.º 2
0
def catfile(ui, repo, type=None, r=None, **opts):
    """cat a specific revision"""
    # in stdin mode, every line except the commit is prefixed with two
    # spaces.  This way the our caller can find the commit without magic
    # strings
    #
    prefix = ""
    if opts['stdin']:
        try:
            (type, r) = raw_input().split(' ')
            prefix = "    "
        except EOFError:
            return

    else:
        if not type or not r:
            ui.warn(_("cat-file: type or revision not supplied\n"))
            commands.help_(ui, 'cat-file')

    while r:
        if type != "commit":
            ui.warn(_("aborting hg cat-file only understands commits\n"))
            return 1
        n = repo.lookup(r)
        catcommit(ui, repo, n, prefix)
        if opts['stdin']:
            try:
                (type, r) = raw_input().split(' ')
            except EOFError:
                break
        else:
            break
Exemplo n.º 3
0
def catfile(ui, repo, type=None, r=None, **opts):
    """cat a specific revision"""
    # in stdin mode, every line except the commit is prefixed with two
    # spaces.  This way the our caller can find the commit without magic
    # strings
    #
    prefix = ""
    if opts['stdin']:
        try:
            (type, r) = raw_input().split(' ')
            prefix = "    "
        except EOFError:
            return

    else:
        if not type or not r:
            ui.warn(_("cat-file: type or revision not supplied\n"))
            commands.help_(ui, 'cat-file')

    while r:
        if type != "commit":
            ui.warn(_("aborting hg cat-file only understands commits\n"))
            return 1
        n = repo.lookup(r)
        catcommit(ui, repo, n, prefix)
        if opts['stdin']:
            try:
                (type, r) = raw_input().split(' ')
            except EOFError:
                break
        else:
            break
Exemplo n.º 4
0
def help(web, req, tmpl):
    from mercurial import commands  # avoid cycle

    topicname = req.form.get('node', [None])[0]
    if not topicname:
        topic = []

        def topics(**map):
            for entries, summary, _ in helpmod.helptable:
                entries = sorted(entries, key=len)
                yield {'topic': entries[-1], 'summary': summary}

        early, other = [], []
        primary = lambda s: s.split('|')[0]
        for c, e in commands.table.iteritems():
            doc = _getdoc(e)
            if 'DEPRECATED' in doc or c.startswith('debug'):
                continue
            cmd = primary(c)
            if cmd.startswith('^'):
                early.append((cmd[1:], doc))
            else:
                other.append((cmd, doc))

        early.sort()
        other.sort()

        def earlycommands(**map):
            for c, doc in early:
                yield {'topic': c, 'summary': doc}

        def othercommands(**map):
            for c, doc in other:
                yield {'topic': c, 'summary': doc}

        return tmpl('helptopics',
                    topics=topics,
                    earlycommands=earlycommands,
                    othercommands=othercommands,
                    title='Index')

    u = webutil.wsgiui()
    u.pushbuffer()
    try:
        commands.help_(u, topicname)
    except error.UnknownCommand:
        raise ErrorResponse(HTTP_NOT_FOUND)
    doc = u.popbuffer()
    return tmpl('help', topic=topicname, doc=doc)
Exemplo n.º 5
0
def help(web, req, tmpl):
    from mercurial import commands  # avoid cycle

    topicname = req.form.get("node", [None])[0]
    if not topicname:

        def topics(**map):
            for entries, summary, _ in helpmod.helptable:
                entries = sorted(entries, key=len)
                yield {"topic": entries[-1], "summary": summary}

        early, other = [], []
        primary = lambda s: s.split("|")[0]
        for c, e in commands.table.iteritems():
            doc = _getdoc(e)
            if "DEPRECATED" in doc or c.startswith("debug"):
                continue
            cmd = primary(c)
            if cmd.startswith("^"):
                early.append((cmd[1:], doc))
            else:
                other.append((cmd, doc))

        early.sort()
        other.sort()

        def earlycommands(**map):
            for c, doc in early:
                yield {"topic": c, "summary": doc}

        def othercommands(**map):
            for c, doc in other:
                yield {"topic": c, "summary": doc}

        return tmpl(
            "helptopics", topics=topics, earlycommands=earlycommands, othercommands=othercommands, title="Index"
        )

    u = webutil.wsgiui()
    u.pushbuffer()
    try:
        commands.help_(u, topicname)
    except error.UnknownCommand:
        raise ErrorResponse(HTTP_NOT_FOUND)
    doc = u.popbuffer()
    return tmpl("help", topic=topicname, doc=doc)
Exemplo n.º 6
0
def main(ui, repo, *pats, **opts):
    """Manage snapshots on FTP server

    Upload snapshots of a revision to one or more FTP server.

    It will upload all files of a revision and set a (local) tag like
    "uploaded@host". If it will find an existing tag for that host it
    will remove vanished files and upload only the difference between
    that revision and the new one.

    Notes:
    If an error happens on server-side on deleting or CHMODing a file
    it will only print a warning about that but it will abort if it can't
    upload a file or create a directory.
    Since Mercurial doesn't track directories it won't delete existing
    directories on server even there is no file anymore.


    Possible settings in hgrc:

    [paths]
    ftp = ftp://[user[:pass]@]host[:port]/[path]
        ('ftp' will be used if DEST is not given)

    [ftp]
    chmod_file  = 644
    chmod_dir   = 755
    global_tags = False
    prefix_tags = uploaded@
    """

    if len(pats) > 1:
        commands.help_(ui, 'ftp')
        return
    elif len(pats) == 1:
        url = pats[0]
    else:
        url = 'ftp'

    obj = manageFTP(ui, repo, opts, url)
    obj.run()
Exemplo n.º 7
0
def main(ui, repo, *pats, **opts):
    """Manage snapshots on FTP server

    Upload snapshots of a revision to one or more FTP server.

    It will upload all files of a revision and set a (local) tag like
    "uploaded@host". If it will find an existing tag for that host it
    will remove vanished files and upload only the difference between
    that revision and the new one.

    Notes:
    If an error happens on server-side on deleting or CHMODing a file
    it will only print a warning about that but it will abort if it can't
    upload a file or create a directory.
    Since Mercurial doesn't track directories it won't delete existing
    directories on server even there is no file anymore.


    Possible settings in hgrc:

    [paths]
    ftp = ftp://[user[:pass]@]host[:port]/[path]
        ('ftp' will be used if DEST is not given)

    [ftp]
    chmod_file  = 644
    chmod_dir   = 755
    global_tags = False
    prefix_tags = uploaded@
    """

    if len(pats) > 1:
        commands.help_(ui, 'ftp')
        return
    elif len(pats) == 1:
        url = pats[0]
    else:
        url = 'ftp'

    obj = manageFTP(ui, repo, opts, url)
    obj.run()
Exemplo n.º 8
0
def help_(ui, args=None, **opts):
    """show help for a given subcommands or a help overview
    """
    if args:
        subcommand = args[0]
        if subcommand not in table:
            candidates = []
            for c in table:
                if c.startswith(subcommand):
                    candidates.append(c)
            if len(candidates) == 1:
                subcommand = candidates[0]
            elif len(candidates) > 1:
                raise error.AmbiguousCommand(subcommand, candidates)
                return
        doc = table[subcommand].__doc__
        if doc is None:
            doc = "No documentation available for %s." % subcommand
        ui.status(doc.strip(), '\n')
        return
    commands.help_(ui, 'svn')
Exemplo n.º 9
0
def help_(ui, args=None, **opts):
    """show help for a given subcommands or a help overview
    """
    if args:
        subcommand = args[0]
        if subcommand not in table:
            candidates = []
            for c in table:
                if c.startswith(subcommand):
                    candidates.append(c)
            if len(candidates) == 1:
                subcommand = candidates[0]
            elif len(candidates) > 1:
                raise error.AmbiguousCommand(subcommand, candidates)
                return
        doc = table[subcommand].__doc__
        if doc is None:
            doc = "No documentation available for %s." % subcommand
        ui.status(doc.strip(), '\n')
        return
    commands.help_(ui, 'svn')
Exemplo n.º 10
0
Arquivo: b.py Projeto: dimo414/b
 def help(self, _opts):
     commands.help_(self.ui, 'b')
Exemplo n.º 11
0
 def _help():
     commands.help_(ui, 'b')
Exemplo n.º 12
0
def thgdispatch(ui, path=None, args=[]):
    '''
    Replicate functionality of mercurial dispatch but force the use
    of the passed in ui for all purposes
    '''
    # read --config before doing anything else
    # (e.g. to change trust settings for reading .hg/hgrc)
    config = _earlygetopt(['--config'], args)
    if config:
        ui.updateopts(config=_parseconfig(config))

    # check for cwd
    cwd = _earlygetopt(['--cwd'], args)
    if cwd:
        os.chdir(cwd[-1])

    # read the local repository .hgrc into a local ui object
    path = rootpath(path) or ""
    if path:
        try:
            ui.readconfig(os.path.join(path, ".hg", "hgrc"))
        except IOError:
            pass

    # now we can expand paths, even ones in .hg/hgrc
    rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
    if rpath:
        path = ui.expandpath(rpath[-1])

    extensions.loadall(ui)
    if not hasattr(extensions, 'extensions'):
        extensions.extensions = lambda: () # pre-0.9.5, loadall did below
    for name, module in extensions.extensions():
        if name in _loaded:
            continue

        # setup extensions
        extsetup = getattr(module, 'extsetup', None)
        if extsetup:
            extsetup()

        cmdtable = getattr(module, 'cmdtable', {})
        overrides = [cmd for cmd in cmdtable if cmd in commands.table]
        if overrides:
            ui.warn(_("extension '%s' overrides commands: %s\n")
                    % (name, " ".join(overrides)))
        commands.table.update(cmdtable)
        _loaded[name] = 1

    # check for fallback encoding
    fallback = ui.config('ui', 'fallbackencoding')
    if fallback:
        util._fallbackencoding = fallback

    fullargs = args
    cmd, func, args, options, cmdoptions = parse(ui, args)

    if options["encoding"]:
        util._encoding = options["encoding"]
    if options["encodingmode"]:
        util._encodingmode = options["encodingmode"]
    ui.updateopts(options["verbose"], options["debug"], options["quiet"],
                 not options["noninteractive"], options["traceback"])

    if options['help']:
        return commands.help_(ui, cmd, options['version'])
    elif options['version']:
        return commands.version_(ui)
    elif not cmd:
        return commands.help_(ui, 'shortlist')

    repo = None
    if cmd not in commands.norepo.split():
        try:
            repo = hg.repository(ui, path=path)
            repo.ui = ui
            ui.setconfig("bundle", "mainreporoot", repo.root)
            if not repo.local():
                raise util.Abort(_("repository '%s' is not local") % path)
        except RepoError:
            if cmd not in commands.optionalrepo.split():
                if not path:
                    raise RepoError(_("There is no Mercurial repository here"
                                         " (.hg not found)"))
                raise
        d = lambda: func(ui, repo, *args, **cmdoptions)
    else:
        d = lambda: func(ui, *args, **cmdoptions)

    # run pre-hook, and abort if it fails
    ret = hook.hook(ui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs))
    if ret:
        return ret

    # Run actual command
    try:
        ret = d()
    except TypeError, inst:
        # was this an argument error?
        tb = traceback.extract_tb(sys.exc_info()[2])
        if len(tb) != 2: # no
            raise
        raise ParseError(cmd, _("invalid arguments"))
Exemplo n.º 13
0
 def _help():
     commands.help_(ui,'b')