Example #1
0
def extsetup(ui):
    extensions.wrapfunction(graphmod, "dagwalker", _dagwalker)
    extensions.wrapfunction(hg, "updaterepo", _updaterepo)
    extensions.wrapfunction(visibility.visibleheads, "_updateheads",
                            _updateheads)
    extensions.wrapfunction(templatekw, "showgraphnode", _showgraphnode)
    templatekw.keywords["graphnode"] = templatekw.showgraphnode
    extensions.wrapfunction(bundlerepo.bundlerepository, "_handlebundle2part",
                            _handlebundle2part)
    extensions.wrapcommand(commands.table, "update", _update)

    def wrapamend(loaded):
        if not loaded:
            return
        amend = extensions.find("amend")
        extensions.wrapfunction(amend.hide, "_dounhide", _dounhide)

    def wrapsmartlog(loaded):
        if not loaded:
            return
        smartlog = extensions.find("smartlog")
        extensions.wrapfunction(smartlog, "smartlogrevset", _smartlogrevset)
        smartlog.revsetpredicate._table["smartlog"] = smartlog.smartlogrevset

    extensions.afterloaded("amend", wrapamend)
    extensions.afterloaded("smartlog", wrapsmartlog)
Example #2
0
def uisetup(ui):
    def _globalrevswrapper(loaded):
        if loaded:
            globalrevsmod = extensions.find("globalrevs")
            extensions.wrapfunction(globalrevsmod, "_lookupglobalrev",
                                    _scmquerylookupglobalrev)

    if ui.configbool("globalrevs", "scmquerylookup"):
        extensions.afterloaded("globalrevs", _globalrevswrapper)

    revset.symbols["gitnode"] = gitnode
    gitnode._weight = 10
Example #3
0
def extsetup(ui):
    extensions.wrapfunction(localrepo.localrepository, "commitctx", _commitctx)

    def wrapshelve(loaded=False):
        try:
            shelvemod = extensions.find("shelve")
            extensions.wrapcommand(shelvemod.cmdtable, "shelve", _bypassdirsync)
            extensions.wrapcommand(shelvemod.cmdtable, "unshelve", _bypassdirsync)
        except KeyError:
            pass

    extensions.afterloaded("shelve", wrapshelve)
Example #4
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()
Example #5
0
def extsetup(ui):
    background.extsetup(ui)
    dependencies.extsetup(ui)

    localrepo.localrepository._wlockfreeprefix.add(backuplock.progressfilename)
    localrepo.localrepository._wlockfreeprefix.add(backupstate.BackupState.directory)
    localrepo.localrepository._wlockfreeprefix.add(background._autobackupstatefile)
    localrepo.localrepository._lockfreeprefix.add(syncstate.SyncState.prefix)
    localrepo.localrepository._lockfreeprefix.add(sync._syncstatusfile)

    def wrapsmartlog(loaded):
        if not loaded:
            return
        smartlogmod = extensions.find("smartlog")
        extensions.wrapcommand(smartlogmod.cmdtable, "smartlog", _smartlog)

    extensions.afterloaded("smartlog", wrapsmartlog)
Example #6
0
def extsetup(ui):
    # Wrap the APIs used to get the revisions for "hg log" so we
    # can peekahead into the rev list and query phabricator for multiple diffs
    # at once.
    extensions.wrapfunction(cmdutil, "getlogrevs", _getlogrevs)
    extensions.wrapfunction(cmdutil, "getgraphlogrevs", _getlogrevs)

    # Also wrap the APIs used by smartlog
    def _smartlogloaded(loaded):
        smartlog = None
        try:
            smartlog = extensions.find("smartlog")
        except KeyError:
            pass
        if smartlog:
            extensions.wrapfunction(smartlog, "getdag", _getsmartlogdag)

    extensions.afterloaded("smartlog", _smartlogloaded)
