MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / replicate

Function replicate

scripts/memwaste-scaling.py:63–83  ·  view source on GitHub ↗

Hard-link `copies` replicas of src under dst/r ; returns the file count.

(src: str, dst: str, copies: int)

Source from the content-addressed store, hash-verified

61
62
63def replicate(src: str, dst: str, copies: int) -> int:
64 """Hard-link `copies` replicas of src under dst/r<i>; returns the file count."""
65 files = 0
66 for i in range(copies):
67 base = os.path.join(dst, f"r{i}")
68 for dirpath, dirnames, filenames in os.walk(src):
69 dirnames[:] = [d for d in dirnames if d not in (".git", ".hg", ".svn")]
70 rel = os.path.relpath(dirpath, src)
71 out_dir = os.path.join(base, rel)
72 os.makedirs(out_dir, exist_ok=True)
73 for name in filenames:
74 s = os.path.join(dirpath, name)
75 if os.path.islink(s) or not os.path.isfile(s):
76 continue
77 d = os.path.join(out_dir, name)
78 try:
79 os.link(s, d)
80 except OSError:
81 shutil.copy2(s, d)
82 files += 1
83 return files
84
85
86def run_leg(binary: str, profdata: str, corpus: str, work: str, copies: int) -> tuple[dict, dict]:

Callers 1

run_legFunction · 0.85

Calls 1

rangeFunction · 0.85

Tested by

no test coverage detected