mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
98d9269874
Summary: Create a fork of the Mercurial code that we can use to build server rpms. The hg servers will continue to exist for a few more months while we move the darkstorm and ediscovery use cases off them. In the mean time, we want to start making breaking changes to the client, so let's create a stable copy of the hg code to produce rpms for the hg servers. The fork is based off c7770c78d, the latest hg release. This copies the files as is, then adds some minor tweaks to get it to build: - Disables some lint checks that appear to be bypassed by path - sed replace eden/scm with eden/hg-server - Removed a dependency on scm/telemetry from the edenfs-client tests since scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts with the hg-server conflict parser. allow-large-files Reviewed By: quark-zju Differential Revision: D27632557 fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
141 lines
3.4 KiB
Python
141 lines
3.4 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
# tracing-level: trace
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import os
|
|
|
|
from bindings import tracing
|
|
from testutil.autofix import eq
|
|
from testutil.dott import feature, sh, testtmp # noqa: F401
|
|
|
|
|
|
idtopath = {}
|
|
|
|
|
|
def getidtopath():
|
|
"""Return a dict mapping from id (in hex form) to path"""
|
|
output = sh.hg("debugmanifestdirs", "-rall()")
|
|
# debugmanifestdirs prints "<id> <path>" per line
|
|
result = dict(l.split() for l in output.splitlines())
|
|
return result
|
|
|
|
|
|
def collectprefetch(command):
|
|
"""Updating to commit, check prefetched paths"""
|
|
d = tracing.tracingdata()
|
|
|
|
with d:
|
|
(sh % command).output
|
|
|
|
ids = []
|
|
for spans in d.treespans().values():
|
|
for span in spans.flatten():
|
|
name = span.get("name")
|
|
if name == "tree::store::prefetch":
|
|
ids += span["ids"].split()
|
|
elif name == "tree::store::get":
|
|
ids.append(span["id"])
|
|
idtopath.update(getidtopath())
|
|
paths = set(idtopath[id] for id in set(ids)) - {"/"}
|
|
|
|
# Translate ids to paths
|
|
return sorted(filter(None, paths))
|
|
|
|
|
|
# Use some production settings. They avoid expensive paths.
|
|
sh % "setconfig experimental.copytrace=off copytrace.fastcopytrace=true perftweaks.disablecasecheck=true"
|
|
sh % "enable sparse treemanifest rebase copytrace"
|
|
|
|
# flatcompat calls '.text()' which invalidates fast paths. So disable it.
|
|
sh % "setconfig treemanifest.flatcompat=0"
|
|
|
|
sh % "newrepo"
|
|
sh % "drawdag" << r"""
|
|
B # B/x/x/y/z=B1
|
|
| # B/y/x/y/z=B2
|
|
|
|
|
|
|
|
| D # D/d/d/d/d=D1
|
|
| |
|
|
| C # C/c/c/c/c=C1
|
|
|/
|
|
A # A/x/x/y/z=A1
|
|
# A/y/x/y/z=A2
|
|
# A/z/x/y/z=A3
|
|
"""
|
|
|
|
sh % "hg sparse include x"
|
|
|
|
# Good: Updating to A should avoid downloading y/ or z/
|
|
eq(collectprefetch("hg update -q $A"), ["x", "x/x", "x/x/y"])
|
|
|
|
# Good: Updating to B should avoid downloading y/
|
|
eq(collectprefetch("hg update -q $B"), ["x", "x/x", "x/x/y"])
|
|
|
|
|
|
sh % "hg update -q $D"
|
|
|
|
|
|
# Good: Rebasing B to D should avoid downloading d/ or c/, or z/.
|
|
# (This is optimized by "rebase: use matcher to optimize manifestmerge",
|
|
# https://www.mercurial-scm.org/repo/hg/rev/4d504e541d3d,
|
|
# fbsource-hg: 94ad1b49ede1f8e5897c7c9381304785746fa460)
|
|
eq(
|
|
collectprefetch("hg rebase -r $B -d $D -q"),
|
|
["x", "x/x", "x/x/y", "y", "y/x", "y/x/y"],
|
|
)
|
|
|
|
# Good: Changing sparse profile should not download everything.
|
|
eq(collectprefetch("hg sparse exclude y"), ["x", "x/x", "x/x/y"])
|
|
|
|
|
|
# Test sparse profile change.
|
|
|
|
sh % "newrepo"
|
|
sh % "drawdag" << r"""
|
|
# B/profile=[include]\nx\ny
|
|
B # B/x/x/x=2
|
|
| # B/y/y/y=2
|
|
| # B/z/z/z=2
|
|
|
|
|
A # A/profile=[include]\nx
|
|
# A/x/x/x=1
|
|
# A/y/y/y=1
|
|
# A/z/z/z=1
|
|
"""
|
|
|
|
idtopath = getidtopath()
|
|
|
|
eq(collectprefetch("hg sparse enable profile"), [])
|
|
|
|
# Good: Updating to A should avoid downloading y/ or z/
|
|
eq(collectprefetch("hg update -q $A"), ["x", "x/x"])
|
|
|
|
# Good: Updating to B should avoid downloading z/
|
|
eq(collectprefetch("hg update -q $B"), ["x", "x/x", "y", "y/y"])
|
|
|
|
|
|
# Test 'status'.
|
|
|
|
sh % "newrepo"
|
|
sh % "drawdag" << r"""
|
|
A # A/x/x/x=1
|
|
# A/y/y/y=1
|
|
# A/z/z/z=1
|
|
"""
|
|
|
|
eq(collectprefetch("hg sparse include x"), [])
|
|
sh % "hg up -q $A"
|
|
open("y", "w").write("2")
|
|
os.mkdir("z")
|
|
open("z/1", "w").write("2")
|
|
open("z/z", "w").write("2")
|
|
|
|
# Good: 'status' should avoid downloading y/ or z/.
|
|
eq(sorted(set(collectprefetch("hg status")) - {"x", "x/x"}), [])
|