Ejemplo n.º 1
0
 def _getfilelog(path):
     if path not in filelogcache:
         # Make memory usage bounded
         if len(filelogcache) % 1000 == 0:
             if _getrsspagecount() > maxpagesize:
                 filelogcache.clear()
         filelogcache[path] = filelog.filelog(repo.svfs, path)
     return filelogcache[path]
Ejemplo n.º 2
0
def buildtemprevlog(repo, file):
    # get filename key
    filekey = hashlib.sha1(file).hexdigest()
    filedir = os.path.join(repo.path, "store/data", filekey)

    # sort all entries based on linkrev
    fctxs = []
    for filenode in os.listdir(filedir):
        if "_old" not in filenode:
            fctxs.append(repo.filectx(file, fileid=bin(filenode)))

    fctxs = sorted(fctxs, key=lambda x: x.linkrev())

    # add to revlog
    temppath = repo.sjoin("data/temprevlog.i")
    if os.path.exists(temppath):
        os.remove(temppath)
    r = filelog.filelog(repo.svfs, "temprevlog")

    class faket(object):
        def add(self, a, b, c):
            pass

    t = faket()
    for fctx in fctxs:
        if fctx.node() not in repo:
            continue

        p = fctx.filelog().parents(fctx.filenode())
        meta = {}
        if fctx.renamed():
            meta["copy"] = fctx.renamed()[0]
            meta["copyrev"] = hex(fctx.renamed()[1])

        r.add(fctx.data(), meta, t, fctx.linkrev(), p[0], p[1])

    return r