Пример #1
0
def extsetup(ui):
    entry = extensions.wrapcommand(commands.table, "push", _push)
    # Don't add the 'to' arg if it already exists
    if not any(a for a in entry[1] if a[1] == "to"):
        entry[1].append(("", "to", "", _("push revs to this bookmark")))

    if not any(a for a in entry[1] if a[1] == "non-forward-move"):
        entry[1].append((
            "",
            "non-forward-move",
            None,
            _("allows moving a remote bookmark to an "
              "arbitrary place"),
        ))

    if not any(a for a in entry[1] if a[1] == "create"):
        entry[1].append(
            ("", "create", None, _("create a new remote bookmark")))

    entry[1].append(("", "bundle-store", None,
                     _("force push to go to bundle store (EXPERIMENTAL)")))

    bookcmd = extensions.wrapcommand(commands.table, "bookmarks", _bookmarks)
    bookcmd[1].append((
        "",
        "list-remote",
        None,
        "list remote bookmarks. "
        "Positional arguments are interpreted as wildcard patterns. "
        "Only allowed wildcard is '*' in the end of the pattern. "
        "If no positional arguments are specified then it will list "
        'the most "important" remote bookmarks. '
        "Otherwise it will list remote bookmarks "
        "that match at least one pattern "
        "",
    ))
    bookcmd[1].append(("", "remote-path", "",
                       "name of the remote path to list the bookmarks"))

    extensions.wrapcommand(commands.table, "pull", _pull)
    extensions.wrapcommand(commands.table, "update", _update)

    extensions.wrapfunction(bundle2, "_addpartsfromopts", _addpartsfromopts)

    wireproto.wirepeer.listkeyspatterns = listkeyspatterns
    wireproto.wirepeer.knownnodes = knownnodes

    # Move infinitepush part before pushrebase part
    # to avoid generation of both parts.
    partorder = exchange.b2partsgenorder
    index = partorder.index("changeset")
    if constants.pushrebaseparttype in partorder:
        index = min(index, partorder.index(constants.pushrebaseparttype))
    partorder.insert(
        index, partorder.pop(partorder.index(constants.scratchbranchparttype)))
Пример #2
0
def extsetup(ui):
    entry = extensions.wrapcommand(commands.table, "diff", _diff)
    options = entry[1]
    options.append(
        ("", "since-last-arc-diff", None, _("Deprecated alias for --since-last-submit"))
    )
    options.append(
        ("", "since-last-submit", None, _("show changes since last Phabricator submit"))
    )
    options.append(
        (
            "",
            "since-last-submit-2o",
            None,
            _("show diff of current diff and last Phabricator submit"),
        )
    )
Пример #3
0
def _wrapamend(flag):
    """add flag to amend, which will be a shortcut to the absorb command"""
    if not flag:
        return
    amendcmd = extensions.bind(_amendcmd, flag)
    # the amend command can exist in amend, or evolve
    for extname in ["amend", "evolve", None]:
        try:
            if extname is None:
                cmdtable = commands.table
            else:
                ext = extensions.find(extname)
                cmdtable = ext.cmdtable
        except (KeyError, AttributeError):
            continue
        try:
            entry = extensions.wrapcommand(cmdtable, "amend", amendcmd)
            options = entry[1]
            msg = _("incorporate corrections into stack. "
                    "see 'hg help absorb' for details")
            options.append(("", flag, None, msg))
            return
        except error.UnknownCommand:
            pass
Пример #4
0
def wrapdefault():
    """wrap the default annotate command, to be aware of the protocol"""
    extensions.wrapcommand(commands.table, "annotate", _annotatewrapper)
Пример #5
0
 def wrapsmartlog(loaded):
     if not loaded:
         return
     smartlogmod = extensions.find("smartlog")
     extensions.wrapcommand(smartlogmod.cmdtable, "smartlog", _smartlog)
