navid/veins / commit
20ddbcdc2ae0
Navid M <navidmomtahen@gmail.com> · 2026-11-29
parents: a3273a56ba14
Browse files at this commit · Download source
--- a/xveins/bench/net_bench.sh+++ b/xveins/bench/net_bench.sh@@ -98,10 +98,6 @@ handle.write("\n") PY }--# ----------------------------------------------------------------------------# Keys and access-# --------------------------------------------------------------------------- run_cpp key generate benchkey >"$WORK/key.txt" PUB=$(awk '/public key:/ {print $3}' "$WORK/key.txt")@@ -115,10 +111,6 @@ (cd "$1" && run_cpp access anonymous on && run_cpp access add -role write -key "$PUB" -name bench >/dev/null) }--# ----------------------------------------------------------------------------# Dataset: 360 small files, a 2 MiB old blob, and a 1 MiB head blob.-# --------------------------------------------------------------------------- ( cd "$WORK/bench_src"@@ -159,10 +151,6 @@ run_sx bmk set main >/dev/null ) grant_access "$WORK/push_pristine"--# ----------------------------------------------------------------------------# Prepared client/server repositories-# --------------------------------------------------------------------------- run_cpp clone "file://$WORK/bench_src" "$WORK/fetch_pristine_cpp" -blobs:all >/dev/null run_sx clone "file://$WORK/bench_src" "$WORK/fetch_pristine_sx" -blobs:all >/dev/null@@ -185,10 +173,6 @@ run_sx bmk set main >/dev/null run_sx remote set-url origin "file://$WORK/push_srv_sx" )--# ----------------------------------------------------------------------------# ssh shim: execute the remote `vn serve -stdio ...` command locally.-# --------------------------------------------------------------------------- cat >"$WORK/fakebin/ssh" <<'SH' #!/bin/sh@@ -204,10 +188,6 @@ exec /bin/sh -c "$*" SH chmod +x "$WORK/fakebin/ssh"--# ----------------------------------------------------------------------------# TLS certificate and servers-# --------------------------------------------------------------------------- cat >"$WORK/openssl.cnf" <<EOF [req]@@ -272,10 +252,6 @@ run_cpp remote add tls_sx "veins://localhost:$PORT_SX/bench_src" \ -key:benchkey -pin:"$PIN" >/dev/null )--# ----------------------------------------------------------------------------# Hyperfine prepare scripts-# --------------------------------------------------------------------------- write_prepare() { path="$WORK/$1"@@ -307,10 +283,6 @@ "rm -rf '$WORK/clone_tls_cpp' '$WORK/clone_tls_sx'" write_prepare prepare_noop.sh \ "exit 0"--# ----------------------------------------------------------------------------# Run hyperfine-# --------------------------------------------------------------------------- run_pair() { name=$1@@ -368,9 +340,6 @@ cleanup trap - 0 2 15 -# ----------------------------------------------------------------------------# BENCHES.md-# --------------------------------------------------------------------------- python3 - "$WORK" >"$WORK/summary.md" <<'PY' import json, os, sys--- a/xveins/src/auth/auth.cpp+++ b/xveins/src/auth/auth.cpp@@ -185,10 +185,6 @@ } } // namespace--// ----------------------------------------------------------------------------// Client keys-// --------------------------------------------------------------------------- fs::path key_dir() { if (auto xdg = env_value("XDG_CONFIG_HOME"))@@ -268,10 +264,6 @@ } return out; }--// ----------------------------------------------------------------------------// Per-user key selection-// --------------------------------------------------------------------------- fs::path auth_dir() { const fs::path dir = key_dir();@@ -344,10 +336,6 @@ } return lookup_credential(dir, "default"); }--// ----------------------------------------------------------------------------// Server access policy-// --------------------------------------------------------------------------- Access empty_access() { return Access{};--- a/xveins/src/auth/auth.h+++ b/xveins/src/auth/auth.h@@ -27,10 +27,6 @@ std::optional<Key> load_key(std::string_view name); std::optional<Key> generate_key(std::string_view name); std::vector<std::string> list_key_names();--// ----------------------------------------------------------------------------// Per-user key selection-// --------------------------------------------------------------------------- fs::path auth_dir(); std::string normalize_target(std::string_view target);@@ -39,10 +35,6 @@ std::vector<std::string> list_credential_lines(); bool local_key_exists(std::string_view name); std::optional<std::string> key_for_url(std::string_view url);--// ----------------------------------------------------------------------------// Server access policy-// --------------------------------------------------------------------------- struct AccessEntry { PublicKey public_key{};--- a/xveins/src/cli/cli.cpp+++ b/xveins/src/cli/cli.cpp@@ -2431,10 +2431,6 @@ return 0; } -// ----------------------------------------------------------------------------// Help-// ---------------------------------------------------------------------------- void usage() { std::cout << "veins is a tool for managing source code\n"; std::cout << "\n";--- a/xveins/src/cli/net_commands.cpp+++ b/xveins/src/cli/net_commands.cpp@@ -652,10 +652,6 @@ std::cout << "unknown remote subcommand: " << sub << "\n"; return 1; }--// ----------------------------------------------------------------------------// clone-// --------------------------------------------------------------------------- int clone_run(const std::vector<std::string>& args) { std::string url;@@ -806,10 +802,6 @@ std::cout << "cloned into " << path << "\n"; return 0; }--// ----------------------------------------------------------------------------// fetch-// --------------------------------------------------------------------------- int fetch_run(const std::vector<std::string>& args) { std::string remote_name;@@ -917,10 +909,6 @@ std::cout << "fetched from " << remote_name << "\n"; return 0; }--// ----------------------------------------------------------------------------// gg: fetch the active remote, or clone a URL-// --------------------------------------------------------------------------- int gg_run(const std::vector<std::string>& args) { std::string first;@@ -956,10 +944,6 @@ } return fetch_run(forwarded); }--// ----------------------------------------------------------------------------// push-// --------------------------------------------------------------------------- int push_run(const std::vector<std::string>& args) { std::string remote_name;@@ -1130,10 +1114,6 @@ std::cout << "pushed " << tag_updates << " tag(s)\n"; return 0; }--// ----------------------------------------------------------------------------// serve-// --------------------------------------------------------------------------- int serve_run(const std::vector<std::string>& args) { bool stdio_mode = false;@@ -1203,10 +1183,6 @@ } return server::serve_listen(listen, path_from_bytes(root), cert, key, quota_bytes); }--// ----------------------------------------------------------------------------// key-// --------------------------------------------------------------------------- int key_run(const std::vector<std::string>& args) { const std::string sub = arg_at(args, 2);@@ -1263,10 +1239,6 @@ std::cout << "unknown key subcommand: " << sub << "\n"; return 1; }--// ----------------------------------------------------------------------------// auth-// --------------------------------------------------------------------------- int auth_run(const std::vector<std::string>& args) { const std::string sub = arg_at(args, 2);@@ -1320,10 +1292,6 @@ auth_usage(); return 1; }--// ----------------------------------------------------------------------------// access-// --------------------------------------------------------------------------- int access_run(const std::vector<std::string>& args) { const std::string sub = arg_at(args, 2);@@ -1431,10 +1399,6 @@ std::cout << "unknown access subcommand: " << sub << "\n"; return 1; }--// ----------------------------------------------------------------------------// whoami-// --------------------------------------------------------------------------- int whoami_run(const std::vector<std::string>& args) { std::string remote;@@ -1498,9 +1462,6 @@ return 0; } -// ----------------------------------------------------------------------------// Help-// --------------------------------------------------------------------------- bool net_help(std::string_view command) { if (command == "remote") {--- a/xveins/src/core/common.cpp+++ b/xveins/src/core/common.cpp@@ -81,9 +81,6 @@ return Error{ErrorKind::Usage, 0, std::move(message)}; } -// ----------------------------------------------------------------------------// Hex / base32-// --------------------------------------------------------------------------- static char hex_digit(std::uint8_t v) { return static_cast<char>(v < 10 ? '0' + v : 'a' + (v - 10));@@ -174,9 +171,6 @@ return true; } -// ----------------------------------------------------------------------------// Hashing and randomness-// --------------------------------------------------------------------------- std::array<std::uint8_t, 32> blake3_hash(Bytes data) { std::array<std::uint8_t, 32> out{};@@ -244,9 +238,6 @@ return value; } -// ----------------------------------------------------------------------------// Reader / writer-// --------------------------------------------------------------------------- Result<std::uint8_t> Reader::u8() { if (pos_ >= data_.size())@@ -514,9 +505,6 @@ i16le(t.tz_min); } -// ----------------------------------------------------------------------------// Time / terminal-// --------------------------------------------------------------------------- std::size_t available_cpu_count() { #if defined(_WIN32)@@ -897,9 +885,6 @@ std::cerr.flush(); } -// ----------------------------------------------------------------------------// Filesystem-// --------------------------------------------------------------------------- fs::path path_from_bytes(std::string_view bytes) { #if defined(_WIN32)@@ -1331,9 +1316,6 @@ return info && info->executable; } -// ----------------------------------------------------------------------------// Configuration-// --------------------------------------------------------------------------- static std::string_view trim_view(std::string_view s) { std::size_t start = 0;@@ -1899,9 +1881,6 @@ return sig; } -// ----------------------------------------------------------------------------// Ignore rules-// --------------------------------------------------------------------------- IgnoreRules ignore_empty() { return {};--- a/xveins/src/core/common.h+++ b/xveins/src/core/common.h@@ -175,9 +175,6 @@ return unexpected(Error::usage(std::move(message))); } -// ----------------------------------------------------------------------------// Byte and string helpers-// --------------------------------------------------------------------------- inline Bytes bytes_of(std::string_view s) { return Bytes(reinterpret_cast<const std::uint8_t*>(s.data()), s.size());@@ -230,9 +227,6 @@ std::string base32_encode(const ChangeId& id); bool base32_prefix_matches(std::string_view full, std::string_view prefix); -// ----------------------------------------------------------------------------// Hashing and random bytes-// --------------------------------------------------------------------------- std::array<std::uint8_t, 32> blake3_hash(Bytes data); Id object_id(std::uint8_t type_byte, Bytes body);@@ -239,9 +233,6 @@ std::array<std::uint8_t, 16> random_change_id(); std::uint64_t random_u64(); -// ----------------------------------------------------------------------------// Binary reader / writer-// --------------------------------------------------------------------------- class Reader { public:@@ -346,9 +337,6 @@ std::vector<std::uint8_t> buf_; }; -// ----------------------------------------------------------------------------// Dates, terminal output-// --------------------------------------------------------------------------- std::string format_utc(std::int64_t seconds); std::int64_t unix_now_seconds();@@ -413,9 +401,6 @@ std::chrono::steady_clock::time_point last_draw_{}; }; -// ----------------------------------------------------------------------------// Filesystem helpers-// --------------------------------------------------------------------------- fs::path path_from_bytes(std::string_view bytes); std::string path_to_bytes(const fs::path& p);@@ -455,9 +440,6 @@ }; std::optional<StatInfo> stat_path(const fs::path& p); -// ----------------------------------------------------------------------------// Configuration and identity-// --------------------------------------------------------------------------- std::optional<std::string> repo_config_value(const fs::path& repo_root, std::string_view key); bool repo_config_set(const fs::path& repo_root, std::string_view key, std::string_view value);@@ -492,9 +474,6 @@ bool set_current_bookmark(const fs::path& repo_root, std::string_view name); bool clear_current_bookmark(const fs::path& repo_root); -// ----------------------------------------------------------------------------// Ignore rules-// --------------------------------------------------------------------------- struct IgnoreRule { std::string pattern;--- a/xveins/src/merge/merge.cpp+++ b/xveins/src/merge/merge.cpp@@ -14,9 +14,6 @@ namespace { -// ----------------------------------------------------------------------------// Object access that also sees pending transaction objects-// --------------------------------------------------------------------------- bool same_id(const Id& a, const Id& b) { return std::memcmp(a.data(), b.data(), ID_LEN) == 0;@@ -166,9 +163,6 @@ return build.root; } -// ----------------------------------------------------------------------------// Three-way line merge-// --------------------------------------------------------------------------- struct DiffOp { char tag = ' ';@@ -461,9 +455,6 @@ split_lines(bytes_of(*theirs)), adjacent); } -// ----------------------------------------------------------------------------// Rename detection-// --------------------------------------------------------------------------- struct RenamePair { std::string old_path;@@ -645,9 +636,6 @@ namespace { -// ----------------------------------------------------------------------------// Rename maps-// --------------------------------------------------------------------------- using RenameMap = std::vector<std::pair<std::string, std::string>>; @@ -1237,9 +1225,6 @@ return MergeOutcome{build_from_entries(tx, out), rerere}; } -// ----------------------------------------------------------------------------// Commit-level merge helpers-// --------------------------------------------------------------------------- bool contains_id_vec(const std::vector<Id>& ids, const Id& id) { for (const auto& candidate : ids) {@@ -1422,9 +1407,6 @@ return value && *value == "merge"; } -// ----------------------------------------------------------------------------// Tree editing-// --------------------------------------------------------------------------- std::optional<Id> tree_edit_into(Txn& tx, Store& store, const Id& tree_id, std::string_view path, bool present, std::uint8_t kind, const Id& target,@@ -1473,9 +1455,6 @@ return edited; } -// ----------------------------------------------------------------------------// Conflicts-// --------------------------------------------------------------------------- std::string conflict_kind_label(const Conflict& conflict) { for (const auto& value : conflict.adds) {@@ -1521,9 +1500,6 @@ return flatten_any_sorted(store, nullptr, std::optional<Id>{tree}); } -// ----------------------------------------------------------------------------// Commands-// --------------------------------------------------------------------------- int merge_command(const std::vector<std::string>& revs) { if (revs.empty()) {@@ -2030,9 +2006,6 @@ } // namespace -// ----------------------------------------------------------------------------// Argument parsing-// --------------------------------------------------------------------------- int merge_run(const std::vector<std::string>& args) { std::vector<std::string> revs;--- a/xveins/src/net/net.cpp+++ b/xveins/src/net/net.cpp@@ -122,9 +122,6 @@ } // namespace -// ----------------------------------------------------------------------------// Stream-// --------------------------------------------------------------------------- Stream::Stream(Stream&& other) noexcept { *this = std::move(other);@@ -334,9 +331,6 @@ } } -// ----------------------------------------------------------------------------// Process spawning-// --------------------------------------------------------------------------- #if defined(_WIN32) std::optional<Stream> spawn_argv(const std::vector<std::string>& argv) {@@ -433,9 +427,6 @@ } #endif -// ----------------------------------------------------------------------------// TCP-// --------------------------------------------------------------------------- std::optional<Socket> tcp_connect(std::string_view host, int port) { if (host.empty())@@ -569,9 +560,6 @@ #endif } -// ----------------------------------------------------------------------------// Process/platform helpers-// --------------------------------------------------------------------------- void ignore_sigpipe() { #if !defined(_WIN32)@@ -635,9 +623,6 @@ return out; } -// ----------------------------------------------------------------------------// TLS-// --------------------------------------------------------------------------- void* tls_server_ctx(std::string_view cert_path, std::string_view key_path) { SSL_CTX* ctx = SSL_CTX_new(TLS_server_method());--- a/xveins/src/net/net.h+++ b/xveins/src/net/net.h@@ -89,9 +89,6 @@ std::string quote_shell(std::string_view word); std::string build_shell_command(const std::vector<std::string>& parts); -// ----------------------------------------------------------------------------// TLS 1.3-// --------------------------------------------------------------------------- void* tls_server_ctx(std::string_view cert_path, std::string_view key_path); void* tls_client_ctx(bool pinned);--- a/xveins/src/object/object.cpp+++ b/xveins/src/object/object.cpp@@ -30,9 +30,6 @@ return type >= TYPE_CHUNK && type <= TYPE_VIEW; } -// ----------------------------------------------------------------------------// Names-// --------------------------------------------------------------------------- static bool is_dot_name(std::string_view s) { return s == "." || s == "..";@@ -82,9 +79,6 @@ return true; } -// ----------------------------------------------------------------------------// FastCDC-// --------------------------------------------------------------------------- static std::array<std::uint64_t, 256> make_gear_table() { static constexpr std::uint8_t prefix[] = {'v', 'e', 'i', 'n', 's', '/', 'f', 'a', 's', 't', 'c',@@ -137,9 +131,6 @@ return limit; } -// ----------------------------------------------------------------------------// Blobs-// --------------------------------------------------------------------------- Result<std::vector<std::uint8_t>> encode_inline_blob(Bytes data) { ByteWriter w(data.size() + 8);@@ -286,9 +277,6 @@ return build; } -// ----------------------------------------------------------------------------// Trees-// --------------------------------------------------------------------------- static bool valid_tree_kind(std::uint8_t kind) { return kind >= KIND_FILE && kind <= KIND_CONFLICT;@@ -364,9 +352,6 @@ return w.take(); } -// ----------------------------------------------------------------------------// Commits-// --------------------------------------------------------------------------- static Result<std::vector<Id>> read_parents(Reader& r) { const auto n = r.list_len(1024);@@ -536,9 +521,6 @@ return w.take(); } -// ----------------------------------------------------------------------------// Conflicts-// --------------------------------------------------------------------------- static bool conflict_kind_valid(std::uint8_t kind) { return kind == 0 || (kind >= KIND_FILE && kind <= KIND_CONFLICT);@@ -638,9 +620,6 @@ return w.take(); } -// ----------------------------------------------------------------------------// Views-// --------------------------------------------------------------------------- static bool view_name_valid(std::string_view name) { if (name.empty() || name.size() > MAX_NAME_LEN)@@ -926,9 +905,6 @@ return w.take(); } -// ----------------------------------------------------------------------------// Operations-// --------------------------------------------------------------------------- Result<Operation> decode_operation(Bytes body) { Reader r(body);--- a/xveins/src/object/object.h+++ b/xveins/src/object/object.h@@ -32,16 +32,10 @@ std::string value; }; -// ----------------------------------------------------------------------------// Names-// --------------------------------------------------------------------------- bool valid_name(std::string_view name); bool valid_path(std::string_view path); -// ----------------------------------------------------------------------------// Blobs-// --------------------------------------------------------------------------- enum class BlobForm : std::uint8_t { Inline = 0, Leaf = 1, Interior = 2 }; @@ -69,9 +63,6 @@ BlobBuild build_blob(Bytes data); -// ----------------------------------------------------------------------------// Trees-// --------------------------------------------------------------------------- constexpr std::uint8_t KIND_FILE = 1; constexpr std::uint8_t KIND_EXECUTABLE = 2;@@ -95,9 +86,6 @@ Result<Tree> decode_tree(Bytes body); Result<std::vector<std::uint8_t>> encode_tree(const std::vector<TreeEntry>& entries); -// ----------------------------------------------------------------------------// Commits-// --------------------------------------------------------------------------- constexpr std::uint8_t RENAMES_UNKNOWN = 0; constexpr std::uint8_t RENAMES_RECORDED = 1;@@ -125,9 +113,6 @@ Result<Commit> decode_commit(Bytes body); std::vector<std::uint8_t> encode_commit(const Commit& commit); -// ----------------------------------------------------------------------------// Conflicts-// --------------------------------------------------------------------------- struct ConflictValue { std::uint8_t kind = 0;@@ -142,9 +127,6 @@ Result<Conflict> decode_conflict(Bytes body); std::vector<std::uint8_t> encode_conflict(const Conflict& conflict); -// ----------------------------------------------------------------------------// Operations and views-// --------------------------------------------------------------------------- struct TargetSet { std::vector<std::optional<Id>> adds;@@ -196,9 +178,6 @@ Result<Operation> decode_operation(Bytes body); std::vector<std::uint8_t> encode_operation(const Operation& op); -// ----------------------------------------------------------------------------// Graph, tree walking, and content-// --------------------------------------------------------------------------- struct LoadedCommit { Commit commit;--- a/xveins/src/protocol/protocol.cpp+++ b/xveins/src/protocol/protocol.cpp@@ -181,10 +181,6 @@ } } // namespace--// ----------------------------------------------------------------------------// Message codecs-// --------------------------------------------------------------------------- std::vector<std::uint8_t> encode_hello(const Hello& hello) { ByteWriter writer(128);@@ -524,10 +520,6 @@ return "read"; return "anonymous"; }--// ----------------------------------------------------------------------------// URLs-// --------------------------------------------------------------------------- std::optional<Url> parse_url(std::string_view url) { constexpr std::string_view file_prefix = "file://";@@ -562,10 +554,6 @@ return {}; return parsed->path; }--// ----------------------------------------------------------------------------// Client-// --------------------------------------------------------------------------- void Client::set_error(std::string text) { last_error_ = std::move(text);--- a/xveins/src/protocol/protocol.h+++ b/xveins/src/protocol/protocol.h@@ -95,9 +95,6 @@ Bytes client_nonce, Bytes binding); std::string_view role_name(std::uint8_t role); -// ----------------------------------------------------------------------------// URLs-// --------------------------------------------------------------------------- struct Url { bool tls = false;@@ -110,9 +107,6 @@ std::optional<Url> parse_url(std::string_view url); std::string url_repo_name(std::string_view url); -// ----------------------------------------------------------------------------// Client-// --------------------------------------------------------------------------- class Client { public:--- a/xveins/src/store/store.cpp+++ b/xveins/src/store/store.cpp@@ -31,9 +31,6 @@ promisor_fetcher = std::move(fetcher); } -// ----------------------------------------------------------------------------// Layout-// --------------------------------------------------------------------------- fs::path veins_dir(const fs::path& root) { return root / ".veins";@@ -172,9 +169,6 @@ return root; } -// ----------------------------------------------------------------------------// Pack decoding-// --------------------------------------------------------------------------- std::optional<std::size_t> Pack::find_by_offset(std::uint64_t offset) const { std::size_t lo = 0;@@ -350,9 +344,6 @@ return pack; } -// ----------------------------------------------------------------------------// Index-// --------------------------------------------------------------------------- std::optional<std::size_t> Index::find(const Id& id) const { std::size_t lo = 0;@@ -467,9 +458,6 @@ return bytes; } -// ----------------------------------------------------------------------------// Pack encoding-// --------------------------------------------------------------------------- static std::vector<std::uint8_t> zstd_compress(Bytes data, int level) { if (data.empty())@@ -1086,9 +1074,6 @@ return 0; } -// ----------------------------------------------------------------------------// Store-// --------------------------------------------------------------------------- #if !defined(_WIN32) StoreHandle::StoreHandle(StoreHandle&& other) noexcept@@ -1438,10 +1423,6 @@ return text.find("promisor") != std::string_view::npos; } -// ----------------------------------------------------------------------------// Writer-// ---------------------------------------------------------------------------- Id Writer::add(std::uint8_t type, const std::vector<std::uint8_t>& body) { const Id id = object_id(type, bytes_of(body)); if (quota_hit_ || !seen_.insert(id).second)@@ -1516,9 +1497,6 @@ return write_pack(root, objects_, limit_); } -// ----------------------------------------------------------------------------// View helpers-// --------------------------------------------------------------------------- static bool id_less(const Id& a, const Id& b) { return std::memcmp(a.data(), b.data(), ID_LEN) < 0;@@ -1782,9 +1760,6 @@ } } -// ----------------------------------------------------------------------------// Transactions-// --------------------------------------------------------------------------- Result<Txn> Txn::begin(const fs::path& root, Store& store) { Txn tx;@@ -1885,9 +1860,6 @@ return {}; } -// ----------------------------------------------------------------------------// Native commit map-// --------------------------------------------------------------------------- static fs::path native_path(const fs::path& root) { return git_map_dir(root) / "native";@@ -1925,9 +1897,6 @@ return contains_id(native, id); } -// ----------------------------------------------------------------------------// Graph-// --------------------------------------------------------------------------- std::optional<LoadedCommit> load_commit(Store& store, const Id& id) { auto body = store.read_body(id, TYPE_COMMIT);@@ -2166,9 +2135,6 @@ return std::nullopt; } -// ----------------------------------------------------------------------------// Tree walking-// --------------------------------------------------------------------------- static void join_path(std::string& prefix, std::string_view name) { if (!prefix.empty())@@ -2334,9 +2300,6 @@ return out; } -// ----------------------------------------------------------------------------// Blob content-// --------------------------------------------------------------------------- static bool append_blob_data(Store& store, const Id& id, std::vector<std::uint8_t>& out, std::size_t depth) {@@ -2382,9 +2345,6 @@ return out; } -// ----------------------------------------------------------------------------// fsck-// --------------------------------------------------------------------------- namespace { --- a/xveins/src/store/store.h+++ b/xveins/src/store/store.h@@ -240,10 +240,6 @@ std::int64_t start_ms_ = 0; Writer writer_; };--// ----------------------------------------------------------------------------// Operation state and view mutations-// --------------------------------------------------------------------------- std::vector<Id> read_heads(const fs::path& root); bool write_head(const fs::path& root, const Id& id);