Page MenuHomeSoftware Heritage

No OneTemporary

diff --git a/swh/provenance/tests/data/generate_repo.py b/swh/provenance/tests/data/generate_repo.py
index ac51739..734838b 100644
--- a/swh/provenance/tests/data/generate_repo.py
+++ b/swh/provenance/tests/data/generate_repo.py
@@ -1,115 +1,115 @@
import os
import pathlib
import shutil
from subprocess import PIPE, check_call, check_output
import click
import yaml
def clean_wd():
_, dirnames, filenames = next(os.walk("."))
for d in dirnames:
if not d.startswith(".git"):
shutil.rmtree(d)
for f in filenames:
if not f.startswith(".git"):
os.unlink(f)
def print_ids():
revid = check_output(["git", "rev-parse", "HEAD"]).decode().strip()
ts, msg = (
check_output(["git", "log", "-1", '--format="%at %s"'])
.decode()
.strip()[1:-1]
.split()
)
print(f"{ts}.0 {revid} {msg}")
print(f"{msg:<5} | {'':>5} | {'':>20} | R {revid} | {ts}.0")
for currentpath, dirnames, filenames in os.walk("."):
if currentpath == ".":
output = check_output(["git", "cat-file", "-p", "HEAD"]).decode()
dirhash = output.splitlines()[0].split()[1]
else:
currentpath = currentpath[2:]
output = check_output(["git", "ls-tree", "HEAD", currentpath]).decode()
dirhash = output.split()[2]
print(f"{'':>5} | {'':>5} | {currentpath:<20} | D {dirhash} | 0.0")
for fname in filenames:
fname = os.path.join(currentpath, fname)
output = check_output(["git", "ls-tree", "HEAD", fname]).decode()
fhash = output.split()[2]
print(f"{'':>5} | {'':>5} | {fname:<20} | C {fhash} | 0.0")
if ".git" in dirnames:
dirnames.remove(".git")
def generate_repo(repo_desc, output_dir):
check_call(["git", "init", output_dir], stdout=PIPE, stderr=PIPE)
os.chdir(output_dir)
os.environ.update(
{
"GIT_AUTHOR_NAME": "SWH",
"GIT_AUTHOR_EMAIL": "contact@softwareheritage.org",
"GIT_COMMITTER_NAME": "SWH",
"GIT_COMMITTER_EMAIL": "contact@softwareheritage.org",
}
)
for rev_d in repo_desc:
parents = rev_d.get("parents")
if parents:
# move at the proper (first) parent position, if any
check_call(["git", "checkout", parents[0]], stdout=PIPE)
- # give a branch name (the msg) to each commit to make it esier to
+ # give a branch name (the msg) to each commit to make it easier to
# navigate in history
check_call(["git", "checkout", "-b", rev_d["msg"]], stdout=PIPE)
if parents and len(parents) > 1:
# it's a merge
check_call(["git", "merge", "--no-commit", *parents[1:]], stdout=PIPE)
clean_wd()
for path, content in rev_d["content"].items():
p = pathlib.Path(path)
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text(content)
os.environ.update(
{
"GIT_AUTHOR_DATE": str(rev_d["date"]),
"GIT_COMMITTER_DATE": str(rev_d["date"]),
}
)
check_call(["git", "add", "."], stdout=PIPE)
check_call(
[
"git",
"commit",
"--all",
"--allow-empty",
"-m",
rev_d["msg"],
],
stdout=PIPE,
)
print_ids()
@click.command(name="generate-repo")
@click.argument("input-file")
@click.argument("output-dir")
@click.option("-C", "--clean-output/--no-clean-output", default=False)
def main(input_file, output_dir, clean_output):
repo_desc = yaml.load(open(input_file))
if clean_output and os.path.exists(output_dir):
shutil.rmtree(output_dir)
generate_repo(repo_desc, output_dir)
if __name__ == "__main__":
main()
diff --git a/swh/provenance/tests/data/history_graphs_with-merges_visits-01.yaml b/swh/provenance/tests/data/history_graphs_with-merges_visits-01.yaml
index a84e73b..d3aa69d 100644
--- a/swh/provenance/tests/data/history_graphs_with-merges_visits-01.yaml
+++ b/swh/provenance/tests/data/history_graphs_with-merges_visits-01.yaml
@@ -1,55 +1,61 @@
# History graph for snapshot with branches: R01
-- origin: "https://with-merges"
+- origin: "https://repo_with_merges/1/"
snapshot: "e2520f0dbf34c92754f00c5a60241dfa7d612868"
graphs:
- rev: "1444db96cbd8cd791abe83527becee73d3c64e86"
parents:
- rev: "c0d8929936631ecbcf9147be6b8aa13b13b014e4"
# History graph for snapshot with branches: R03 and R06
-- origin: "https://with-merges"
+- origin: "https://repo_with_merges/1/"
snapshot: "e2520f0dbf34c92754f00c5a60241dfa7d612868"
graphs:
- rev: "20f4da0f48609d9f7f908ebbcac3b3741a0f25cb"
parents:
- rev: "1c533587277731236616cac0d44f3b46c1da0f8a"
parents:
- rev: "1444db96cbd8cd791abe83527becee73d3c64e86"
visited: True
- rev: "72d92d41a9095db2dd6b8fb1c62d92c8251753ff"
parents:
- rev: "1444db96cbd8cd791abe83527becee73d3c64e86"
visited: True
# History graph for snapshot with branches: R05 and R06
-- origin: "https://with-merges"
+- origin: "https://repo_with_merges/2/"
snapshot: "e2520f0dbf34c92754f00c5a60241dfa7d612868"
graphs:
- rev: "65e58853df939b318c106c4c1f55acaf8b41c74c"
parents:
- rev: "0d66eadcc15e0d7f6cfd4289329a7749a1309982"
parents:
- rev: "20f4da0f48609d9f7f908ebbcac3b3741a0f25cb"
visited: True
- rev: "72d92d41a9095db2dd6b8fb1c62d92c8251753ff"
visited: True
# History graph for snapshot with branches: R06 and R07
-- origin: "https://with-merges"
+- origin: "https://repo_with_merges/1/"
snapshot: "e2520f0dbf34c92754f00c5a60241dfa7d612868"
graphs:
- rev: "72d92d41a9095db2dd6b8fb1c62d92c8251753ff"
visited: True
- rev: "fff0089fad98e8f5b46ec5c9025a20a602851ba6"
parents:
- rev: "20f4da0f48609d9f7f908ebbcac3b3741a0f25cb"
visited: True
# History graph for snapshot with branches: R08
-- origin: "https://with-merges"
+- origin: "https://repo_with_merges/1/"
snapshot: "e2520f0dbf34c92754f00c5a60241dfa7d612868"
graphs:
- rev: "7c8f29237dded4f9d265e46ec7066503e7858e87"
parents:
- rev: "65e58853df939b318c106c4c1f55acaf8b41c74c"
visited: True
- rev: "72d92d41a9095db2dd6b8fb1c62d92c8251753ff"
visited: True
- rev: "fff0089fad98e8f5b46ec5c9025a20a602851ba6"
visited: True
+# History graph for snapshot with branches: R08
+- origin: "https://repo_with_merges/2/"
+ snapshot: "e2520f0dbf34c92754f00c5a60241dfa7d612868"
+ graphs:
+ - rev: "7c8f29237dded4f9d265e46ec7066503e7858e87"
+ visited: True

File Metadata

Mime Type
text/x-diff
Expires
Fri, Jul 4, 3:49 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3293371

Event Timeline