Пример #6
0
def uisetup(ui):
    """Wraps user facing Mercurial commands to swap them out with shallow
    versions.
    """
    hg.wirepeersetupfuncs.append(fileserverclient.peersetup)

    entry = extensions.wrapcommand(commands.table, "clone", cloneshallow)
    entry[1].append((
        "",
        "shallow",
        None,
        _("create a shallow clone which uses remote file "
          "history"),
    ))

    extensions.wrapcommand(commands.table, "debugindex",
                           debugcommands.debugindex)
    extensions.wrapcommand(commands.table, "debugindexdot",
                           debugcommands.debugindexdot)
    extensions.wrapcommand(commands.table, "log", log)
    extensions.wrapcommand(commands.table, "pull", pull)
    extensions.wrapfunction(bundle2, "getrepocaps", getrepocaps)

    # Prevent 'hg manifest --all'
    def _manifest(orig, ui, repo, *args, **opts):
        if shallowrepo.requirement in repo.requirements and opts.get("all"):
            raise error.Abort(_("--all is not supported in a shallow repo"))

        return orig(ui, repo, *args, **opts)

    extensions.wrapcommand(commands.table, "manifest", _manifest)

    # Wrap remotefilelog with lfs code
    def _lfsloaded(loaded=False):
        lfsmod = None
        try:
            lfsmod = extensions.find("lfs")
        except KeyError:
            pass
        if lfsmod:
            lfsmod.wrapfilelog(remotefilelog.remotefilelog)
            fileserverclient._lfsmod = lfsmod

    extensions.afterloaded("lfs", _lfsloaded)

    # debugdata needs remotefilelog.len to work
    extensions.wrapcommand(commands.table, "debugdata", debugdatashallow)

    wrappackers()
Пример #7
0
def uisetup(ui):
    entry = extensions.wrapcommand(commands.table, "commit", commit)
    for opt in amendopts:
        opt = (opt[0], opt[1], opt[2], "(with --amend) " + opt[3])
        entry[1].append(opt)

    # manual call of the decorator
    command(
        "amend|am|ame|amen",
        [
            (
                "A",
                "addremove",
                None,
                _("mark new/missing files as added/removed before committing"),
            ),
            ("e", "edit", None, _("prompt to edit the commit message")),
            ("i", "interactive", None, _("use interactive mode")),
        ] + amendopts + commands.walkopts + commands.commitopts +
        commands.commitopts2,
        _("hg amend [OPTION]..."),
    )(amend)

    def has_automv(loaded):
        if not loaded:
            return
        automv = extensions.find("automv")
        entry = extensions.wrapcommand(cmdtable, "amend", automv.mvcheck)
        entry[1].append(("", "no-move-detection", None,
                         _("disable automatic file move detection")))

    extensions.afterloaded("automv", has_automv)

    def evolveloaded(loaded):
        if not loaded:
            return

        evolvemod = extensions.find("evolve")

        # Remove conflicted commands from evolve.
        table = evolvemod.cmdtable
        for name in ["prev", "next", "split", "fold", "metaedit", "prune"]:
            todelete = [k for k in table if name in k]
            for k in todelete:
                oldentry = table[k]
                table["debugevolve%s" % name] = oldentry
                del table[k]

    extensions.afterloaded("evolve", evolveloaded)

    def rebaseloaded(loaded):
        if not loaded:
            return
        entry = extensions.wrapcommand(rebasemod.cmdtable, "rebase",
                                       wraprebase)
        entry[1].append((
            "",
            "restack",
            False,
            _("rebase all changesets in the current "
              "stack onto the latest version of their "
              "respective parents"),
        ))

    extensions.afterloaded("rebase", rebaseloaded)
Пример #8
0
def extsetup(ui):
    entry = extensions.wrapcommand(commands.table, "commit", mvcheck)
    entry[1].append(("", "no-automv", None, _("disable automatic file move detection")))
    entry[1].append(
        ("", "no-move-detection", None, _("disable automatic file move detection"))
    )
Пример #9
0
def extsetup(ui):
    entry = extensions.wrapcommand(commands.table, "commit", _commit)
    options = entry[1]
    options.append(
        ("", "extra", [], _("set a changeset's extra values"), _("KEY=VALUE")))
