tests/remotefilelog-getflogheads.py
author Yuya Nishihara <yuya@tcha.org>
Tue, 08 Jan 2019 22:19:36 +0900
branchstable
changeset 41458 83377b4b4ae0
parent 41253 29996f6c2687
child 43076 2372284d9457
permissions -rw-r--r--
subrepo: reject potentially unsafe subrepo paths (BC) (SEC) In addition to the previous patch, this prohibits '~', '$nonexistent', etc. for any subrepo types. I think this is safer, and real-world subrepos wouldn't use such (local) paths.

from __future__ import absolute_import

from mercurial.i18n import _
from mercurial import (
    hg,
    registrar,
)

cmdtable = {}
command = registrar.command(cmdtable)

@command(b'getflogheads',
         [],
         b'path')
def getflogheads(ui, repo, path):
    """
    Extension printing a remotefilelog's heads

    Used for testing purpose
    """

    dest = repo.ui.expandpath(b'default')
    peer = hg.peer(repo, {}, dest)

    flogheads = peer.x_rfl_getflogheads(path)

    if flogheads:
        for head in flogheads:
            ui.write(head + b'\n')
    else:
        ui.write(_(b'EMPTY\n'))