Ejemplo n.º 1
0
def extsetup(ui):
    wrapfilelog(ui, filelog.filelog)

    wrapfunction = extensions.wrapfunction

    try:
        # Older Mercurial does not have wrapconvertsink. These methods are
        # "convert"-related and missing them is not fatal.  Ignore them so
        # bootstrapping from an old Mercurial works.
        wrapfunction(scmutil, "wrapconvertsink", wrapper.convertsink)
    except AttributeError:
        pass

    wrapfunction(changegroup, "supportedoutgoingversions",
                 wrapper.supportedoutgoingversions)
    wrapfunction(changegroup, "allsupportedversions",
                 wrapper.allsupportedversions)

    context.basefilectx.islfs = wrapper.filectxislfs

    if ui.configbool("experimental", "lfsplaceholders"):
        wrapfunction(context.basefilectx, "cmp", placeholders.filectxcmp)
        wrapfunction(context.basefilectx, "isbinary",
                     placeholders.filectxisbinary)
        revlog.addflagprocessor(
            revlog.REVIDX_EXTSTORED,
            (
                placeholders.readfromstore,
                placeholders.writetostore,
                wrapper.bypasscheckhash,
            ),
        )
    else:
        wrapfunction(context.basefilectx, "cmp", wrapper.filectxcmp)
        wrapfunction(context.basefilectx, "isbinary", wrapper.filectxisbinary)
        revlog.addflagprocessor(
            revlog.REVIDX_EXTSTORED,
            (wrapper.readfromstore, wrapper.writetostore,
             wrapper.bypasscheckhash),
        )

    wrapfunction(hg, "clonepreclose", wrapper.hgclone)
    wrapfunction(hg, "postshare", wrapper.hgpostshare)

    # Make bundle choose changegroup3 instead of changegroup2. This affects
    # "hg bundle" command. Note: it does not cover all bundle formats like
    # "packed1". Using "packed1" with lfs will likely cause trouble.
    names = [k for k, v in exchange._bundlespeccgversions.items() if v == "02"]
    for k in names:
        exchange._bundlespeccgversions[k] = "03"

    # bundlerepo uses "vfsmod.readonlyvfs(othervfs)", we need to make sure lfs
    # options and blob stores are passed from othervfs to the new readonlyvfs.
    wrapfunction(vfsmod.readonlyvfs, "__init__", wrapper.vfsinit)

    # when writing a bundle via "hg bundle" command, upload related LFS blobs
    wrapfunction(bundle2, "writenewbundle", wrapper.writenewbundle)

    # verify LFS objects were uploaded when receiving pushes
    wrapfunction(changegroup, "checkrevs", wrapper.checkrevs)
Ejemplo n.º 2
0
def extsetup(ui):
    # Enable changegroup3 for flags to be sent over the wire
    wrapfunction = extensions.wrapfunction
    wrapfunction(changegroup, "supportedoutgoingversions",
                 supportedoutgoingversions)
    wrapfunction(changegroup, "allsupportedversions", allsupportedversions)

    # Teach revlog about our test flags
    flags = [REVIDX_NOOP, REVIDX_BASE64, REVIDX_GZIP, REVIDX_FAIL]
    revlog.REVIDX_KNOWN_FLAGS |= util.bitsfrom(flags)
    revlog.REVIDX_FLAGS_ORDER.extend(flags)

    # Teach exchange to use changegroup 3
    for k in exchange._bundlespeccgversions.keys():
        exchange._bundlespeccgversions[k] = "03"

    # Add wrappers for addrevision, responsible to set flags depending on the
    # revision data contents.
    wrapfunction(filelog.filelog, "addrevision", noopaddrevision)
    wrapfunction(filelog.filelog, "addrevision", b64addrevision)
    wrapfunction(filelog.filelog, "addrevision", gzipaddrevision)
    wrapfunction(filelog.filelog, "addrevision", failaddrevision)

    # Register flag processors for each extension
    revlog.addflagprocessor(REVIDX_NOOP,
                            (noopdonothing, noopdonothing, validatehash))
    revlog.addflagprocessor(REVIDX_BASE64, (b64decode, b64encode, bypass))
    revlog.addflagprocessor(REVIDX_GZIP,
                            (gzipdecompress, gzipcompress, bypass))
Ejemplo n.º 3
0

def writeprocessor(self, text):
    # False: the returned rawtext shouldn't be used to verify hash
    rawtext = _extheader + text.replace(b"1", b"i")
    return rawtext, False


def rawprocessor(self, rawtext):
    # False: do not verify hash. Only the content returned by "readprocessor"
    # can be used to verify hash.
    return False


revlog.addflagprocessor(
    revlog.REVIDX_EXTSTORED, (readprocessor, writeprocessor, rawprocessor)
)

# Utilities about reading and appending revlog


def newtransaction():
    # A transaction is required to write revlogs
    report = lambda msg: None
    return transaction.transaction(report, tvfs, {"plain": tvfs}, b"journal")


def newrevlog(name=b"_testrevlog.i", recreate=False):
    if recreate:
        tvfs.tryunlink(name)
    rlog = revlog.revlog(tvfs, name)