Exemple #1
0
    def _walkstreamfiles(orig, repo):
        if state.shallowremote:
            # if we are shallow ourselves, stream our local commits
            if shallowrepo.requirement in repo.requirements:
                striplen = len(repo.store.path) + 1
                readdir = repo.store.rawvfs.readdir
                visit = [
                    os.path.join(repo.store.path, "packs"),
                    os.path.join(repo.store.path, "data"),
                ]
                while visit:
                    p = visit.pop()

                    try:
                        dirents = readdir(p, stat=True)
                    except OSError as ex:
                        if ex.errno != errno.ENOENT:
                            raise
                        continue

                    for f, kind, st in dirents:
                        fp = p + "/" + f
                        if kind == stat.S_IFREG:
                            if not fp.endswith(".i") and not fp.endswith(".d"):
                                n = util.pconvert(fp[striplen:])
                                yield (store.decodedir(n), n, st.st_size)
                        if kind == stat.S_IFDIR:
                            visit.append(fp)

            shallowtrees = repo.ui.configbool("remotefilelog", "shallowtrees", False)
            if "treemanifest" in repo.requirements and not shallowtrees:
                for (u, e, s) in repo.store.datafiles():
                    if u.startswith("meta/") and (u.endswith(".i") or u.endswith(".d")):
                        yield (u, e, s)

            # Return .d and .i files that do not match the shallow pattern
            match = state.match
            if match and not match.always():
                for (u, e, s) in repo.store.datafiles():
                    f = u[5:-2]  # trim data/...  and .i/.d
                    if not state.match(f):
                        yield (u, e, s)

            for x in repo.store.topfiles():
                if shallowtrees and x[0][:15] == "00manifesttree.":
                    continue
                if state.noflatmf and x[0][:11] == "00manifest.":
                    continue
                yield x

        elif shallowrepo.requirement in repo.requirements:
            # don't allow cloning from a shallow repo to a full repo
            # since it would require fetching every version of every
            # file in order to create the revlogs.
            raise error.Abort(_("Cannot clone from a shallow repo " "to a full repo."))
        else:
            for x in orig(repo):
                yield x
Exemple #2
0
def issvnurl(ui, url):
    try:
        proto, path = url.split("://", 1)
        if proto == "file":
            if (pycompat.iswindows and path[:1] == "/" and path[1:2].isalpha()
                    and path[2:6].lower() == "%3a/"):
                path = path[:2] + ":/" + path[6:]
            path = urlreq.url2pathname(path)
    except ValueError:
        proto = "file"
        path = os.path.abspath(url)
    if proto == "file":
        path = util.pconvert(path)
    check = protomap.get(proto, lambda *args: False)
    while "/" in path:
        if check(ui, path, proto):
            return True
        path = path.rsplit("/", 1)[0]
    return False
Exemple #3
0
def snapshot(ui, repo, files, node, tmproot):
    """snapshot files as of some revision
    if not using snapshot, -I/-X does not work and recursive diff
    in tools like kdiff3 and meld displays too many files."""
    dirname = os.path.basename(repo.root)
    if dirname == "":
        dirname = "root"
    if node is not None:
        dirname = "%s.%s" % (dirname, short(node))
    base = os.path.join(tmproot, dirname)
    os.mkdir(base)
    fnsandstat = []

    if node is not None:
        ui.note(
            _("making snapshot of %d files from rev %s\n") %
            (len(files), short(node)))
    else:
        ui.note(
            _("making snapshot of %d files from working directory\n") %
            (len(files)))

    if files:
        repo.ui.setconfig("ui", "archivemeta", False)

        archival.archive(repo,
                         base,
                         node,
                         "files",
                         matchfn=scmutil.matchfiles(repo, files))

        for fn in sorted(files):
            wfn = util.pconvert(fn)
            ui.note("  %s\n" % wfn)

            if node is None:
                dest = os.path.join(base, wfn)

                fnsandstat.append((dest, repo.wjoin(fn), util.lstat(dest)))
    return dirname, fnsandstat