コード例 #1
0
def _resetinfinitepushpath(ui, **opts):
    """
    Sets "default" path to "infinitepush" or "infinitepushbookmark" path and
    deletes "infinitepush"/"infinitepushbookmark" path ("infinitepushbookmark"
    is always preferred if it's set unless a single commit hash is requested).
    In some cases (e.g. when testing new hg backend which doesn't have commit cloud
    commits) we want to do normal `hg pull` from "default" path but `hg pull -r HASH`
    from "infinitepush" path if it's present. This is better than just setting
    another path because of "remotenames" extension. Pulling or pushing to
    another path will add lots of new remote bookmarks and that can be slow
    and slow down smartlog.
    """

    overrides = {}
    defaultpath = pathname.default
    infinitepushpath = pathname.infinitepush
    infinitepushwritepath = pathname.infinitepushwrite
    infinitepushbookmarkpath = pathname.infinitepushbookmark

    pullingsinglecommithash = False
    if opts.get("rev"):
        revs = opts.get("rev")
        if isinstance(revs, list) and len(revs) == 1 and _definitelyhash(
                revs[0]):
            pullingsinglecommithash = True

    if not pullingsinglecommithash and infinitepushbookmarkpath in ui.paths:
        path = infinitepushbookmarkpath
    elif infinitepushpath in ui.paths:
        path = infinitepushpath
    else:
        path = None

    if path is not None:
        overrides[("paths", defaultpath)] = ui.paths[path].loc
        overrides[("paths", infinitepushpath)] = "!"
        overrides[("paths", infinitepushwritepath)] = "!"
        overrides[("paths", infinitepushbookmarkpath)] = "!"
        with ui.configoverride(overrides, "infinitepush"):
            loc, sub = ui.configsuboptions("paths", defaultpath)
            ui.paths[defaultpath] = uimod.path(ui,
                                               defaultpath,
                                               rawloc=loc,
                                               suboptions=sub)
            for p in [
                    infinitepushpath,
                    infinitepushbookmarkpath,
                    infinitepushwritepath,
            ]:
                if p not in ui.paths:
                    continue
                del ui.paths[p]
            yield
    else:
        yield
コード例 #2
0
ファイル: client.py プロジェクト: jsoref/eden
def _resetinfinitepushpath(ui):
    """
    Sets "default" path to "infinitepush" path and deletes "infinitepush" path.
    In some cases (e.g. when testing new hg backend which doesn't have commit cloud
    commits) we want to do normal `hg pull` from "default" path but `hg pull -r HASH`
    from "infinitepush" path if it's present. This is better than just setting
    another path because of "remotenames" extension. Pulling or pushing to
    another path will add lots of new remote bookmarks and that can be slow
    and slow down smartlog.
    """

    overrides = {}
    if "infinitepush" in ui.paths:
        overrides[("paths", "default")] = ui.paths["infinitepush"].loc
        overrides[("paths", "infinitepush")] = "!"
        with ui.configoverride(overrides, "infinitepush"):
            loc, sub = ui.configsuboptions("paths", "default")
            ui.paths["default"] = uimod.path(ui, "default", rawloc=loc, suboptions=sub)
            del ui.paths["infinitepush"]
            yield
    else:
        yield