Пример #10
0
def extsetup(ui):
    extensions.wrapfunction(bookmarks, "calculateupdate", exbookcalcupdate)
    extensions.wrapfunction(exchange.pushoperation, "__init__", expushop)
    extensions.wrapfunction(exchange, "push", expush)
    extensions.wrapfunction(exchange, "pull", expull)
    extensions.wrapfunction(bookmarks, "updatefromremote", exupdatefromremote)
    extensions.wrapfunction(bookmarks, "reachablerevs", exreachablerevs)
    if util.safehasattr(bookmarks, "activate"):
        extensions.wrapfunction(bookmarks, "activate", exactivate)
    else:
        extensions.wrapfunction(bookmarks, "setcurrent", exactivate)
    extensions.wrapfunction(hg, "clonepreclose", exclone)
    extensions.wrapfunction(hg, "updaterepo", exupdate)
    extensions.wrapfunction(localrepo.localrepository, "commit", excommit)

    extensions.wrapfunction(converthg.mercurial_source, "getbookmarks",
                            exconvertbookmarks)

    if util.safehasattr(discovery, "_nowarnheads"):
        extensions.wrapfunction(discovery, "_nowarnheads", exnowarnheads)

    if _tracking(ui):
        try:
            rebase = extensions.find("rebase")
            extensions.wrapcommand(rebase.cmdtable, "rebase", exrebasecmd)
        except KeyError:
            # rebase isn't on, that's fine
            pass

    entry = extensions.wrapcommand(commands.table, "log", exlog)
    entry[1].append(("", "remote", None, "show remote names even if hidden"))

    entry = extensions.wrapcommand(commands.table, "paths", expaths)
    entry[1].append(("d", "delete", "", "delete remote path", "NAME"))
    entry[1].append(("a", "add", "", "add remote path", "NAME PATH"))

    extensions.wrapcommand(commands.table, "pull", expullcmd)

    entry = extensions.wrapcommand(commands.table, "clone", exclonecmd)
    entry[1].append(("", "mirror", None, "sync all bookmarks"))

    entry = extensions.wrapcommand(commands.table, "update", updatecmd)
    entry[1].append(("B", "bookmark", "", "create new bookmark"))

    exchange.pushdiscoverymapping["bookmarks"] = expushdiscoverybookmarks

    try:
        strip = extensions.find("strip")
        if strip:
            extensions.wrapcommand(strip.cmdtable, "strip", exstrip)
    except KeyError:
        # strip isn't on
        pass

    try:
        histedit = extensions.find("histedit")
        if histedit:
            extensions.wrapcommand(histedit.cmdtable, "histedit", exhistedit)
    except KeyError:
        # histedit isn't on
        pass

    def hasjournal(loaded):
        if not loaded:
            return
        # register our namespace as 'shared' when bookmarks are shared
        journal = extensions.find("journal")
        journal.sharednamespaces[
            journalremotebookmarktype] = hg.sharedbookmarks

    extensions.afterloaded("journal", hasjournal)

    bookcmd = extensions.wrapcommand(commands.table, "bookmarks", exbookmarks)
    pushcmd = extensions.wrapcommand(commands.table, "push", expushcmd)

    localrepo.localrepository._wlockfreeprefix.add("selectivepullenabled")

    if _tracking(ui):
        bookcmd[1].append(("t", "track", "",
                           "track this bookmark or remote name", "BOOKMARK"))
        bookcmd[1].append(("u", "untrack", None,
                           "remove tracking for this bookmark", "BOOKMARK"))

    newopts = [
        (bookcmd, ("a", "all", None, "show both remote and local bookmarks")),
        (bookcmd, ("", "remote", None,
                   _("show only remote bookmarks (DEPRECATED)"))),
        (
            bookcmd,
            (
                "",
                "list-subscriptions",
                None,
                "show only remote bookmarks that are available locally",
                "BOOKMARK",
            ),
        ),
        (pushcmd, ("t", "to", "", "push revs to this bookmark", "BOOKMARK")),
        (pushcmd, ("d", "delete", "", "delete remote bookmark", "BOOKMARK")),
        (pushcmd, ("", "create", None, "create a new remote bookmark")),
        (pushcmd, ("", "allow-anon", None, "allow a new unbookmarked head")),
        (
            pushcmd,
            (
                "",
                "non-forward-move",
                None,
                "allows moving a remote bookmark to an arbitrary place",
            ),
        ),
    ]

    def afterload(loaded):
        if loaded:
            raise ValueError("nonexistant extension should not be loaded")

        for cmd, newopt in newopts:
            # avoid adding duplicate optionms
            skip = False
            for opt in cmd[1]:
                if opt[1] == newopt[1]:
                    skip = True
            if not skip:
                cmd[1].append(newopt)

    extensions.afterloaded("nonexistant", afterload)
Пример #11
0
def extsetup(ui):
    extensions.wrapfunction(merge, "driverpreprocess", wrappreprocess)
    extensions.wrapfunction(merge, "driverconclude", wrapconclude)
    wrappropertycache(merge.mergestate, "mergedriver", wrapmdprop)
    entry = extensions.wrapcommand(commands.table, "resolve", wrapresolve)
    entry[1].append(("", "skip", None, _("skip merge driver")))
Пример #12
0
def extsetup(ui):
    extensions.wrapcommand(commands.table, "resolve", _resolve)