# HG changeset patch # User Georges Racinet <georges.racinet@octobus.net> # Date 1695238037 -7200 # Wed Sep 20 21:27:17 2023 +0200 # Node ID eef65d4bfe4227236fcf35c09b3048eab2bc8d24 # Parent 60137290214a60beb5899af9ab71e13b582394b1 CommitService.GetTreeEntries: remove root_oid Of course this requires an update of the base image, to get a Gitaly past the point when `root_oid` is removed from protocol. We could run locally the Comparison tests with 16.0.0, which is simpler to reference than an exact commit, so we'll try this. The length of the first response in `test_compare_get_tree_entries_pagination` by Gitaly changes, perhaps because each `TreeEntry` is a bit smaller (we've long suspected the streaming logic was based on actual size hints), but we did not check that. Closes #151 diff --git a/hgitaly/service/commit.py b/hgitaly/service/commit.py --- a/hgitaly/service/commit.py +++ b/hgitaly/service/commit.py @@ -366,7 +366,6 @@ blob_type = TreeEntry.EntryType.BLOB tree_type = TreeEntry.EntryType.TREE - root_oid = tree_oid(repo, sha, b'') miner = manifest.miner(changeset) if request.recursive: @@ -441,7 +440,6 @@ type=tree_type if is_dir else blob_type, oid=entry_oid(path, is_dir), commit_oid=revision, - root_oid=root_oid, mode=(OBJECT_MODE_TREE if is_dir else git_perms(changeset.filectx(path))), flat_path=flat_path, diff --git a/hgitaly/service/tests/test_commit.py b/hgitaly/service/tests/test_commit.py --- a/hgitaly/service/tests/test_commit.py +++ b/hgitaly/service/tests/test_commit.py @@ -26,7 +26,6 @@ ) from hgitaly.oid import ( - tree_oid, blob_oid, ) @@ -930,27 +929,23 @@ ctx1_oid = ctx1.hex().decode() sha1 = ctx1.hex() - root1_oid = tree_oid(repo, ctx1_oid, b'') bar_default = TreeEntry(path=b'sub/bar', flat_path=b'sub/bar', mode=0o100644, oid=blob_oid(repo, ctx1_oid, b'sub/bar'), commit_oid=ctx1_oid, - root_oid=root1_oid, ) ba2_default = TreeEntry(path=b'sub/ba2', flat_path=b'sub/ba2', mode=0o100755, oid=blob_oid(repo, ctx1_oid, b'sub/ba2'), commit_oid=ctx1_oid, - root_oid=root1_oid, ) foo_default = TreeEntry(path=b'foo', flat_path=b'foo', mode=0o100644, oid=blob_oid(repo, ctx1_oid, b'foo'), commit_oid=ctx1_oid, - root_oid=root1_oid, ) sub_default = TreeEntry(path=b'sub', flat_path=b'sub', @@ -958,7 +953,6 @@ type=TreeEntry.EntryType.TREE, oid=blob_oid(repo, ctx1_oid, b'sub'), commit_oid=ctx1_oid, - root_oid=root1_oid, ) # unknown revision gives empty response instead of an error, diff --git a/rust/rhgitaly/proto/commit.proto b/rust/rhgitaly/proto/commit.proto --- a/rust/rhgitaly/proto/commit.proto +++ b/rust/rhgitaly/proto/commit.proto @@ -275,8 +275,6 @@ // OID of the object this tree entry points to string oid = 1; - // OID of the tree attached to commit_oid - string root_oid = 2; // Path relative to repository root bytes path = 3; // This comment is left unintentionally blank. @@ -287,6 +285,11 @@ string commit_oid = 6; // Relative path of the first subdir that doesn't have only one directory descendant bytes flat_path = 7; + + // RootOid used to refer to the resolved object ID of the root tree. This field has been removed + // with no replacement. + reserved "root_oid"; + reserved 2; } // This comment is left unintentionally blank. diff --git a/rust/rhgitaly/src/mercurial.rs b/rust/rhgitaly/src/mercurial.rs --- a/rust/rhgitaly/src/mercurial.rs +++ b/rust/rhgitaly/src/mercurial.rs @@ -402,7 +402,6 @@ /// often something like `branch/default` and not a real OID commit_oid: String, changeset_node: Node, - root_oid: String, manifest_dir_iter: ManifestDirIterator<'a, 'm, IM>, current_subdir: &'m [u8], } @@ -412,11 +411,9 @@ IM: Iterator<Item = Result<ManifestEntry<'m>, HgError>>, { pub fn new(commit_oid: String, changeset_node: Node, manifest: IM, path: &'a [u8]) -> Self { - let root_oid = tree_oid(&changeset_node, b""); Self { commit_oid, changeset_node, - root_oid, manifest_dir_iter: ManifestDirIterator::new(manifest, path), current_subdir: &[], } @@ -433,7 +430,6 @@ oid, mode, commit_oid: self.commit_oid.clone(), - root_oid: self.root_oid.clone(), path: path.to_vec(), r#type: obj_type as i32, flat_path: Vec::new(), @@ -498,7 +494,6 @@ /// often something like `branch/default` and not a real OID commit_oid: String, changeset_node: Node, - root_oid: String, manifest_dir_iter: ManifestDirIterator<'a, 'm, IM>, current_subdir: &'m [u8], to_yield: VecDeque<Result<TreeEntry, HgError>>, @@ -509,11 +504,9 @@ IM: Iterator<Item = Result<ManifestEntry<'m>, HgError>>, { pub fn new(commit_oid: String, changeset_node: Node, manifest: IM, path: &'a [u8]) -> Self { - let root_oid = tree_oid(&changeset_node, b""); Self { commit_oid, changeset_node, - root_oid, manifest_dir_iter: ManifestDirIterator::new(manifest, path), current_subdir: "".as_ref(), /// Queue of `TreeEntry` messages that have to be emitted. @@ -539,7 +532,6 @@ oid, mode, commit_oid: self.commit_oid.clone(), - root_oid: self.root_oid.clone(), path: path.to_vec(), r#type: obj_type as i32, flat_path: Vec::new(), // resulting flat_path is always default for recursive queries @@ -612,7 +604,6 @@ /// often something like `branch/default` and not a real OID commit_oid: String, changeset_node: Node, - root_oid: String, manifest_dir_iter: ManifestDirIterator<'a, 'm, IM>, /// This iterator also has the potential to yield several elements for a single /// read manifest entry, however this queue is overvill, because it can at most yield two @@ -625,11 +616,9 @@ IM: Iterator<Item = Result<ManifestEntry<'m>, HgError>>, { pub fn new(commit_oid: String, changeset_node: Node, manifest: IM, path: &'a [u8]) -> Self { - let root_oid = tree_oid(&changeset_node, b""); Self { commit_oid, changeset_node, - root_oid, manifest_dir_iter: ManifestDirIterator::new(manifest, path), /// Queue of `TreeEntry` messages that have to be emitted. /// @@ -651,7 +640,6 @@ oid: tree_oid(&self.changeset_node, &path), mode: git::OBJECT_MODE_TREE, commit_oid: self.commit_oid.clone(), - root_oid: self.root_oid.clone(), path, r#type: EntryType::Tree as i32, flat_path, @@ -663,7 +651,6 @@ mode, oid: blob_oid(&self.changeset_node, path), commit_oid: self.commit_oid.clone(), - root_oid: self.root_oid.clone(), path: path.to_vec(), r#type: EntryType::Blob as i32, flat_path: path.to_vec(), @@ -923,7 +910,6 @@ r#type: EntryType::Blob as i32, mode: git::OBJECT_MODE_NON_EXECUTABLE, commit_oid: "branch/test".to_owned(), - root_oid: tree_oid(cs_node, b""), oid: blob_oid(cs_node, path), flat_path: flat_path.to_vec(), } @@ -939,7 +925,6 @@ r#type: EntryType::Tree as i32, mode: git::OBJECT_MODE_TREE, commit_oid: "branch/test".to_owned(), - root_oid: tree_oid(cs_node, b""), oid: tree_oid(cs_node, path), flat_path: flat_path.to_vec(), } diff --git a/tests_with_gitaly/test_blob_tree.py b/tests_with_gitaly/test_blob_tree.py --- a/tests_with_gitaly/test_blob_tree.py +++ b/tests_with_gitaly/test_blob_tree.py @@ -182,7 +182,6 @@ for entry in resp.entries: if entry.oid and vcs == 'hg': entry.oid = oid2git[entry.oid] - entry.root_oid = b'' rpc_helper = fixture.rpc_helper(stub_cls=CommitServiceStub, hg_server=hg_server, @@ -249,7 +248,8 @@ sub.mkdir() rel_paths = [] # Chunk size with Gitaly is big - for x in range(2900): + nb_files = 3270 + for x in range(nb_files): # max file name length is 255 on most filesystems path = sub / ('very-' * 46 + '-long-filename-bar%04d' % x) path.write_text(str(x)) @@ -262,7 +262,7 @@ def normalizer(rpc_helper, responses, **kw): for resp in responses: for entry in resp.entries: - entry.oid = entry.root_oid = b'' + entry.oid = b'' resp.pagination_cursor.next_cursor = '' def concat_entries(responses): @@ -313,7 +313,7 @@ first_resps = assert_compare_aggregated( path=b'sub', recursive=True, - pagination_params=PaginationParameter(limit=2890), + pagination_params=PaginationParameter(limit=nb_files - 2), compare_first_chunks=False, )