Example #7
0
def uisetup(ui):
    extensions.wrapfunction(localrepo, "newreporequirements",
                            _newreporequirementswrapper)

    def _hgsqlwrapper(loaded):
        if loaded:
            hgsqlmod = extensions.find("hgsql")
            extensions.wrapfunction(hgsqlmod, "wraprepo", _sqllocalrepowrapper)

    # We only wrap `hgsql` extension for embedding strictly increasing global
    # revision number in commits if the repository has `hgsql` enabled and it is
    # also configured to write data to the commits. Therefore, do not wrap the
    # extension if that is not the case.
    if not ui.configbool("globalrevs", "readonly") and not ishgsqlbypassed(ui):
        extensions.afterloaded("hgsql", _hgsqlwrapper)

    cls = localrepo.localrepository
    for reqs in ["_basesupported", "supportedformats"]:
        getattr(cls, reqs).add("globalrevs")
Example #8
0
def extsetup(ui):
    wrapblame()

    entry = wrapcommand(commands.table, "commit", commitcmd)
    wrapcommand(rebase.cmdtable, "rebase", _rebase)
    wrapfunction(scmutil, "cleanupnodes", cleanupnodeswrapper)
    entry = wrapcommand(commands.table, "pull", pull)
    options = entry[1]
    options.append(("d", "dest", "", _("destination for rebase or update")))

    # anonymous function to pass ui object to _analyzewrapper
    def _analyzewrap(orig, x):
        return _analyzewrapper(orig, x, ui)

    wrapfunction(revsetlang, "_analyze", _analyzewrap)

    try:
        rebaseext = extensions.find("rebase")
        # tweakdefaults is already loaded before other extensions
        # (see tweakorder() function) so if these functions are wrapped
        # by something else, it's not a problem.
        wrapfunction(rebaseext, "_computeobsoletenotrebased",
                     _computeobsoletenotrebasedwrapper)
        wrapfunction(rebaseext, "_checkobsrebase", _checkobsrebasewrapper)
    except KeyError:
        pass  # no rebase, no problem
    except AssertionError:
        msg = _("tweakdefaults: _computeobsoletenotrebased or " +
                "_checkobsrebase are not what we expect them to be")
        ui.warning(msg)

    try:
        remotenames = extensions.find("remotenames")
        wrapfunction(remotenames, "_getrebasedest", _getrebasedest)
    except KeyError:
        pass  # no remotenames, no worries
    except AttributeError:
        pass  # old version of remotenames doh

    entry = wrapcommand(commands.table, "log", log)
    for opt in logopts:
        opt = (opt[0], opt[1], opt[2], opt[3])
        entry[1].append(opt)

    entry = wrapcommand(commands.table, "status", statuscmd)
    options = entry[1]
    options.append(
        ("", "root-relative", None, _("show status relative to root")))

    wrapcommand(commands.table, "graft", graftcmd)
    try:
        amendmodule = extensions.find("amend")
        wrapcommand(amendmodule.cmdtable, "amend", amendcmd)
    except KeyError:
        pass
    try:
        histeditmodule = extensions.find("histedit")
        wrapfunction(histeditmodule, "commitfuncfor", histeditcommitfuncfor)
    except KeyError:
        pass

    # wrapped createmarkers knows how to write operation-aware
    # metadata (e.g. 'amend', 'rebase' and so forth)
    wrapfunction(obsolete, "createmarkers", _createmarkers)

    # bookmark -D is an alias to strip -B

    # wrap bookmarks after remotenames
    def afterloaded(loaded):
        if loaded:
            # remotenames is loaded, wrap its wrapper directly
            remotenames = extensions.find("remotenames")
            wrapfunction(remotenames, "exbookmarks", unfilteredcmd)
            wrapfunction(remotenames, "expullcmd", pullrebaseffwd)
        else:
            # otherwise wrap the bookmarks command
            wrapcommand(commands.table, "bookmarks", unfilteredcmd)

    extensions.afterloaded("remotenames", afterloaded)

    entry = wrapcommand(commands.table, "diff", diffcmd)
    options = entry[1]
    options.append((
        "",
        "per-file-stat-json",
        None,
        _("show diff stat per file in json (ADVANCED)"),
    ))

    pipei_bufsize = ui.configint("experimental", "winpipebufsize", 4096)
    if pipei_bufsize != 4096 and pycompat.iswindows:
        wrapfunction(util, "popen4", get_winpopen4(pipei_bufsize))

    _fixpager(ui)

    # Change manifest template output
    templatekw.defaulttempl["manifest"] = "{node}"
Example #9
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)
Example #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)