コード例 #1
0
ファイル: wrapper.py プロジェクト: Smosker/mercurial
def writetostore(self, text):
    # hg filelog metadata (includes rename, etc)
    hgmeta, offset = revlog.parsemeta(text)
    if offset and offset > 0:
        # lfs blob does not contain hg filelog metadata
        text = text[offset:]

    # git-lfs only supports sha256
    oid = hex(hashlib.sha256(text).digest())
    self.opener.lfslocalblobstore.write(oid, text)

    # replace contents with metadata
    longoid = 'sha256:%s' % oid
    metadata = pointer.gitlfspointer(oid=longoid, size='%d' % len(text))

    # by default, we expect the content to be binary. however, LFS could also
    # be used for non-binary content. add a special entry for non-binary data.
    # this will be used by filectx.isbinary().
    if not stringutil.binary(text):
        # not hg filelog metadata (affecting commit hash), no "x-hg-" prefix
        metadata['x-is-binary'] = '0'

    # translate hg filelog metadata to lfs metadata with "x-hg-" prefix
    if hgmeta is not None:
        for k, v in hgmeta.iteritems():
            metadata['x-hg-%s' % k] = v

    rawtext = metadata.serialize()
    return (rawtext, False)
コード例 #2
0
def filelogaddrevision(orig,
                       self,
                       text,
                       transaction,
                       link,
                       p1,
                       p2,
                       cachedelta=None,
                       node=None,
                       flags=revlog.REVIDX_DEFAULT_FLAGS,
                       **kwds):
    # The matcher isn't available if reposetup() wasn't called.
    lfstrack = self.opener.options.get('lfstrack')

    if lfstrack:
        textlen = len(text)
        # exclude hg rename meta from file size
        meta, offset = revlog.parsemeta(text)
        if offset:
            textlen -= offset

        if lfstrack(self.filename, textlen):
            flags |= revlog.REVIDX_EXTSTORED

    return orig(self,
                text,
                transaction,
                link,
                p1,
                p2,
                cachedelta=cachedelta,
                node=node,
                flags=flags,
                **kwds)
コード例 #3
0
    def renamed(self, node):
        validatenode(node)

        if self.parents(node)[0] != nullid:
            return False

        fulltext = self.revision(node)
        m = revlog.parsemeta(fulltext)[0]

        if m and 'copy' in m:
            return m['copy'], bin(m['copyrev'])

        return False
コード例 #4
0
ファイル: wrapper.py プロジェクト: Smosker/mercurial
def filelogaddrevision(orig, self, text, transaction, link, p1, p2,
                       cachedelta=None, node=None,
                       flags=revlog.REVIDX_DEFAULT_FLAGS, **kwds):
    textlen = len(text)
    # exclude hg rename meta from file size
    meta, offset = revlog.parsemeta(text)
    if offset:
        textlen -= offset

    lfstrack = self.opener.options['lfstrack']

    if lfstrack(self.filename, textlen):
        flags |= revlog.REVIDX_EXTSTORED

    return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta,
                node=node, flags=flags, **kwds)