2022-11-26 23:57:50 +00:00
|
|
|
// Copyright 2021 The Jujutsu Authors
|
2021-04-05 05:56:10 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2022-10-23 04:14:00 +00:00
|
|
|
use std::path::Path;
|
|
|
|
|
2022-12-31 08:25:40 +00:00
|
|
|
use assert_matches::assert_matches;
|
2023-03-14 05:14:06 +00:00
|
|
|
use itertools::Itertools;
|
2023-01-01 03:24:32 +00:00
|
|
|
use jujutsu_lib::backend::{CommitId, MillisSinceEpoch, ObjectId, Signature, Timestamp};
|
2023-03-22 19:47:46 +00:00
|
|
|
use jujutsu_lib::commit::Commit;
|
2022-11-08 12:35:16 +00:00
|
|
|
use jujutsu_lib::git;
|
2021-11-26 07:18:43 +00:00
|
|
|
use jujutsu_lib::op_store::{RefTarget, WorkspaceId};
|
2023-02-13 17:52:21 +00:00
|
|
|
use jujutsu_lib::repo::Repo;
|
2022-09-13 06:39:06 +00:00
|
|
|
use jujutsu_lib::repo_path::RepoPath;
|
2022-10-23 03:41:50 +00:00
|
|
|
use jujutsu_lib::revset::{
|
2023-03-22 19:47:46 +00:00
|
|
|
optimize, parse, resolve_symbol, resolve_symbols, ReverseRevsetGraphIterator, Revset,
|
|
|
|
RevsetAliasesMap, RevsetError, RevsetExpression, RevsetFilterPredicate, RevsetGraphEdge,
|
|
|
|
RevsetIteratorExt, RevsetWorkspaceContext,
|
2022-10-23 03:41:50 +00:00
|
|
|
};
|
2022-12-13 00:18:19 +00:00
|
|
|
use jujutsu_lib::settings::GitSettings;
|
2022-10-23 06:51:44 +00:00
|
|
|
use jujutsu_lib::workspace::Workspace;
|
2021-04-05 05:56:10 +00:00
|
|
|
use test_case::test_case;
|
2022-12-24 15:38:20 +00:00
|
|
|
use testutils::{
|
|
|
|
create_random_commit, write_random_commit, CommitGraphBuilder, TestRepo, TestWorkspace,
|
|
|
|
};
|
2021-04-05 05:56:10 +00:00
|
|
|
|
2023-03-22 19:47:46 +00:00
|
|
|
fn revset_for_commits<'index>(
|
|
|
|
repo: &'index dyn Repo,
|
|
|
|
commits: &[&Commit],
|
|
|
|
) -> Box<dyn Revset<'index> + 'index> {
|
|
|
|
RevsetExpression::commits(commits.iter().map(|commit| commit.id().clone()).collect())
|
|
|
|
.evaluate(repo)
|
|
|
|
.unwrap()
|
|
|
|
}
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-05 05:56:10 +00:00
|
|
|
fn test_resolve_symbol_root(use_git: bool) {
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-05 05:56:10 +00:00
|
|
|
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(repo.as_ref(), "root", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Ok(v) if v == vec![repo.store().root_commit_id().clone()]
|
2021-04-05 05:56:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_resolve_symbol_commit_id() {
|
|
|
|
let settings = testutils::user_settings();
|
|
|
|
// Test only with git so we can get predictable commit ids
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(true);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-05 05:56:10 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-05 05:56:10 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
let signature = Signature {
|
|
|
|
name: "test".to_string(),
|
|
|
|
email: "test".to_string(),
|
|
|
|
timestamp: Timestamp {
|
|
|
|
timestamp: MillisSinceEpoch(0),
|
|
|
|
tz_offset: 0,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut commits = vec![];
|
|
|
|
for i in &[1, 167, 895] {
|
2022-12-25 16:36:13 +00:00
|
|
|
let commit = mut_repo
|
|
|
|
.new_commit(
|
|
|
|
&settings,
|
|
|
|
vec![repo.store().root_commit_id().clone()],
|
|
|
|
repo.store().empty_tree_id().clone(),
|
|
|
|
)
|
|
|
|
.set_description(format!("test {i}"))
|
|
|
|
.set_author(signature.clone())
|
|
|
|
.set_committer(signature.clone())
|
|
|
|
.write()
|
|
|
|
.unwrap();
|
2021-04-05 05:56:10 +00:00
|
|
|
commits.push(commit);
|
|
|
|
}
|
2021-07-30 21:35:08 +00:00
|
|
|
let repo = tx.commit();
|
2021-04-05 05:56:10 +00:00
|
|
|
|
|
|
|
// Test the test setup
|
|
|
|
assert_eq!(
|
|
|
|
commits[0].id().hex(),
|
|
|
|
"0454de3cae04c46cda37ba2e8873b4c17ff51dcb"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
commits[1].id().hex(),
|
|
|
|
"045f56cd1b17e8abde86771e2705395dcde6a957"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
commits[2].id().hex(),
|
|
|
|
"0468f7da8de2ce442f512aacf83411d26cd2e0cf"
|
|
|
|
);
|
|
|
|
|
2023-01-14 07:46:30 +00:00
|
|
|
// Change ids should never have prefix "04"
|
|
|
|
insta::assert_snapshot!(commits[0].change_id().hex(), @"781199f9d55d18e855a7aa84c5e4b40d");
|
|
|
|
insta::assert_snapshot!(commits[1].change_id().hex(), @"a2c96fc88f32e487328f04927f20c4b1");
|
|
|
|
insta::assert_snapshot!(commits[2].change_id().hex(), @"4399e4f3123763dfe7d68a2809ecc01b");
|
|
|
|
|
2021-04-05 05:56:10 +00:00
|
|
|
// Test lookup by full commit id
|
|
|
|
assert_eq!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(
|
|
|
|
repo.as_ref(),
|
|
|
|
"0454de3cae04c46cda37ba2e8873b4c17ff51dcb",
|
|
|
|
None
|
|
|
|
)
|
|
|
|
.unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commits[0].id().clone()]
|
2021-04-05 05:56:10 +00:00
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(
|
|
|
|
repo.as_ref(),
|
|
|
|
"045f56cd1b17e8abde86771e2705395dcde6a957",
|
|
|
|
None
|
|
|
|
)
|
|
|
|
.unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commits[1].id().clone()]
|
2021-04-05 05:56:10 +00:00
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(
|
|
|
|
repo.as_ref(),
|
|
|
|
"0468f7da8de2ce442f512aacf83411d26cd2e0cf",
|
|
|
|
None
|
|
|
|
)
|
|
|
|
.unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commits[2].id().clone()]
|
2021-04-05 05:56:10 +00:00
|
|
|
);
|
|
|
|
|
2022-11-20 03:06:09 +00:00
|
|
|
// Test empty commit id
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(repo.as_ref(), "", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::AmbiguousIdPrefix(s)) if s.is_empty()
|
2022-11-20 03:06:09 +00:00
|
|
|
);
|
|
|
|
|
2021-04-05 05:56:10 +00:00
|
|
|
// Test commit id prefix
|
2021-05-30 17:26:23 +00:00
|
|
|
assert_eq!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(repo.as_ref(), "046", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commits[2].id().clone()]
|
2021-05-30 17:26:23 +00:00
|
|
|
);
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(repo.as_ref(), "04", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::AmbiguousIdPrefix(s)) if s == "04"
|
2021-04-05 05:56:10 +00:00
|
|
|
);
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(repo.as_ref(), "", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::AmbiguousIdPrefix(s)) if s.is_empty()
|
2021-04-05 05:56:10 +00:00
|
|
|
);
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(repo.as_ref(), "040", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::NoSuchRevision(s)) if s == "040"
|
2021-04-05 05:56:10 +00:00
|
|
|
);
|
|
|
|
|
2021-04-10 06:51:37 +00:00
|
|
|
// Test non-hex string
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbol(repo.as_ref(), "foo", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::NoSuchRevision(s)) if s == "foo"
|
2021-04-10 06:51:37 +00:00
|
|
|
);
|
2022-11-07 07:29:35 +00:00
|
|
|
|
|
|
|
// Test present() suppresses only NoSuchRevision error
|
2023-03-21 06:02:29 +00:00
|
|
|
assert_eq!(resolve_commit_ids(repo.as_ref(), "present(foo)"), []);
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_symbols(repo.as_ref(), optimize(parse("present(04)", &RevsetAliasesMap::new(), None).unwrap()), None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::AmbiguousIdPrefix(s)) if s == "04"
|
2022-11-07 07:29:35 +00:00
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-03-21 06:02:29 +00:00
|
|
|
resolve_commit_ids(repo.as_ref(), "present(046)"),
|
2022-11-07 07:29:35 +00:00
|
|
|
vec![commits[2].id().clone()]
|
|
|
|
);
|
2021-04-05 05:56:10 +00:00
|
|
|
}
|
|
|
|
|
2023-01-25 08:58:20 +00:00
|
|
|
#[test_case(false ; "mutable")]
|
|
|
|
#[test_case(true ; "readonly")]
|
|
|
|
fn test_resolve_symbol_change_id(readonly: bool) {
|
2022-11-13 06:29:06 +00:00
|
|
|
let settings = testutils::user_settings();
|
2022-12-13 00:18:19 +00:00
|
|
|
let git_settings = GitSettings::default();
|
2021-05-30 06:52:50 +00:00
|
|
|
// Test only with git so we can get predictable change ids
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(true);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-05-30 06:52:50 +00:00
|
|
|
|
|
|
|
let git_repo = repo.store().git_repo().unwrap();
|
|
|
|
// Add some commits that will end up having change ids with common prefixes
|
|
|
|
let empty_tree_id = git_repo.treebuilder(None).unwrap().write().unwrap();
|
|
|
|
let git_author = git2::Signature::new(
|
|
|
|
"git author",
|
|
|
|
"git.author@example.com",
|
|
|
|
&git2::Time::new(1000, 60),
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
let git_committer = git2::Signature::new(
|
|
|
|
"git committer",
|
|
|
|
"git.committer@example.com",
|
|
|
|
&git2::Time::new(2000, -480),
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
let git_tree = git_repo.find_tree(empty_tree_id).unwrap();
|
|
|
|
let mut git_commit_ids = vec![];
|
2022-11-27 09:39:35 +00:00
|
|
|
for i in &[133, 664, 840, 5085] {
|
2021-05-30 06:52:50 +00:00
|
|
|
let git_commit_id = git_repo
|
|
|
|
.commit(
|
2022-12-15 02:30:06 +00:00
|
|
|
Some(&format!("refs/heads/branch{i}")),
|
2021-05-30 06:52:50 +00:00
|
|
|
&git_author,
|
|
|
|
&git_committer,
|
2022-12-15 02:30:06 +00:00
|
|
|
&format!("test {i}"),
|
2021-05-30 06:52:50 +00:00
|
|
|
&git_tree,
|
|
|
|
&[],
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
git_commit_ids.push(git_commit_id);
|
|
|
|
}
|
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2022-12-13 00:18:19 +00:00
|
|
|
git::import_refs(tx.mut_repo(), &git_repo, &git_settings).unwrap();
|
2021-05-30 06:52:50 +00:00
|
|
|
|
|
|
|
// Test the test setup
|
|
|
|
assert_eq!(
|
2021-11-17 22:20:54 +00:00
|
|
|
hex::encode(git_commit_ids[0]),
|
2021-05-30 06:52:50 +00:00
|
|
|
// "04e12a5467bba790efb88a9870894ec208b16bf1" reversed
|
|
|
|
"8fd68d104372910e19511df709e5dde62a548720"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2021-11-17 22:20:54 +00:00
|
|
|
hex::encode(git_commit_ids[1]),
|
2021-05-30 06:52:50 +00:00
|
|
|
// "040b3ba3a51d8edbc4c5855cbd09de71d4c29cca" reversed
|
|
|
|
"5339432b8e7b90bd3aa1a323db71b8a5c5dcd020"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2021-11-17 22:20:54 +00:00
|
|
|
hex::encode(git_commit_ids[2]),
|
2021-05-30 06:52:50 +00:00
|
|
|
// "04e1c7082e4e34f3f371d8a1a46770b861b9b547" reversed
|
|
|
|
"e2ad9d861d0ee625851b8ecfcf2c727410e38720"
|
|
|
|
);
|
2022-11-27 09:39:35 +00:00
|
|
|
assert_eq!(
|
|
|
|
hex::encode(git_commit_ids[3]),
|
|
|
|
// "911d7e52fd5ba04b8f289e14c3d30b52d38c0020" reversed
|
|
|
|
"040031cb4ad0cbc3287914f1d205dabf4a7eb889"
|
|
|
|
);
|
2021-05-30 06:52:50 +00:00
|
|
|
|
2023-02-13 17:52:21 +00:00
|
|
|
let _readonly_repo;
|
|
|
|
let repo: &dyn Repo = if readonly {
|
|
|
|
_readonly_repo = tx.commit();
|
2023-03-21 06:02:29 +00:00
|
|
|
_readonly_repo.as_ref()
|
2023-01-25 08:58:20 +00:00
|
|
|
} else {
|
2023-02-13 17:52:21 +00:00
|
|
|
tx.mut_repo()
|
2023-01-25 08:58:20 +00:00
|
|
|
};
|
|
|
|
|
2021-05-30 06:52:50 +00:00
|
|
|
// Test lookup by full change id
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "zvlyxpuvtsoopsqzlkorrpqrszrqvlnx", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![CommitId::from_hex(
|
2021-05-30 06:52:50 +00:00
|
|
|
"8fd68d104372910e19511df709e5dde62a548720"
|
2022-12-31 08:25:40 +00:00
|
|
|
)]
|
2021-05-30 06:52:50 +00:00
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "zvzowopwpuymrlmonvnuruunomzqmlsy", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![CommitId::from_hex(
|
2021-05-30 06:52:50 +00:00
|
|
|
"5339432b8e7b90bd3aa1a323db71b8a5c5dcd020"
|
2022-12-31 08:25:40 +00:00
|
|
|
)]
|
2021-05-30 06:52:50 +00:00
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "zvlynszrxlvlwvkwkwsymrpypvtsszor", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![CommitId::from_hex(
|
2021-05-30 06:52:50 +00:00
|
|
|
"e2ad9d861d0ee625851b8ecfcf2c727410e38720"
|
2022-12-31 08:25:40 +00:00
|
|
|
)]
|
2021-05-30 06:52:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Test change id prefix
|
2023-02-12 18:21:29 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "zvlyx", None).unwrap(),
|
2023-02-12 18:21:29 +00:00
|
|
|
vec![CommitId::from_hex(
|
|
|
|
"8fd68d104372910e19511df709e5dde62a548720"
|
|
|
|
)]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "zvlyn", None).unwrap(),
|
2023-02-12 18:21:29 +00:00
|
|
|
vec![CommitId::from_hex(
|
|
|
|
"e2ad9d861d0ee625851b8ecfcf2c727410e38720"
|
|
|
|
)]
|
|
|
|
);
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "zvly", None),
|
2023-02-13 04:21:34 +00:00
|
|
|
Err(RevsetError::AmbiguousIdPrefix(s)) if s == "zvly"
|
2021-05-30 06:52:50 +00:00
|
|
|
);
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::AmbiguousIdPrefix(s)) if s.is_empty()
|
2021-05-30 06:52:50 +00:00
|
|
|
);
|
2023-02-12 18:21:29 +00:00
|
|
|
assert_matches!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "zvlyw", None),
|
2023-02-12 18:21:29 +00:00
|
|
|
Err(RevsetError::NoSuchRevision(s)) if s == "zvlyw"
|
|
|
|
);
|
2022-11-27 09:39:35 +00:00
|
|
|
|
2023-02-13 04:21:34 +00:00
|
|
|
// Test that commit and changed id don't conflict ("040" and "zvz" are the
|
|
|
|
// same).
|
2022-11-27 09:39:35 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "040", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![CommitId::from_hex(
|
2023-02-13 04:21:34 +00:00
|
|
|
"040031cb4ad0cbc3287914f1d205dabf4a7eb889"
|
2022-12-31 08:25:40 +00:00
|
|
|
)]
|
2022-11-27 09:39:35 +00:00
|
|
|
);
|
2023-02-12 18:21:29 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "zvz", None).unwrap(),
|
2023-02-12 18:21:29 +00:00
|
|
|
vec![CommitId::from_hex(
|
|
|
|
"5339432b8e7b90bd3aa1a323db71b8a5c5dcd020"
|
|
|
|
)]
|
|
|
|
);
|
|
|
|
|
2021-05-30 06:52:50 +00:00
|
|
|
// Test non-hex string
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(repo, "foo", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::NoSuchRevision(s)) if s == "foo"
|
2021-05-30 06:52:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-05 05:56:10 +00:00
|
|
|
fn test_resolve_symbol_checkout(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-05 05:56:10 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-05 05:56:10 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
2022-12-24 15:38:20 +00:00
|
|
|
let commit1 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit2 = write_random_commit(mut_repo, &settings);
|
2021-04-05 05:56:10 +00:00
|
|
|
|
2022-02-02 16:15:25 +00:00
|
|
|
let ws1 = WorkspaceId::new("ws1".to_string());
|
|
|
|
let ws2 = WorkspaceId::new("ws2".to_string());
|
|
|
|
|
|
|
|
// With no workspaces, no variation can be resolved
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "@", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::NoSuchRevision(s)) if s == "@"
|
2022-02-02 16:15:25 +00:00
|
|
|
);
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "@", Some(&ws1)),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::NoSuchRevision(s)) if s == "@"
|
2022-02-02 16:15:25 +00:00
|
|
|
);
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "ws1@", Some(&ws1)),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::NoSuchRevision(s)) if s == "ws1@"
|
2022-02-02 16:15:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Add some workspaces
|
2022-10-20 23:33:14 +00:00
|
|
|
mut_repo
|
|
|
|
.set_wc_commit(ws1.clone(), commit1.id().clone())
|
|
|
|
.unwrap();
|
|
|
|
mut_repo.set_wc_commit(ws2, commit2.id().clone()).unwrap();
|
2022-02-02 16:15:25 +00:00
|
|
|
// @ cannot be resolved without a default workspace ID
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "@", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::NoSuchRevision(s)) if s == "@"
|
2022-02-02 16:15:25 +00:00
|
|
|
);
|
|
|
|
// Can resolve "@" shorthand with a default workspace ID
|
2021-04-05 05:56:10 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "@", Some(&ws1)).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commit1.id().clone()]
|
2021-04-05 05:56:10 +00:00
|
|
|
);
|
2022-02-02 16:15:25 +00:00
|
|
|
// Can resolve an explicit checkout
|
2021-04-05 05:56:10 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "ws2@", Some(&ws1)).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commit2.id().clone()]
|
2021-04-05 05:56:10 +00:00
|
|
|
);
|
|
|
|
}
|
2021-04-10 06:40:52 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_resolve_symbol_git_refs() {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(true);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-10 06:40:52 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-10 06:40:52 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
|
|
|
// Create some commits and refs to work with and so the repo is not empty
|
2022-12-24 15:38:20 +00:00
|
|
|
let commit1 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit2 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit3 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit4 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit5 = write_random_commit(mut_repo, &settings);
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/heads/branch1".to_string(),
|
|
|
|
RefTarget::Normal(commit1.id().clone()),
|
|
|
|
);
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/heads/branch2".to_string(),
|
|
|
|
RefTarget::Normal(commit2.id().clone()),
|
|
|
|
);
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/heads/conflicted".to_string(),
|
|
|
|
RefTarget::Conflict {
|
|
|
|
removes: vec![commit2.id().clone()],
|
|
|
|
adds: vec![commit1.id().clone(), commit3.id().clone()],
|
|
|
|
},
|
|
|
|
);
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/tags/tag1".to_string(),
|
|
|
|
RefTarget::Normal(commit2.id().clone()),
|
|
|
|
);
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-04-10 06:40:52 +00:00
|
|
|
"refs/tags/remotes/origin/branch1".to_string(),
|
2021-07-11 17:58:01 +00:00
|
|
|
RefTarget::Normal(commit3.id().clone()),
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
|
2022-09-09 17:31:43 +00:00
|
|
|
// Nonexistent ref
|
2022-12-31 08:25:40 +00:00
|
|
|
assert_matches!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "nonexistent", None),
|
2022-12-31 08:25:40 +00:00
|
|
|
Err(RevsetError::NoSuchRevision(s)) if s == "nonexistent"
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Full ref
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/heads/branch".to_string(),
|
|
|
|
RefTarget::Normal(commit4.id().clone()),
|
|
|
|
);
|
2021-04-10 06:40:52 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "refs/heads/branch", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commit4.id().clone()]
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Qualified with only heads/
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/heads/branch".to_string(),
|
|
|
|
RefTarget::Normal(commit5.id().clone()),
|
|
|
|
);
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/tags/branch".to_string(),
|
|
|
|
RefTarget::Normal(commit4.id().clone()),
|
|
|
|
);
|
2021-04-10 06:40:52 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "heads/branch", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commit5.id().clone()]
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Unqualified branch name
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/heads/branch".to_string(),
|
|
|
|
RefTarget::Normal(commit3.id().clone()),
|
|
|
|
);
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/tags/branch".to_string(),
|
|
|
|
RefTarget::Normal(commit4.id().clone()),
|
|
|
|
);
|
2021-04-10 06:40:52 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "branch", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commit3.id().clone()]
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Unqualified tag name
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/tags/tag".to_string(),
|
|
|
|
RefTarget::Normal(commit4.id().clone()),
|
|
|
|
);
|
2021-04-10 06:40:52 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "tag", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commit4.id().clone()]
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Unqualified remote-tracking branch name
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-04-10 06:40:52 +00:00
|
|
|
"refs/remotes/origin/remote-branch".to_string(),
|
2021-07-11 17:58:01 +00:00
|
|
|
RefTarget::Normal(commit2.id().clone()),
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "origin/remote-branch", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commit2.id().clone()]
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Cannot shadow checkout ("@") or root symbols
|
2022-02-05 23:02:16 +00:00
|
|
|
let ws_id = WorkspaceId::default();
|
2022-10-20 23:33:14 +00:00
|
|
|
mut_repo
|
|
|
|
.set_wc_commit(ws_id.clone(), commit1.id().clone())
|
|
|
|
.unwrap();
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref("@".to_string(), RefTarget::Normal(commit2.id().clone()));
|
|
|
|
mut_repo.set_git_ref("root".to_string(), RefTarget::Normal(commit3.id().clone()));
|
2021-04-10 06:40:52 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "@", Some(&ws_id)).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![mut_repo.view().get_wc_commit_id(&ws_id).unwrap().clone()]
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "root", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![mut_repo.store().root_commit().id().clone()]
|
2021-04-10 06:40:52 +00:00
|
|
|
);
|
|
|
|
|
2021-07-11 17:58:01 +00:00
|
|
|
// Conflicted ref resolves to its "adds"
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_symbol(mut_repo, "refs/heads/conflicted", None).unwrap(),
|
2022-12-31 08:25:40 +00:00
|
|
|
vec![commit1.id().clone(), commit3.id().clone()]
|
2021-07-11 17:58:01 +00:00
|
|
|
);
|
2021-04-10 06:40:52 +00:00
|
|
|
}
|
2021-04-10 17:18:30 +00:00
|
|
|
|
2023-02-13 17:52:21 +00:00
|
|
|
fn resolve_commit_ids(repo: &dyn Repo, revset_str: &str) -> Vec<CommitId> {
|
2022-11-25 03:53:01 +00:00
|
|
|
let expression = optimize(parse(revset_str, &RevsetAliasesMap::new(), None).unwrap());
|
revset: resolve symbols earlier, before passing to revset engine
For large repos, it's useful to be able to use shorter change id and
commit id prefixes by resolving the prefix in a limited subset of the
repo (typically the same subset that you'd want to see in your default
log output). For very large repos, like Google's internal one, the
shortest unique prefix evaluated within the whole repo is practically
useless because it's long enough that the user would want to copy and
paste it anyway.
Mercurial supports this with its `revisions.disambiguatewithin` config
(added in https://www.mercurial-scm.org/repo/hg/rev/503f936489dd). I'd
like to add the same feature to jj. Mercurial's implementation works
by attempting to resolve the prefix in the whole repo and then, if the
prefix was ambiguous, it resolves it in the configured subset
instead. The advantage of doing it that way is that there's no extra
cost of resolving the revset defining the subset if the prefix was not
ambiguous within the whole repo. However, there are two important
reasons to do it differently in jj:
* We support very large repos using custom backends, and it's probably
cheaper to resolve a prefix within the subset because it can all be
cached on the client. Resolving the prefix within the whole repo
requires a roundtrip to the server.
* We want to be able to resolve change id prefixes, which is always
done in *some* revset. That revset is currently `all()`, i.e. all
visible commits. Even on local disk, it's probably cheaper to
resolve a small revset first and then resolve the prefix within that
than it is to build up the index of all visible change ids.
We could achieve the goal by letting each revset engine respect the
configured subset, but since the solution proposed above makes sense
also for local-disk repos, I think it's better to do it outside of the
revset engine, so all revset engines can share the code.
This commit prepares for the new functionality by moving the symbol
resolution out of `Index::evaluate_revset()`.
2023-03-16 17:03:47 +00:00
|
|
|
let expression = resolve_symbols(repo, expression, None).unwrap();
|
2021-05-28 15:37:06 +00:00
|
|
|
expression
|
2023-03-17 18:01:00 +00:00
|
|
|
.evaluate(repo)
|
2022-02-02 16:15:25 +00:00
|
|
|
.unwrap()
|
|
|
|
.iter()
|
|
|
|
.commit_ids()
|
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn resolve_commit_ids_in_workspace(
|
2023-02-13 17:52:21 +00:00
|
|
|
repo: &dyn Repo,
|
2022-02-02 16:15:25 +00:00
|
|
|
revset_str: &str,
|
2022-10-23 06:51:44 +00:00
|
|
|
workspace: &Workspace,
|
2022-10-23 04:14:00 +00:00
|
|
|
cwd: Option<&Path>,
|
2022-02-02 16:15:25 +00:00
|
|
|
) -> Vec<CommitId> {
|
2022-10-23 06:51:44 +00:00
|
|
|
let workspace_ctx = RevsetWorkspaceContext {
|
2022-10-23 04:14:00 +00:00
|
|
|
cwd: cwd.unwrap_or_else(|| workspace.workspace_root()),
|
2022-10-23 06:51:44 +00:00
|
|
|
workspace_id: workspace.workspace_id(),
|
2022-10-23 04:14:00 +00:00
|
|
|
workspace_root: workspace.workspace_root(),
|
2022-10-23 06:51:44 +00:00
|
|
|
};
|
2022-11-25 03:53:01 +00:00
|
|
|
let expression =
|
|
|
|
optimize(parse(revset_str, &RevsetAliasesMap::new(), Some(&workspace_ctx)).unwrap());
|
revset: resolve symbols earlier, before passing to revset engine
For large repos, it's useful to be able to use shorter change id and
commit id prefixes by resolving the prefix in a limited subset of the
repo (typically the same subset that you'd want to see in your default
log output). For very large repos, like Google's internal one, the
shortest unique prefix evaluated within the whole repo is practically
useless because it's long enough that the user would want to copy and
paste it anyway.
Mercurial supports this with its `revisions.disambiguatewithin` config
(added in https://www.mercurial-scm.org/repo/hg/rev/503f936489dd). I'd
like to add the same feature to jj. Mercurial's implementation works
by attempting to resolve the prefix in the whole repo and then, if the
prefix was ambiguous, it resolves it in the configured subset
instead. The advantage of doing it that way is that there's no extra
cost of resolving the revset defining the subset if the prefix was not
ambiguous within the whole repo. However, there are two important
reasons to do it differently in jj:
* We support very large repos using custom backends, and it's probably
cheaper to resolve a prefix within the subset because it can all be
cached on the client. Resolving the prefix within the whole repo
requires a roundtrip to the server.
* We want to be able to resolve change id prefixes, which is always
done in *some* revset. That revset is currently `all()`, i.e. all
visible commits. Even on local disk, it's probably cheaper to
resolve a small revset first and then resolve the prefix within that
than it is to build up the index of all visible change ids.
We could achieve the goal by letting each revset engine respect the
configured subset, but since the solution proposed above makes sense
also for local-disk repos, I think it's better to do it outside of the
revset engine, so all revset engines can share the code.
This commit prepares for the new functionality by moving the symbol
resolution out of `Index::evaluate_revset()`.
2023-03-16 17:03:47 +00:00
|
|
|
let expression = resolve_symbols(repo, expression, Some(&workspace_ctx)).unwrap();
|
2022-02-02 16:15:25 +00:00
|
|
|
expression
|
2023-03-17 18:01:00 +00:00
|
|
|
.evaluate(repo)
|
2021-04-10 17:18:30 +00:00
|
|
|
.unwrap()
|
|
|
|
.iter()
|
2021-10-06 20:53:38 +00:00
|
|
|
.commit_ids()
|
2021-04-10 17:18:30 +00:00
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-10 17:18:30 +00:00
|
|
|
fn test_evaluate_expression_root_and_checkout(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-10-23 06:51:44 +00:00
|
|
|
let test_workspace = TestWorkspace::init(&settings, use_git);
|
|
|
|
let repo = &test_workspace.repo;
|
2021-04-10 17:18:30 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-10 17:18:30 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
|
|
|
let root_commit = repo.store().root_commit();
|
2022-12-24 15:38:20 +00:00
|
|
|
let commit1 = write_random_commit(mut_repo, &settings);
|
2021-04-10 17:18:30 +00:00
|
|
|
|
|
|
|
// Can find the root commit
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "root"),
|
2021-04-10 17:18:30 +00:00
|
|
|
vec![root_commit.id().clone()]
|
|
|
|
);
|
|
|
|
|
2023-01-25 16:29:15 +00:00
|
|
|
// Can find the current working-copy commit
|
2022-10-20 23:33:14 +00:00
|
|
|
mut_repo
|
|
|
|
.set_wc_commit(WorkspaceId::default(), commit1.id().clone())
|
|
|
|
.unwrap();
|
2021-04-10 17:18:30 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids_in_workspace(mut_repo, "@", &test_workspace.workspace, None),
|
2021-04-10 17:18:30 +00:00
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-10-10 19:30:00 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2022-04-13 20:27:00 +00:00
|
|
|
fn test_evaluate_expression_heads(use_git: bool) {
|
2021-10-10 19:30:00 +00:00
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-10-10 19:30:00 +00:00
|
|
|
|
|
|
|
let root_commit = repo.store().root_commit();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-10-10 19:30:00 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
|
|
|
|
|
|
|
// Heads of an empty set is an empty set
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "heads(none())"), vec![]);
|
2021-10-10 19:30:00 +00:00
|
|
|
|
|
|
|
// Heads of the root is the root
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "heads(root)"),
|
2021-10-10 19:30:00 +00:00
|
|
|
vec![root_commit.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Heads of a single commit is that commit
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!("heads({})", commit2.id().hex())),
|
2021-10-10 19:30:00 +00:00
|
|
|
vec![commit2.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Heads of a parent and a child is the child
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-10-10 19:30:00 +00:00
|
|
|
&format!("heads({} | {})", commit2.id().hex(), commit3.id().hex())
|
|
|
|
),
|
|
|
|
vec![commit3.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Heads of a grandparent and a grandchild is the grandchild (unlike Mercurial's
|
|
|
|
// heads() revset, which would include both)
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-10-10 19:30:00 +00:00
|
|
|
&format!("heads({} | {})", commit1.id().hex(), commit3.id().hex())
|
|
|
|
),
|
|
|
|
vec![commit3.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Heads of all commits is the set of heads in the repo
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "heads(all())"),
|
|
|
|
resolve_commit_ids(mut_repo, "heads()")
|
2021-10-10 19:30:00 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-04-13 20:55:47 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
|
|
|
fn test_evaluate_expression_roots(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-04-13 20:55:47 +00:00
|
|
|
let repo = &test_repo.repo;
|
|
|
|
|
|
|
|
let root_commit = repo.store().root_commit();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2022-04-13 20:55:47 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
|
|
|
|
|
|
|
// Roots of an empty set is an empty set
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "roots(none())"), vec![]);
|
2022-04-13 20:55:47 +00:00
|
|
|
|
|
|
|
// Roots of the root is the root
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "roots(root)"),
|
2022-04-13 20:55:47 +00:00
|
|
|
vec![root_commit.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Roots of a single commit is that commit
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!("roots({})", commit2.id().hex())),
|
2022-04-13 20:55:47 +00:00
|
|
|
vec![commit2.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Roots of a parent and a child is the parent
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-04-13 20:55:47 +00:00
|
|
|
&format!("roots({} | {})", commit2.id().hex(), commit3.id().hex())
|
|
|
|
),
|
|
|
|
vec![commit2.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Roots of a grandparent and a grandchild is the grandparent (unlike
|
|
|
|
// Mercurial's roots() revset, which would include both)
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-04-13 20:55:47 +00:00
|
|
|
&format!("roots({} | {})", commit1.id().hex(), commit3.id().hex())
|
|
|
|
),
|
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Roots of all commits is the root commit
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "roots(all())"),
|
2022-04-13 20:55:47 +00:00
|
|
|
vec![root_commit.id().clone()]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-10 17:18:30 +00:00
|
|
|
fn test_evaluate_expression_parents(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-10-23 06:51:44 +00:00
|
|
|
let test_workspace = TestWorkspace::init(&settings, use_git);
|
|
|
|
let repo = &test_workspace.repo;
|
2021-04-10 17:18:30 +00:00
|
|
|
|
2021-05-01 04:41:27 +00:00
|
|
|
let root_commit = repo.store().root_commit();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-10 17:18:30 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-05-01 04:41:27 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.initial_commit();
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit2, &commit3]);
|
|
|
|
let commit5 = graph_builder.commit_with_parents(&[&commit2]);
|
2021-04-10 17:18:30 +00:00
|
|
|
|
|
|
|
// The root commit has no parents
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "root-"), vec![]);
|
2021-04-10 17:18:30 +00:00
|
|
|
|
2023-01-25 16:29:15 +00:00
|
|
|
// Can find parents of the current working-copy commit
|
2022-10-20 23:33:14 +00:00
|
|
|
mut_repo
|
|
|
|
.set_wc_commit(WorkspaceId::default(), commit2.id().clone())
|
|
|
|
.unwrap();
|
2021-04-10 17:18:30 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids_in_workspace(mut_repo, "@-", &test_workspace.workspace, None,),
|
2021-04-10 17:18:30 +00:00
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Can find parents of a merge commit
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!("{}-", commit4.id().hex())),
|
2021-04-18 22:09:29 +00:00
|
|
|
vec![commit3.id().clone(), commit2.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Parents of all commits in input are returned
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-13 06:40:16 +00:00
|
|
|
&format!("({} | {})-", commit2.id().hex(), commit3.id().hex())
|
2021-04-18 22:09:29 +00:00
|
|
|
),
|
|
|
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Parents already in input set are returned
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-13 06:40:16 +00:00
|
|
|
&format!("({} | {})-", commit1.id().hex(), commit2.id().hex())
|
2021-04-18 22:09:29 +00:00
|
|
|
),
|
|
|
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Parents shared among commits in input are not repeated
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-13 06:40:16 +00:00
|
|
|
&format!("({} | {})-", commit4.id().hex(), commit5.id().hex())
|
2021-04-18 22:09:29 +00:00
|
|
|
),
|
|
|
|
vec![commit3.id().clone(), commit2.id().clone()]
|
2021-04-10 17:18:30 +00:00
|
|
|
);
|
2022-12-09 13:55:59 +00:00
|
|
|
|
|
|
|
// Can find parents of parents, which may be optimized to single query
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!("{}--", commit4.id().hex())),
|
2022-12-09 13:55:59 +00:00
|
|
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-12-09 13:55:59 +00:00
|
|
|
&format!("({} | {})--", commit4.id().hex(), commit5.id().hex())
|
|
|
|
),
|
|
|
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-12-09 13:55:59 +00:00
|
|
|
&format!("({} | {})--", commit4.id().hex(), commit2.id().hex())
|
|
|
|
),
|
|
|
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
|
|
|
);
|
2021-04-10 17:18:30 +00:00
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-21 21:51:23 +00:00
|
|
|
fn test_evaluate_expression_children(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-21 21:51:23 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-21 21:51:23 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
2022-12-24 15:38:20 +00:00
|
|
|
let commit1 = write_random_commit(mut_repo, &settings);
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit2 = create_random_commit(mut_repo, &settings)
|
2021-04-21 21:51:23 +00:00
|
|
|
.set_parents(vec![commit1.id().clone()])
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit3 = create_random_commit(mut_repo, &settings)
|
2021-09-25 21:36:34 +00:00
|
|
|
.set_parents(vec![commit2.id().clone()])
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit4 = create_random_commit(mut_repo, &settings)
|
2021-04-21 21:51:23 +00:00
|
|
|
.set_parents(vec![commit1.id().clone()])
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit5 = create_random_commit(mut_repo, &settings)
|
2021-09-25 21:36:34 +00:00
|
|
|
.set_parents(vec![commit3.id().clone(), commit4.id().clone()])
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2021-04-21 21:51:23 +00:00
|
|
|
|
|
|
|
// Can find children of the root commit
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "root+"),
|
2022-02-05 23:02:16 +00:00
|
|
|
vec![commit1.id().clone()]
|
2021-04-21 21:51:23 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Children of all commits in input are returned, including those already in the
|
|
|
|
// input set
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-11 19:23:29 +00:00
|
|
|
&format!("({} | {})+", commit1.id().hex(), commit2.id().hex())
|
2021-04-21 21:51:23 +00:00
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit4.id().clone(),
|
2021-09-25 21:36:34 +00:00
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone()
|
2021-04-21 21:51:23 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Children shared among commits in input are not repeated
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-11 19:23:29 +00:00
|
|
|
&format!("({} | {})+", commit3.id().hex(), commit4.id().hex())
|
2021-04-21 21:51:23 +00:00
|
|
|
),
|
2021-09-25 21:36:34 +00:00
|
|
|
vec![commit5.id().clone()]
|
2021-04-21 21:51:23 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-10 17:18:30 +00:00
|
|
|
fn test_evaluate_expression_ancestors(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-10 17:18:30 +00:00
|
|
|
|
2021-05-01 04:41:27 +00:00
|
|
|
let root_commit = repo.store().root_commit();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-10 17:18:30 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-05-01 04:41:27 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit1, &commit3]);
|
2021-04-10 17:18:30 +00:00
|
|
|
|
|
|
|
// The ancestors of the root commit is just the root commit itself
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, ":root"),
|
2021-04-10 17:18:30 +00:00
|
|
|
vec![root_commit.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Can find ancestors of a specific commit. Commits reachable via multiple paths
|
|
|
|
// are not repeated.
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!(":{}", commit4.id().hex())),
|
2021-04-10 17:18:30 +00:00
|
|
|
vec![
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
root_commit.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
2022-12-09 13:55:59 +00:00
|
|
|
|
|
|
|
// Can find ancestors of parents or parents of ancestors, which may be optimized
|
|
|
|
// to single query
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!(":({}-)", commit4.id().hex()),),
|
2022-12-09 13:55:59 +00:00
|
|
|
vec![
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
root_commit.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-12-09 13:55:59 +00:00
|
|
|
&format!("(:({}|{}))-", commit3.id().hex(), commit2.id().hex()),
|
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
root_commit.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-12-09 13:55:59 +00:00
|
|
|
&format!(":(({}|{})-)", commit3.id().hex(), commit2.id().hex()),
|
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
root_commit.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
2021-04-10 17:18:30 +00:00
|
|
|
}
|
2021-04-16 05:19:08 +00:00
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-23 18:11:39 +00:00
|
|
|
fn test_evaluate_expression_range(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-23 18:11:39 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-23 18:11:39 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-05-01 04:41:27 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit1, &commit3]);
|
2021-04-23 18:11:39 +00:00
|
|
|
|
|
|
|
// The range from the root to the root is empty (because the left side of the
|
|
|
|
// range is exclusive)
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "root..root"), vec![]);
|
2021-04-23 18:11:39 +00:00
|
|
|
|
|
|
|
// Linear range
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:56:37 +00:00
|
|
|
&format!("{}..{}", commit1.id().hex(), commit3.id().hex())
|
2021-04-23 18:11:39 +00:00
|
|
|
),
|
|
|
|
vec![commit3.id().clone(), commit2.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Empty range (descendant first)
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:56:37 +00:00
|
|
|
&format!("{}..{}", commit3.id().hex(), commit1.id().hex())
|
2021-04-23 18:11:39 +00:00
|
|
|
),
|
|
|
|
vec![]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Range including a merge
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:56:37 +00:00
|
|
|
&format!("{}..{}", commit1.id().hex(), commit4.id().hex())
|
2021-04-23 18:11:39 +00:00
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sibling commits
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:56:37 +00:00
|
|
|
&format!("{}..{}", commit2.id().hex(), commit3.id().hex())
|
2021-04-23 18:11:39 +00:00
|
|
|
),
|
|
|
|
vec![commit3.id().clone()]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-23 05:45:58 +00:00
|
|
|
fn test_evaluate_expression_dag_range(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-23 05:45:58 +00:00
|
|
|
|
2021-11-17 20:29:08 +00:00
|
|
|
let root_commit_id = repo.store().root_commit_id().clone();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-23 05:45:58 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-05-01 04:41:27 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit5 = graph_builder.commit_with_parents(&[&commit3, &commit4]);
|
2021-04-23 05:45:58 +00:00
|
|
|
|
|
|
|
// Can get DAG range of just the root commit
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "root:root"),
|
2021-11-17 20:29:08 +00:00
|
|
|
vec![root_commit_id.clone()]
|
2021-04-23 05:45:58 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Linear range
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:50:26 +00:00
|
|
|
&format!("{}:{}", root_commit_id.hex(), commit2.id().hex())
|
2021-04-23 05:45:58 +00:00
|
|
|
),
|
2022-04-14 04:26:21 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone(), root_commit_id]
|
2021-04-23 05:45:58 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Empty range
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:50:26 +00:00
|
|
|
&format!("{}:{}", commit2.id().hex(), commit4.id().hex())
|
2021-04-23 05:45:58 +00:00
|
|
|
),
|
|
|
|
vec![]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Including a merge
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:50:26 +00:00
|
|
|
&format!("{}:{}", commit1.id().hex(), commit5.id().hex())
|
2021-04-23 05:45:58 +00:00
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit5.id().clone(),
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2022-04-14 04:26:21 +00:00
|
|
|
// Including a merge, but ancestors only from one side
|
2021-04-23 05:45:58 +00:00
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:50:26 +00:00
|
|
|
&format!("{}:{}", commit2.id().hex(), commit5.id().hex())
|
2021-04-23 05:45:58 +00:00
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit5.id().clone(),
|
2022-04-14 04:26:21 +00:00
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
|
|
|
fn test_evaluate_expression_connected(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-04-14 04:26:21 +00:00
|
|
|
let repo = &test_repo.repo;
|
|
|
|
|
|
|
|
let root_commit_id = repo.store().root_commit_id().clone();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2022-04-14 04:26:21 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit5 = graph_builder.commit_with_parents(&[&commit3, &commit4]);
|
|
|
|
|
|
|
|
// Connecting an empty set yields an empty set
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "connected(none())"), vec![]);
|
2022-04-14 04:26:21 +00:00
|
|
|
|
|
|
|
// Can connect just the root commit
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "connected(root)"),
|
2022-04-14 04:26:21 +00:00
|
|
|
vec![root_commit_id.clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Can connect linearly
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-04-14 04:26:21 +00:00
|
|
|
&format!(
|
|
|
|
"connected({} | {})",
|
|
|
|
root_commit_id.hex(),
|
|
|
|
commit2.id().hex()
|
|
|
|
)
|
|
|
|
),
|
|
|
|
vec![commit2.id().clone(), commit1.id().clone(), root_commit_id]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Siblings don't get connected
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-04-14 04:26:21 +00:00
|
|
|
&format!("connected({} | {})", commit2.id().hex(), commit4.id().hex())
|
|
|
|
),
|
|
|
|
vec![commit4.id().clone(), commit2.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Including a merge
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-04-14 04:26:21 +00:00
|
|
|
&format!("connected({} | {})", commit1.id().hex(), commit5.id().hex())
|
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit5.id().clone(),
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Including a merge, but ancestors only from one side
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-04-14 04:26:21 +00:00
|
|
|
&format!("connected({} | {})", commit2.id().hex(), commit5.id().hex())
|
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit5.id().clone(),
|
2021-04-23 05:45:58 +00:00
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-21 21:51:23 +00:00
|
|
|
fn test_evaluate_expression_descendants(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-21 21:51:23 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-21 21:51:23 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
2021-11-17 20:29:08 +00:00
|
|
|
let root_commit_id = repo.store().root_commit_id().clone();
|
2022-12-24 15:38:20 +00:00
|
|
|
let commit1 = write_random_commit(mut_repo, &settings);
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit2 = create_random_commit(mut_repo, &settings)
|
2021-04-21 21:51:23 +00:00
|
|
|
.set_parents(vec![commit1.id().clone()])
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit3 = create_random_commit(mut_repo, &settings)
|
2021-09-25 21:36:34 +00:00
|
|
|
.set_parents(vec![commit2.id().clone()])
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit4 = create_random_commit(mut_repo, &settings)
|
2021-04-21 21:51:23 +00:00
|
|
|
.set_parents(vec![commit1.id().clone()])
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit5 = create_random_commit(mut_repo, &settings)
|
2021-09-25 21:36:34 +00:00
|
|
|
.set_parents(vec![commit3.id().clone(), commit4.id().clone()])
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2021-04-21 21:51:23 +00:00
|
|
|
|
2021-09-25 21:36:34 +00:00
|
|
|
// The descendants of the root commit are all the commits in the repo
|
2021-04-21 21:51:23 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "root:"),
|
2021-04-21 21:51:23 +00:00
|
|
|
vec![
|
|
|
|
commit5.id().clone(),
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
2021-09-25 21:36:34 +00:00
|
|
|
commit2.id().clone(),
|
2021-04-21 21:51:23 +00:00
|
|
|
commit1.id().clone(),
|
2021-11-17 20:29:08 +00:00
|
|
|
root_commit_id,
|
2021-04-21 21:51:23 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2021-08-29 05:03:49 +00:00
|
|
|
// Can find descendants of a specific commit
|
2021-04-21 21:51:23 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!("{}:", commit2.id().hex())),
|
2021-04-21 21:51:23 +00:00
|
|
|
vec![
|
2021-09-25 21:36:34 +00:00
|
|
|
commit5.id().clone(),
|
2021-04-21 21:51:23 +00:00
|
|
|
commit3.id().clone(),
|
2021-09-25 21:36:34 +00:00
|
|
|
commit2.id().clone(),
|
2021-04-21 21:51:23 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-10-13 16:07:18 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
|
|
|
fn test_evaluate_expression_none(use_git: bool) {
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-10-13 16:07:18 +00:00
|
|
|
|
|
|
|
// none() is empty (doesn't include the checkout, for example)
|
2023-03-21 06:02:29 +00:00
|
|
|
assert_eq!(resolve_commit_ids(repo.as_ref(), "none()"), vec![]);
|
2021-10-13 16:07:18 +00:00
|
|
|
}
|
|
|
|
|
2021-10-13 16:12:50 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
|
|
|
fn test_evaluate_expression_all(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-10-13 16:12:50 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-10-13 16:12:50 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-11-17 20:29:08 +00:00
|
|
|
let root_commit_id = repo.store().root_commit_id().clone();
|
2021-10-13 16:12:50 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit2, &commit3]);
|
|
|
|
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "all()"),
|
2021-10-13 16:12:50 +00:00
|
|
|
vec![
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
2021-11-17 20:29:08 +00:00
|
|
|
root_commit_id,
|
2021-10-13 16:12:50 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2022-04-13 20:27:00 +00:00
|
|
|
fn test_evaluate_expression_visible_heads(use_git: bool) {
|
2021-04-16 05:19:08 +00:00
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-16 05:19:08 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-16 05:19:08 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-05-01 04:41:27 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
2022-02-05 23:02:16 +00:00
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit1]);
|
2021-04-16 05:19:08 +00:00
|
|
|
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "heads()"),
|
2022-02-05 23:02:16 +00:00
|
|
|
vec![commit3.id().clone(), commit2.id().clone()]
|
2021-04-16 05:19:08 +00:00
|
|
|
);
|
|
|
|
}
|
2021-04-16 05:52:33 +00:00
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-19 00:30:21 +00:00
|
|
|
fn test_evaluate_expression_public_heads(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-19 00:30:21 +00:00
|
|
|
|
2021-05-01 04:41:27 +00:00
|
|
|
let root_commit = repo.store().root_commit();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-19 00:30:21 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-05-01 04:41:27 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.initial_commit();
|
2021-04-19 00:30:21 +00:00
|
|
|
|
|
|
|
// Can get public heads with root commit as only public head
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "public_heads()"),
|
2021-04-19 05:52:31 +00:00
|
|
|
vec![root_commit.id().clone()]
|
2021-04-19 00:30:21 +00:00
|
|
|
);
|
|
|
|
// Can get public heads with a single public head
|
|
|
|
mut_repo.add_public_head(&commit1);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "public_heads()"),
|
2021-04-19 00:30:21 +00:00
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
// Can get public heads with multiple public head
|
|
|
|
mut_repo.add_public_head(&commit2);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "public_heads()"),
|
2021-04-19 00:30:21 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-26 06:38:23 +00:00
|
|
|
fn test_evaluate_expression_git_refs(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-26 06:38:23 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-26 06:38:23 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
2022-12-24 15:38:20 +00:00
|
|
|
let commit1 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit2 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit3 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit4 = write_random_commit(mut_repo, &settings);
|
2021-04-26 06:38:23 +00:00
|
|
|
|
|
|
|
// Can get git refs when there are none
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "git_refs()"), vec![]);
|
2021-04-26 06:38:23 +00:00
|
|
|
// Can get a mix of git refs
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/heads/branch1".to_string(),
|
|
|
|
RefTarget::Normal(commit1.id().clone()),
|
|
|
|
);
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/tags/tag1".to_string(),
|
|
|
|
RefTarget::Normal(commit2.id().clone()),
|
|
|
|
);
|
2021-04-26 06:38:23 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "git_refs()"),
|
2021-04-26 06:38:23 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
|
|
|
// Two refs pointing to the same commit does not result in a duplicate in the
|
|
|
|
// revset
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/tags/tag2".to_string(),
|
|
|
|
RefTarget::Normal(commit2.id().clone()),
|
|
|
|
);
|
2021-04-26 06:38:23 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "git_refs()"),
|
2021-04-26 06:38:23 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
2021-07-11 17:58:01 +00:00
|
|
|
// Can get git refs when there are conflicted refs
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/heads/branch1".to_string(),
|
|
|
|
RefTarget::Conflict {
|
|
|
|
removes: vec![commit1.id().clone()],
|
|
|
|
adds: vec![commit2.id().clone(), commit3.id().clone()],
|
|
|
|
},
|
|
|
|
);
|
2021-08-04 15:42:16 +00:00
|
|
|
mut_repo.set_git_ref(
|
2021-07-11 17:58:01 +00:00
|
|
|
"refs/tags/tag1".to_string(),
|
|
|
|
RefTarget::Conflict {
|
|
|
|
removes: vec![commit2.id().clone()],
|
|
|
|
adds: vec![commit3.id().clone(), commit4.id().clone()],
|
|
|
|
},
|
|
|
|
);
|
|
|
|
mut_repo.remove_git_ref("refs/tags/tag2");
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "git_refs()"),
|
2021-07-11 17:58:01 +00:00
|
|
|
vec![
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone()
|
|
|
|
]
|
|
|
|
);
|
2021-04-26 06:38:23 +00:00
|
|
|
}
|
|
|
|
|
2021-11-29 07:02:35 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
|
|
|
fn test_evaluate_expression_git_head(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-11-29 07:02:35 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-11-29 07:02:35 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
2022-12-24 15:38:20 +00:00
|
|
|
let commit1 = write_random_commit(mut_repo, &settings);
|
2021-11-29 07:02:35 +00:00
|
|
|
|
|
|
|
// Can get git head when it's not set
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "git_head()"), vec![]);
|
2022-12-17 17:34:09 +00:00
|
|
|
mut_repo.set_git_head(RefTarget::Normal(commit1.id().clone()));
|
2021-11-29 07:02:35 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "git_head()"),
|
2021-11-29 07:02:35 +00:00
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-10-10 16:39:40 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
|
|
|
fn test_evaluate_expression_branches(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-10-10 16:39:40 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-10-10 16:39:40 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
2022-12-24 15:38:20 +00:00
|
|
|
let commit1 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit2 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit3 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit4 = write_random_commit(mut_repo, &settings);
|
2021-10-10 16:39:40 +00:00
|
|
|
|
|
|
|
// Can get branches when there are none
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "branches()"), vec![]);
|
2021-10-10 16:39:40 +00:00
|
|
|
// Can get a few branches
|
|
|
|
mut_repo.set_local_branch(
|
|
|
|
"branch1".to_string(),
|
|
|
|
RefTarget::Normal(commit1.id().clone()),
|
|
|
|
);
|
|
|
|
mut_repo.set_local_branch(
|
|
|
|
"branch2".to_string(),
|
|
|
|
RefTarget::Normal(commit2.id().clone()),
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "branches()"),
|
2021-10-10 16:39:40 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
2023-01-12 10:01:35 +00:00
|
|
|
// Can get branches with matching names
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "branches(branch1)"),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "branches(branch)"),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
|
|
|
// Can silently resolve to an empty set if there's no matches
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "branches(branch3)"), vec![]);
|
2021-10-10 16:39:40 +00:00
|
|
|
// Two branches pointing to the same commit does not result in a duplicate in
|
|
|
|
// the revset
|
|
|
|
mut_repo.set_local_branch(
|
|
|
|
"branch3".to_string(),
|
|
|
|
RefTarget::Normal(commit2.id().clone()),
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "branches()"),
|
2021-10-10 16:39:40 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
|
|
|
// Can get branches when there are conflicted refs
|
|
|
|
mut_repo.set_local_branch(
|
|
|
|
"branch1".to_string(),
|
|
|
|
RefTarget::Conflict {
|
|
|
|
removes: vec![commit1.id().clone()],
|
|
|
|
adds: vec![commit2.id().clone(), commit3.id().clone()],
|
|
|
|
},
|
|
|
|
);
|
|
|
|
mut_repo.set_local_branch(
|
|
|
|
"branch2".to_string(),
|
|
|
|
RefTarget::Conflict {
|
|
|
|
removes: vec![commit2.id().clone()],
|
|
|
|
adds: vec![commit3.id().clone(), commit4.id().clone()],
|
|
|
|
},
|
|
|
|
);
|
|
|
|
mut_repo.remove_local_branch("branch3");
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "branches()"),
|
2021-10-10 16:39:40 +00:00
|
|
|
vec![
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
|
|
|
fn test_evaluate_expression_remote_branches(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-10-10 16:39:40 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-10-10 16:39:40 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
2022-12-24 15:38:20 +00:00
|
|
|
let commit1 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit2 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit3 = write_random_commit(mut_repo, &settings);
|
|
|
|
let commit4 = write_random_commit(mut_repo, &settings);
|
2021-10-10 16:39:40 +00:00
|
|
|
|
|
|
|
// Can get branches when there are none
|
2023-02-13 17:52:21 +00:00
|
|
|
assert_eq!(resolve_commit_ids(mut_repo, "remote_branches()"), vec![]);
|
2021-10-10 16:39:40 +00:00
|
|
|
// Can get a few branches
|
|
|
|
mut_repo.set_remote_branch(
|
|
|
|
"branch1".to_string(),
|
|
|
|
"origin".to_string(),
|
|
|
|
RefTarget::Normal(commit1.id().clone()),
|
|
|
|
);
|
|
|
|
mut_repo.set_remote_branch(
|
|
|
|
"branch2".to_string(),
|
|
|
|
"private".to_string(),
|
|
|
|
RefTarget::Normal(commit2.id().clone()),
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "remote_branches()"),
|
2021-10-10 16:39:40 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
2023-01-12 10:01:35 +00:00
|
|
|
// Can get branches with matching names
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "remote_branches(branch1)"),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "remote_branches(branch)"),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
|
|
|
// Can get branches from matching remotes
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, r#"remote_branches("", origin)"#),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, r#"remote_branches("", ri)"#),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
|
|
|
// Can get branches with matching names from matching remotes
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "remote_branches(branch1, ri)"),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, r#"remote_branches(branch, private)"#),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![commit2.id().clone()]
|
|
|
|
);
|
|
|
|
// Can silently resolve to an empty set if there's no matches
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "remote_branches(branch3)"),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, r#"remote_branches("", upstream)"#),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, r#"remote_branches(branch1, private)"#),
|
2023-01-12 10:01:35 +00:00
|
|
|
vec![]
|
|
|
|
);
|
2021-10-10 16:39:40 +00:00
|
|
|
// Two branches pointing to the same commit does not result in a duplicate in
|
|
|
|
// the revset
|
|
|
|
mut_repo.set_remote_branch(
|
|
|
|
"branch3".to_string(),
|
|
|
|
"origin".to_string(),
|
|
|
|
RefTarget::Normal(commit2.id().clone()),
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "remote_branches()"),
|
2021-10-10 16:39:40 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
2021-10-23 06:52:16 +00:00
|
|
|
// The commits don't have to be in the current set of heads to be included.
|
|
|
|
mut_repo.remove_head(commit2.id());
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "remote_branches()"),
|
2021-10-23 06:52:16 +00:00
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
2021-10-10 16:39:40 +00:00
|
|
|
// Can get branches when there are conflicted refs
|
|
|
|
mut_repo.set_remote_branch(
|
|
|
|
"branch1".to_string(),
|
|
|
|
"origin".to_string(),
|
|
|
|
RefTarget::Conflict {
|
|
|
|
removes: vec![commit1.id().clone()],
|
|
|
|
adds: vec![commit2.id().clone(), commit3.id().clone()],
|
|
|
|
},
|
|
|
|
);
|
|
|
|
mut_repo.set_remote_branch(
|
|
|
|
"branch2".to_string(),
|
|
|
|
"private".to_string(),
|
|
|
|
RefTarget::Conflict {
|
|
|
|
removes: vec![commit2.id().clone()],
|
|
|
|
adds: vec![commit3.id().clone(), commit4.id().clone()],
|
|
|
|
},
|
|
|
|
);
|
|
|
|
mut_repo.remove_remote_branch("branch3", "origin");
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "remote_branches()"),
|
2021-10-10 16:39:40 +00:00
|
|
|
vec![
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-05-01 21:29:43 +00:00
|
|
|
fn test_evaluate_expression_merges(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-05-01 21:29:43 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-05-01 21:29:43 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.initial_commit();
|
|
|
|
let commit3 = graph_builder.initial_commit();
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit1, &commit2]);
|
|
|
|
let commit5 = graph_builder.commit_with_parents(&[&commit1, &commit2, &commit3]);
|
|
|
|
|
|
|
|
// Finds all merges by default
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "merges()"),
|
2021-05-01 21:29:43 +00:00
|
|
|
vec![commit5.id().clone(), commit4.id().clone(),]
|
|
|
|
);
|
|
|
|
// Searches only among candidates if specified
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!(":{} & merges()", commit5.id().hex())),
|
2021-05-01 21:29:43 +00:00
|
|
|
vec![commit5.id().clone()]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-16 17:24:22 +00:00
|
|
|
fn test_evaluate_expression_description(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-16 17:24:22 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-16 17:24:22 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit1 = create_random_commit(mut_repo, &settings)
|
2022-12-21 09:13:56 +00:00
|
|
|
.set_description("commit 1")
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit2 = create_random_commit(mut_repo, &settings)
|
2021-04-16 17:24:22 +00:00
|
|
|
.set_parents(vec![commit1.id().clone()])
|
2022-12-21 09:13:56 +00:00
|
|
|
.set_description("commit 2")
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit3 = create_random_commit(mut_repo, &settings)
|
2021-04-16 17:24:22 +00:00
|
|
|
.set_parents(vec![commit2.id().clone()])
|
2022-12-21 09:13:56 +00:00
|
|
|
.set_description("commit 3")
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2021-04-16 17:24:22 +00:00
|
|
|
|
|
|
|
// Can find multiple matches
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "description(commit)"),
|
2021-04-16 17:24:22 +00:00
|
|
|
vec![
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
// Can find a unique match
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "description(\"commit 2\")"),
|
2021-04-16 17:24:22 +00:00
|
|
|
vec![commit2.id().clone()]
|
|
|
|
);
|
2021-05-01 21:29:43 +00:00
|
|
|
// Searches only among candidates if specified
|
2021-04-16 17:24:22 +00:00
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "heads() & description(\"commit 2\")"),
|
2021-04-16 17:24:22 +00:00
|
|
|
vec![]
|
|
|
|
);
|
|
|
|
}
|
2021-04-17 22:25:52 +00:00
|
|
|
|
2021-12-16 06:16:22 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
|
|
|
fn test_evaluate_expression_author(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-12-16 06:16:22 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-12-16 06:16:22 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
|
|
|
let timestamp = Timestamp {
|
|
|
|
timestamp: MillisSinceEpoch(0),
|
|
|
|
tz_offset: 0,
|
|
|
|
};
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit1 = create_random_commit(mut_repo, &settings)
|
2021-12-16 06:16:22 +00:00
|
|
|
.set_author(Signature {
|
|
|
|
name: "name1".to_string(),
|
|
|
|
email: "email1".to_string(),
|
|
|
|
timestamp: timestamp.clone(),
|
|
|
|
})
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit2 = create_random_commit(mut_repo, &settings)
|
2021-12-16 06:16:22 +00:00
|
|
|
.set_parents(vec![commit1.id().clone()])
|
|
|
|
.set_author(Signature {
|
|
|
|
name: "name2".to_string(),
|
|
|
|
email: "email2".to_string(),
|
|
|
|
timestamp: timestamp.clone(),
|
|
|
|
})
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit3 = create_random_commit(mut_repo, &settings)
|
2021-12-16 06:16:22 +00:00
|
|
|
.set_parents(vec![commit2.id().clone()])
|
|
|
|
.set_author(Signature {
|
|
|
|
name: "name3".to_string(),
|
|
|
|
email: "email3".to_string(),
|
|
|
|
timestamp,
|
|
|
|
})
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2021-12-16 06:16:22 +00:00
|
|
|
|
|
|
|
// Can find multiple matches
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "author(name)"),
|
2021-12-16 06:16:22 +00:00
|
|
|
vec![
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
// Can find a unique match by either name or email
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "author(\"name2\")"),
|
2021-12-16 06:16:22 +00:00
|
|
|
vec![commit2.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "author(\"name3\")"),
|
2021-12-16 06:16:22 +00:00
|
|
|
vec![commit3.id().clone()]
|
|
|
|
);
|
|
|
|
// Searches only among candidates if specified
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "heads() & author(\"name2\")"),
|
2021-12-16 06:16:22 +00:00
|
|
|
vec![]
|
|
|
|
);
|
2022-11-30 09:17:06 +00:00
|
|
|
// Filter by union of pure predicate and set
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-11-30 09:17:06 +00:00
|
|
|
&format!("root.. & (author(name1) | {})", commit3.id().hex())
|
|
|
|
),
|
|
|
|
vec![commit3.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
2021-12-16 06:16:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
|
|
|
fn test_evaluate_expression_committer(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-12-16 06:16:22 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-12-16 06:16:22 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
|
|
|
let timestamp = Timestamp {
|
|
|
|
timestamp: MillisSinceEpoch(0),
|
|
|
|
tz_offset: 0,
|
|
|
|
};
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit1 = create_random_commit(mut_repo, &settings)
|
2021-12-16 06:16:22 +00:00
|
|
|
.set_committer(Signature {
|
|
|
|
name: "name1".to_string(),
|
|
|
|
email: "email1".to_string(),
|
|
|
|
timestamp: timestamp.clone(),
|
|
|
|
})
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit2 = create_random_commit(mut_repo, &settings)
|
2021-12-16 06:16:22 +00:00
|
|
|
.set_parents(vec![commit1.id().clone()])
|
|
|
|
.set_committer(Signature {
|
|
|
|
name: "name2".to_string(),
|
|
|
|
email: "email2".to_string(),
|
|
|
|
timestamp: timestamp.clone(),
|
|
|
|
})
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-12-24 17:01:11 +00:00
|
|
|
let commit3 = create_random_commit(mut_repo, &settings)
|
2021-12-16 06:16:22 +00:00
|
|
|
.set_parents(vec![commit2.id().clone()])
|
|
|
|
.set_committer(Signature {
|
|
|
|
name: "name3".to_string(),
|
|
|
|
email: "email3".to_string(),
|
|
|
|
timestamp,
|
|
|
|
})
|
2022-12-24 05:09:19 +00:00
|
|
|
.write()
|
|
|
|
.unwrap();
|
2021-12-16 06:16:22 +00:00
|
|
|
|
|
|
|
// Can find multiple matches
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "committer(name)"),
|
2021-12-16 06:16:22 +00:00
|
|
|
vec![
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
// Can find a unique match by either name or email
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "committer(\"name2\")"),
|
2021-12-16 06:16:22 +00:00
|
|
|
vec![commit2.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "committer(\"name3\")"),
|
2021-12-16 06:16:22 +00:00
|
|
|
vec![commit3.id().clone()]
|
|
|
|
);
|
|
|
|
// Searches only among candidates if specified
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, "heads() & committer(\"name2\")"),
|
2021-12-16 06:16:22 +00:00
|
|
|
vec![]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-18 22:09:29 +00:00
|
|
|
fn test_evaluate_expression_union(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-18 22:09:29 +00:00
|
|
|
|
2021-05-01 04:41:27 +00:00
|
|
|
let root_commit = repo.store().root_commit();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-18 22:09:29 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-05-01 04:41:27 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit3]);
|
|
|
|
let commit5 = graph_builder.commit_with_parents(&[&commit2]);
|
2021-04-18 22:09:29 +00:00
|
|
|
|
|
|
|
// Union between ancestors
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:50:26 +00:00
|
|
|
&format!(":{} | :{}", commit4.id().hex(), commit5.id().hex())
|
2021-04-18 22:09:29 +00:00
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit5.id().clone(),
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
root_commit.id().clone()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Unioning can add back commits removed by difference
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-04-18 22:09:29 +00:00
|
|
|
&format!(
|
2021-12-13 06:40:16 +00:00
|
|
|
"(:{} ~ :{}) | :{}",
|
2021-04-18 22:09:29 +00:00
|
|
|
commit4.id().hex(),
|
|
|
|
commit2.id().hex(),
|
|
|
|
commit5.id().hex()
|
|
|
|
)
|
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit5.id().clone(),
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
root_commit.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Unioning of disjoint sets
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-04-18 22:09:29 +00:00
|
|
|
&format!(
|
2021-12-13 06:40:16 +00:00
|
|
|
"(:{} ~ :{}) | {}",
|
2021-04-18 22:09:29 +00:00
|
|
|
commit4.id().hex(),
|
|
|
|
commit2.id().hex(),
|
|
|
|
commit5.id().hex(),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit5.id().clone(),
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit3.id().clone()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-19 00:10:17 +00:00
|
|
|
fn test_evaluate_expression_intersection(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-19 00:10:17 +00:00
|
|
|
|
2021-05-01 04:41:27 +00:00
|
|
|
let root_commit = repo.store().root_commit();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-19 00:10:17 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-05-01 04:41:27 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit3]);
|
|
|
|
let commit5 = graph_builder.commit_with_parents(&[&commit2]);
|
2021-04-19 00:10:17 +00:00
|
|
|
|
|
|
|
// Intersection between ancestors
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-12 07:50:26 +00:00
|
|
|
&format!(":{} & :{}", commit4.id().hex(), commit5.id().hex())
|
2021-04-19 00:10:17 +00:00
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
root_commit.id().clone()
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Intersection of disjoint sets
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-04-19 00:10:17 +00:00
|
|
|
&format!("{} & {}", commit4.id().hex(), commit2.id().hex())
|
|
|
|
),
|
|
|
|
vec![]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-12 06:52:38 +00:00
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2021-04-17 22:25:52 +00:00
|
|
|
fn test_evaluate_expression_difference(use_git: bool) {
|
|
|
|
let settings = testutils::user_settings();
|
2022-05-21 18:20:51 +00:00
|
|
|
let test_repo = TestRepo::init(use_git);
|
2022-02-05 23:02:16 +00:00
|
|
|
let repo = &test_repo.repo;
|
2021-04-17 22:25:52 +00:00
|
|
|
|
2021-05-01 04:41:27 +00:00
|
|
|
let root_commit = repo.store().root_commit();
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2021-04-17 22:25:52 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
2021-05-01 04:41:27 +00:00
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo);
|
|
|
|
let commit1 = graph_builder.initial_commit();
|
|
|
|
let commit2 = graph_builder.commit_with_parents(&[&commit1]);
|
|
|
|
let commit3 = graph_builder.commit_with_parents(&[&commit2]);
|
|
|
|
let commit4 = graph_builder.commit_with_parents(&[&commit3]);
|
|
|
|
let commit5 = graph_builder.commit_with_parents(&[&commit2]);
|
2021-04-17 22:25:52 +00:00
|
|
|
|
2022-11-17 12:58:51 +00:00
|
|
|
// Difference from all
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!("~:{}", commit5.id().hex())),
|
2022-11-17 12:58:51 +00:00
|
|
|
vec![commit4.id().clone(), commit3.id().clone()]
|
|
|
|
);
|
|
|
|
|
2021-04-17 22:25:52 +00:00
|
|
|
// Difference between ancestors
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-13 06:40:16 +00:00
|
|
|
&format!(":{} ~ :{}", commit4.id().hex(), commit5.id().hex())
|
2021-04-17 22:25:52 +00:00
|
|
|
),
|
|
|
|
vec![commit4.id().clone(), commit3.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-13 06:40:16 +00:00
|
|
|
&format!(":{} ~ :{}", commit5.id().hex(), commit4.id().hex())
|
2021-04-17 22:25:52 +00:00
|
|
|
),
|
|
|
|
vec![commit5.id().clone()]
|
|
|
|
);
|
2022-11-17 12:58:51 +00:00
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-11-17 12:58:51 +00:00
|
|
|
&format!("~:{} & :{}", commit4.id().hex(), commit5.id().hex())
|
|
|
|
),
|
|
|
|
vec![commit5.id().clone()]
|
|
|
|
);
|
2021-04-17 22:25:52 +00:00
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-12-13 06:40:16 +00:00
|
|
|
&format!(":{} ~ :{}", commit4.id().hex(), commit2.id().hex())
|
2021-04-17 22:25:52 +00:00
|
|
|
),
|
|
|
|
vec![commit4.id().clone(), commit3.id().clone()]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Associativity
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-04-17 22:25:52 +00:00
|
|
|
&format!(
|
2021-12-13 06:40:16 +00:00
|
|
|
":{} ~ {} ~ {}",
|
2021-04-17 22:25:52 +00:00
|
|
|
commit4.id().hex(),
|
|
|
|
commit2.id().hex(),
|
|
|
|
commit3.id().hex()
|
|
|
|
)
|
|
|
|
),
|
|
|
|
vec![
|
|
|
|
commit4.id().clone(),
|
|
|
|
commit1.id().clone(),
|
|
|
|
root_commit.id().clone(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Subtracting a difference does not add back any commits
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2021-04-17 22:25:52 +00:00
|
|
|
&format!(
|
2021-12-13 06:40:16 +00:00
|
|
|
"(:{} ~ :{}) ~ (:{} ~ :{})",
|
2021-04-17 22:25:52 +00:00
|
|
|
commit4.id().hex(),
|
|
|
|
commit1.id().hex(),
|
|
|
|
commit3.id().hex(),
|
|
|
|
commit1.id().hex(),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
vec![commit4.id().clone()]
|
|
|
|
);
|
|
|
|
}
|
2022-09-13 06:39:06 +00:00
|
|
|
|
|
|
|
#[test_case(false ; "local backend")]
|
|
|
|
#[test_case(true ; "git backend")]
|
2023-03-04 04:41:11 +00:00
|
|
|
fn test_evaluate_expression_file(use_git: bool) {
|
2022-09-13 06:39:06 +00:00
|
|
|
let settings = testutils::user_settings();
|
2022-10-23 04:14:00 +00:00
|
|
|
let test_workspace = TestWorkspace::init(&settings, use_git);
|
|
|
|
let repo = &test_workspace.repo;
|
2022-09-13 06:39:06 +00:00
|
|
|
|
2022-11-13 06:29:06 +00:00
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
2022-09-13 06:39:06 +00:00
|
|
|
let mut_repo = tx.mut_repo();
|
|
|
|
|
|
|
|
let added_clean_clean = RepoPath::from_internal_string("added_clean_clean");
|
|
|
|
let added_modified_clean = RepoPath::from_internal_string("added_modified_clean");
|
|
|
|
let added_modified_removed = RepoPath::from_internal_string("added_modified_removed");
|
|
|
|
let tree1 = testutils::create_tree(
|
|
|
|
repo,
|
|
|
|
&[
|
|
|
|
(&added_clean_clean, "1"),
|
|
|
|
(&added_modified_clean, "1"),
|
|
|
|
(&added_modified_removed, "1"),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
let tree2 = testutils::create_tree(
|
|
|
|
repo,
|
|
|
|
&[
|
|
|
|
(&added_clean_clean, "1"),
|
|
|
|
(&added_modified_clean, "2"),
|
|
|
|
(&added_modified_removed, "2"),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
let tree3 = testutils::create_tree(
|
|
|
|
repo,
|
|
|
|
&[
|
|
|
|
(&added_clean_clean, "1"),
|
|
|
|
(&added_modified_clean, "2"),
|
|
|
|
// added_modified_removed,
|
|
|
|
],
|
|
|
|
);
|
2022-12-25 16:36:13 +00:00
|
|
|
let commit1 = mut_repo
|
|
|
|
.new_commit(
|
|
|
|
&settings,
|
|
|
|
vec![repo.store().root_commit_id().clone()],
|
|
|
|
tree1.id().clone(),
|
|
|
|
)
|
|
|
|
.write()
|
|
|
|
.unwrap();
|
|
|
|
let commit2 = mut_repo
|
|
|
|
.new_commit(&settings, vec![commit1.id().clone()], tree2.id().clone())
|
|
|
|
.write()
|
|
|
|
.unwrap();
|
|
|
|
let commit3 = mut_repo
|
|
|
|
.new_commit(&settings, vec![commit2.id().clone()], tree3.id().clone())
|
|
|
|
.write()
|
|
|
|
.unwrap();
|
|
|
|
let commit4 = mut_repo
|
|
|
|
.new_commit(&settings, vec![commit3.id().clone()], tree3.id().clone())
|
|
|
|
.write()
|
|
|
|
.unwrap();
|
2022-09-13 06:39:06 +00:00
|
|
|
|
|
|
|
let resolve = |file_path: &RepoPath| -> Vec<CommitId> {
|
2023-02-13 17:52:21 +00:00
|
|
|
let mut_repo = &*mut_repo;
|
2023-02-28 17:07:38 +00:00
|
|
|
let expression =
|
|
|
|
RevsetExpression::filter(RevsetFilterPredicate::File(Some(vec![file_path.clone()])));
|
2023-03-17 18:01:00 +00:00
|
|
|
let revset = expression.evaluate(mut_repo).unwrap();
|
2023-02-28 17:07:38 +00:00
|
|
|
let commit_ids = revset.iter().commit_ids().collect();
|
2022-09-13 06:39:06 +00:00
|
|
|
commit_ids
|
|
|
|
};
|
|
|
|
|
|
|
|
assert_eq!(resolve(&added_clean_clean), vec![commit1.id().clone()]);
|
|
|
|
assert_eq!(
|
|
|
|
resolve(&added_modified_clean),
|
|
|
|
vec![commit2.id().clone(), commit1.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
resolve(&added_modified_removed),
|
|
|
|
vec![
|
|
|
|
commit3.id().clone(),
|
|
|
|
commit2.id().clone(),
|
|
|
|
commit1.id().clone()
|
|
|
|
]
|
|
|
|
);
|
2022-10-23 04:14:00 +00:00
|
|
|
|
|
|
|
// file() revset:
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids_in_workspace(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-10-23 04:14:00 +00:00
|
|
|
r#"file("repo/added_clean_clean")"#,
|
|
|
|
&test_workspace.workspace,
|
|
|
|
Some(test_workspace.workspace.workspace_root().parent().unwrap()),
|
|
|
|
),
|
|
|
|
vec![commit1.id().clone()]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
resolve_commit_ids_in_workspace(
|
2023-02-13 17:52:21 +00:00
|
|
|
mut_repo,
|
2022-10-25 13:08:11 +00:00
|
|
|
&format!(r#"{}: & file("added_modified_clean")"#, commit2.id().hex()),
|
2022-10-23 04:14:00 +00:00
|
|
|
&test_workspace.workspace,
|
|
|
|
Some(test_workspace.workspace.workspace_root()),
|
|
|
|
),
|
|
|
|
vec![commit2.id().clone()]
|
|
|
|
);
|
2022-11-15 08:12:37 +00:00
|
|
|
|
|
|
|
// empty() revset, which is identical to ~file(".")
|
|
|
|
assert_eq!(
|
2023-02-13 17:52:21 +00:00
|
|
|
resolve_commit_ids(mut_repo, &format!("{}: & empty()", commit1.id().hex())),
|
2022-11-15 08:12:37 +00:00
|
|
|
vec![commit4.id().clone()]
|
|
|
|
);
|
2022-09-13 06:39:06 +00:00
|
|
|
}
|
2023-03-14 05:14:06 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_reverse_graph_iterator() {
|
|
|
|
let settings = testutils::user_settings();
|
|
|
|
let test_repo = TestRepo::init(true);
|
|
|
|
let repo = &test_repo.repo;
|
|
|
|
|
|
|
|
// Tests that merges, forks, direct edges, indirect edges, and "missing" edges
|
|
|
|
// are correct in reversed graph. "Missing" edges (i.e. edges to commits not
|
|
|
|
// in the input set) won't be part of the reversed graph. Conversely, there
|
|
|
|
// won't be missing edges to children not in the input.
|
|
|
|
//
|
|
|
|
// F
|
|
|
|
// |\
|
|
|
|
// D E
|
|
|
|
// |/
|
|
|
|
// C
|
|
|
|
// |
|
|
|
|
// b
|
|
|
|
// |
|
|
|
|
// A
|
|
|
|
// |
|
|
|
|
// root
|
|
|
|
let mut tx = repo.start_transaction(&settings, "test");
|
|
|
|
let mut graph_builder = CommitGraphBuilder::new(&settings, tx.mut_repo());
|
|
|
|
let commit_a = graph_builder.initial_commit();
|
|
|
|
let commit_b = graph_builder.commit_with_parents(&[&commit_a]);
|
|
|
|
let commit_c = graph_builder.commit_with_parents(&[&commit_b]);
|
|
|
|
let commit_d = graph_builder.commit_with_parents(&[&commit_c]);
|
|
|
|
let commit_e = graph_builder.commit_with_parents(&[&commit_c]);
|
|
|
|
let commit_f = graph_builder.commit_with_parents(&[&commit_d, &commit_e]);
|
|
|
|
let repo = tx.commit();
|
|
|
|
|
|
|
|
let revset = revset_for_commits(
|
2023-03-21 06:02:29 +00:00
|
|
|
repo.as_ref(),
|
2023-03-14 05:14:06 +00:00
|
|
|
&[&commit_a, &commit_c, &commit_d, &commit_e, &commit_f],
|
|
|
|
);
|
|
|
|
let commits = ReverseRevsetGraphIterator::new(revset.iter_graph()).collect_vec();
|
|
|
|
assert_eq!(commits.len(), 5);
|
2023-03-20 00:44:50 +00:00
|
|
|
assert_eq!(commits[0].0, *commit_a.id());
|
|
|
|
assert_eq!(commits[1].0, *commit_c.id());
|
|
|
|
assert_eq!(commits[2].0, *commit_d.id());
|
|
|
|
assert_eq!(commits[3].0, *commit_e.id());
|
|
|
|
assert_eq!(commits[4].0, *commit_f.id());
|
2023-03-19 23:52:33 +00:00
|
|
|
assert_eq!(
|
|
|
|
commits[0].1,
|
|
|
|
vec![RevsetGraphEdge::indirect(commit_c.id().clone())]
|
|
|
|
);
|
2023-03-14 05:14:06 +00:00
|
|
|
assert_eq!(
|
|
|
|
commits[1].1,
|
|
|
|
vec![
|
2023-03-19 23:52:33 +00:00
|
|
|
RevsetGraphEdge::direct(commit_e.id().clone()),
|
|
|
|
RevsetGraphEdge::direct(commit_d.id().clone()),
|
2023-03-14 05:14:06 +00:00
|
|
|
]
|
|
|
|
);
|
2023-03-19 23:52:33 +00:00
|
|
|
assert_eq!(
|
|
|
|
commits[2].1,
|
|
|
|
vec![RevsetGraphEdge::direct(commit_f.id().clone())]
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
commits[3].1,
|
|
|
|
vec![RevsetGraphEdge::direct(commit_f.id().clone())]
|
|
|
|
);
|
2023-03-14 05:14:06 +00:00
|
|
|
assert_eq!(commits[4].1, vec![]);
|
|
|
|
}
|