mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-23 08:01:12 +00:00
object_id: implement Display on ObjectId types
It's convenient if id can be inlined in error messages.
This commit is contained in:
parent
5658f070fc
commit
ad4b940daa
@ -2652,15 +2652,15 @@ pub fn edit_temp_file(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn short_commit_hash(commit_id: &CommitId) -> String {
|
pub fn short_commit_hash(commit_id: &CommitId) -> String {
|
||||||
commit_id.hex()[0..12].to_string()
|
format!("{commit_id:.12}")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn short_change_hash(change_id: &ChangeId) -> String {
|
pub fn short_change_hash(change_id: &ChangeId) -> String {
|
||||||
change_id.reverse_hex()[0..12].to_string()
|
format!("{change_id:.12}")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn short_operation_hash(operation_id: &OperationId) -> String {
|
pub fn short_operation_hash(operation_id: &OperationId) -> String {
|
||||||
operation_id.hex()[0..12].to_string()
|
format!("{operation_id:.12}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapper around a `DiffEditor` to conditionally start interactive session.
|
/// Wrapper around a `DiffEditor` to conditionally start interactive session.
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::io::Write as _;
|
use std::io::Write as _;
|
||||||
|
|
||||||
use jj_lib::object_id::ObjectId;
|
|
||||||
use jj_lib::revset;
|
use jj_lib::revset;
|
||||||
use jj_lib::revset::RevsetDiagnostics;
|
use jj_lib::revset::RevsetDiagnostics;
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ pub fn cmd_debug_revset(
|
|||||||
|
|
||||||
writeln!(ui.stdout(), "-- Commit IDs:")?;
|
writeln!(ui.stdout(), "-- Commit IDs:")?;
|
||||||
for commit_id in revset.iter() {
|
for commit_id in revset.iter() {
|
||||||
writeln!(ui.stdout(), "{}", commit_id.hex())?;
|
writeln!(ui.stdout(), "{commit_id}")?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -850,7 +850,7 @@ fn diff_content(path: &RepoPath, value: MaterializedTreeValue) -> io::Result<Fil
|
|||||||
}),
|
}),
|
||||||
MaterializedTreeValue::GitSubmodule(id) => Ok(FileContent {
|
MaterializedTreeValue::GitSubmodule(id) => Ok(FileContent {
|
||||||
is_binary: false,
|
is_binary: false,
|
||||||
contents: format!("Git submodule checked out at {}", id.hex()).into_bytes(),
|
contents: format!("Git submodule checked out at {id}").into_bytes(),
|
||||||
}),
|
}),
|
||||||
// TODO: are we sure this is never binary?
|
// TODO: are we sure this is never binary?
|
||||||
MaterializedTreeValue::FileConflict {
|
MaterializedTreeValue::FileConflict {
|
||||||
|
@ -37,7 +37,7 @@ pub enum BuiltinToolError {
|
|||||||
Record(#[from] scm_record::RecordError),
|
Record(#[from] scm_record::RecordError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
ReadFileBackend(BackendError),
|
ReadFileBackend(BackendError),
|
||||||
#[error("Failed to read file {path:?} with ID {id}", id = id.hex())]
|
#[error("Failed to read file {path:?} with ID {id}")]
|
||||||
ReadFileIo {
|
ReadFileIo {
|
||||||
path: RepoPathBuf,
|
path: RepoPathBuf,
|
||||||
id: FileId,
|
id: FileId,
|
||||||
|
@ -39,17 +39,17 @@ use crate::signing::SignResult;
|
|||||||
id_type!(
|
id_type!(
|
||||||
/// Identifier for a [`Commit`] based on its content. When a commit is
|
/// Identifier for a [`Commit`] based on its content. When a commit is
|
||||||
/// rewritten, its `CommitId` changes.
|
/// rewritten, its `CommitId` changes.
|
||||||
pub CommitId
|
pub CommitId { hex() }
|
||||||
);
|
);
|
||||||
id_type!(
|
id_type!(
|
||||||
/// Stable identifier for a [`Commit`]. Unlike the `CommitId`, the `ChangeId`
|
/// Stable identifier for a [`Commit`]. Unlike the `CommitId`, the `ChangeId`
|
||||||
/// follows the commit and is not updated when the commit is rewritten.
|
/// follows the commit and is not updated when the commit is rewritten.
|
||||||
pub ChangeId
|
pub ChangeId { reverse_hex() }
|
||||||
);
|
);
|
||||||
id_type!(pub TreeId);
|
id_type!(pub TreeId { hex() });
|
||||||
id_type!(pub FileId);
|
id_type!(pub FileId { hex() });
|
||||||
id_type!(pub SymlinkId);
|
id_type!(pub SymlinkId { hex() });
|
||||||
id_type!(pub ConflictId);
|
id_type!(pub ConflictId { hex() });
|
||||||
|
|
||||||
impl ChangeId {
|
impl ChangeId {
|
||||||
/// Returns the hex string representation of this ID, which uses `z-k`
|
/// Returns the hex string representation of this ID, which uses `z-k`
|
||||||
@ -240,7 +240,10 @@ pub enum BackendError {
|
|||||||
hash: String,
|
hash: String,
|
||||||
source: Box<dyn std::error::Error + Send + Sync>,
|
source: Box<dyn std::error::Error + Send + Sync>,
|
||||||
},
|
},
|
||||||
#[error("Error when reading file content for file {} with id {}", path.as_internal_file_string(), id.hex())]
|
#[error(
|
||||||
|
"Error when reading file content for file {path} with id {id}",
|
||||||
|
path = path.as_internal_file_string()
|
||||||
|
)]
|
||||||
ReadFile {
|
ReadFile {
|
||||||
path: RepoPathBuf,
|
path: RepoPathBuf,
|
||||||
id: FileId,
|
id: FileId,
|
||||||
|
@ -68,10 +68,7 @@ impl From<DefaultIndexStoreInitError> for BackendInitError {
|
|||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum DefaultIndexStoreError {
|
pub enum DefaultIndexStoreError {
|
||||||
#[error(
|
#[error("Failed to associate commit index file with an operation {op_id}")]
|
||||||
"Failed to associate commit index file with an operation {op_id}",
|
|
||||||
op_id = op_id.hex()
|
|
||||||
)]
|
|
||||||
AssociateIndex {
|
AssociateIndex {
|
||||||
op_id: OperationId,
|
op_id: OperationId,
|
||||||
source: io::Error,
|
source: io::Error,
|
||||||
@ -82,7 +79,7 @@ pub enum DefaultIndexStoreError {
|
|||||||
LoadIndex(ReadonlyIndexLoadError),
|
LoadIndex(ReadonlyIndexLoadError),
|
||||||
#[error("Failed to write commit index file")]
|
#[error("Failed to write commit index file")]
|
||||||
SaveIndex(#[source] io::Error),
|
SaveIndex(#[source] io::Error),
|
||||||
#[error("Failed to index commits at operation {op_id}", op_id = op_id.hex())]
|
#[error("Failed to index commits at operation {op_id}")]
|
||||||
IndexCommits {
|
IndexCommits {
|
||||||
op_id: OperationId,
|
op_id: OperationId,
|
||||||
source: BackendError,
|
source: BackendError,
|
||||||
|
@ -180,7 +180,7 @@ fn resolve_git_ref_to_commit_id(
|
|||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum GitImportError {
|
pub enum GitImportError {
|
||||||
#[error("Failed to read Git HEAD target commit {id}", id=id.hex())]
|
#[error("Failed to read Git HEAD target commit {id}")]
|
||||||
MissingHeadTarget {
|
MissingHeadTarget {
|
||||||
id: CommitId,
|
id: CommitId,
|
||||||
#[source]
|
#[source]
|
||||||
|
@ -703,7 +703,7 @@ fn deserialize_extras(commit: &mut Commit, bytes: &[u8]) {
|
|||||||
/// Returns `RefEdit` that will create a ref in `refs/jj/keep` if not exist.
|
/// Returns `RefEdit` that will create a ref in `refs/jj/keep` if not exist.
|
||||||
/// Used for preventing GC of commits we create.
|
/// Used for preventing GC of commits we create.
|
||||||
fn to_no_gc_ref_update(id: &CommitId) -> gix::refs::transaction::RefEdit {
|
fn to_no_gc_ref_update(id: &CommitId) -> gix::refs::transaction::RefEdit {
|
||||||
let name = format!("{NO_GC_REF_NAMESPACE}{}", id.hex());
|
let name = format!("{NO_GC_REF_NAMESPACE}{id}");
|
||||||
let new = gix::refs::Target::Object(validate_git_object_id(id).unwrap());
|
let new = gix::refs::Target::Object(validate_git_object_id(id).unwrap());
|
||||||
let expected = gix::refs::transaction::PreviousValue::ExistingMustMatch(new.clone());
|
let expected = gix::refs::transaction::PreviousValue::ExistingMustMatch(new.clone());
|
||||||
gix::refs::transaction::RefEdit {
|
gix::refs::transaction::RefEdit {
|
||||||
|
@ -36,7 +36,6 @@ use crate::backend::TreeId;
|
|||||||
use crate::backend::TreeValue;
|
use crate::backend::TreeValue;
|
||||||
use crate::content_hash::ContentHash;
|
use crate::content_hash::ContentHash;
|
||||||
use crate::content_hash::DigestUpdate;
|
use crate::content_hash::DigestUpdate;
|
||||||
use crate::object_id::ObjectId;
|
|
||||||
use crate::repo_path::RepoPath;
|
use crate::repo_path::RepoPath;
|
||||||
use crate::store::Store;
|
use crate::store::Store;
|
||||||
use crate::tree::Tree;
|
use crate::tree::Tree;
|
||||||
@ -665,25 +664,25 @@ fn describe_conflict_term(value: &TreeValue) -> String {
|
|||||||
id,
|
id,
|
||||||
executable: false,
|
executable: false,
|
||||||
} => {
|
} => {
|
||||||
format!("file with id {}", id.hex())
|
format!("file with id {id}")
|
||||||
}
|
}
|
||||||
TreeValue::File {
|
TreeValue::File {
|
||||||
id,
|
id,
|
||||||
executable: true,
|
executable: true,
|
||||||
} => {
|
} => {
|
||||||
format!("executable file with id {}", id.hex())
|
format!("executable file with id {id}")
|
||||||
}
|
}
|
||||||
TreeValue::Symlink(id) => {
|
TreeValue::Symlink(id) => {
|
||||||
format!("symlink with id {}", id.hex())
|
format!("symlink with id {id}")
|
||||||
}
|
}
|
||||||
TreeValue::Tree(id) => {
|
TreeValue::Tree(id) => {
|
||||||
format!("tree with id {}", id.hex())
|
format!("tree with id {id}")
|
||||||
}
|
}
|
||||||
TreeValue::GitSubmodule(id) => {
|
TreeValue::GitSubmodule(id) => {
|
||||||
format!("Git submodule with id {}", id.hex())
|
format!("Git submodule with id {id}")
|
||||||
}
|
}
|
||||||
TreeValue::Conflict(id) => {
|
TreeValue::Conflict(id) => {
|
||||||
format!("Conflict with id {}", id.hex())
|
format!("Conflict with id {id}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,22 +32,22 @@ pub trait ObjectId {
|
|||||||
// ```no_run
|
// ```no_run
|
||||||
// id_type!(
|
// id_type!(
|
||||||
// /// My favorite id type.
|
// /// My favorite id type.
|
||||||
// pub MyId
|
// pub MyId { hex() }
|
||||||
// );
|
// );
|
||||||
// ```
|
// ```
|
||||||
macro_rules! id_type {
|
macro_rules! id_type {
|
||||||
( $(#[$attr:meta])*
|
( $(#[$attr:meta])*
|
||||||
$vis:vis $name:ident
|
$vis:vis $name:ident { $hex_method:ident() }
|
||||||
) => {
|
) => {
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
#[derive(ContentHash, PartialEq, Eq, PartialOrd, Ord, Clone, Hash)]
|
#[derive(ContentHash, PartialEq, Eq, PartialOrd, Ord, Clone, Hash)]
|
||||||
$vis struct $name(Vec<u8>);
|
$vis struct $name(Vec<u8>);
|
||||||
$crate::object_id::impl_id_type!($name);
|
$crate::object_id::impl_id_type!($name, $hex_method);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_id_type {
|
macro_rules! impl_id_type {
|
||||||
($name:ident) => {
|
($name:ident, $hex_method:ident) => {
|
||||||
impl $name {
|
impl $name {
|
||||||
pub fn new(value: Vec<u8>) -> Self {
|
pub fn new(value: Vec<u8>) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
@ -73,10 +73,17 @@ macro_rules! impl_id_type {
|
|||||||
|
|
||||||
impl std::fmt::Debug for $name {
|
impl std::fmt::Debug for $name {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||||
|
// TODO: should we use $hex_method here?
|
||||||
f.debug_tuple(stringify!($name)).field(&self.hex()).finish()
|
f.debug_tuple(stringify!($name)).field(&self.hex()).finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for $name {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||||
|
f.pad(&self.$hex_method())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl crate::object_id::ObjectId for $name {
|
impl crate::object_id::ObjectId for $name {
|
||||||
fn object_type(&self) -> String {
|
fn object_type(&self) -> String {
|
||||||
stringify!($name)
|
stringify!($name)
|
||||||
@ -217,8 +224,20 @@ impl<T: Clone> PrefixResolution<T> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::backend::ChangeId;
|
||||||
use crate::backend::CommitId;
|
use crate::backend::CommitId;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_display_object_id() {
|
||||||
|
let commit_id = CommitId::from_hex("deadbeef0123");
|
||||||
|
assert_eq!(format!("{commit_id}"), "deadbeef0123");
|
||||||
|
assert_eq!(format!("{commit_id:.6}"), "deadbe");
|
||||||
|
|
||||||
|
let change_id = ChangeId::from_hex("deadbeef0123");
|
||||||
|
assert_eq!(format!("{change_id}"), "mlpmollkzyxw");
|
||||||
|
assert_eq!(format!("{change_id:.6}"), "mlpmol");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hex_prefix_prefixes() {
|
fn test_hex_prefix_prefixes() {
|
||||||
let prefix = HexPrefix::new("").unwrap();
|
let prefix = HexPrefix::new("").unwrap();
|
||||||
|
@ -63,8 +63,8 @@ impl WorkspaceId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
id_type!(pub ViewId);
|
id_type!(pub ViewId { hex() });
|
||||||
id_type!(pub OperationId);
|
id_type!(pub OperationId { hex() });
|
||||||
|
|
||||||
#[derive(ContentHash, PartialEq, Eq, Hash, Clone, Debug)]
|
#[derive(ContentHash, PartialEq, Eq, Hash, Clone, Debug)]
|
||||||
pub struct RefTarget {
|
pub struct RefTarget {
|
||||||
|
@ -1071,7 +1071,7 @@ fn test_evaluate_expression_heads() {
|
|||||||
|
|
||||||
// Heads of a single commit is that commit
|
// Heads of a single commit is that commit
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("heads({})", commit2.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("heads({})", commit2.id())),
|
||||||
vec![commit2.id().clone()]
|
vec![commit2.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1079,7 +1079,7 @@ fn test_evaluate_expression_heads() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("heads({} | {})", commit2.id().hex(), commit3.id().hex())
|
&format!("heads({} | {})", commit2.id(), commit3.id())
|
||||||
),
|
),
|
||||||
vec![commit3.id().clone()]
|
vec![commit3.id().clone()]
|
||||||
);
|
);
|
||||||
@ -1089,7 +1089,7 @@ fn test_evaluate_expression_heads() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("heads({} | {})", commit1.id().hex(), commit3.id().hex())
|
&format!("heads({} | {})", commit1.id(), commit3.id())
|
||||||
),
|
),
|
||||||
vec![commit3.id().clone()]
|
vec![commit3.id().clone()]
|
||||||
);
|
);
|
||||||
@ -1098,7 +1098,7 @@ fn test_evaluate_expression_heads() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("heads({} | {})", commit3.id().hex(), commit4.id().hex())
|
&format!("heads({} | {})", commit3.id(), commit4.id())
|
||||||
),
|
),
|
||||||
vec![commit4.id().clone(), commit3.id().clone()]
|
vec![commit4.id().clone(), commit3.id().clone()]
|
||||||
);
|
);
|
||||||
@ -1135,7 +1135,7 @@ fn test_evaluate_expression_roots() {
|
|||||||
|
|
||||||
// Roots of a single commit is that commit
|
// Roots of a single commit is that commit
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("roots({})", commit2.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("roots({})", commit2.id())),
|
||||||
vec![commit2.id().clone()]
|
vec![commit2.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1143,7 +1143,7 @@ fn test_evaluate_expression_roots() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("roots({} | {})", commit2.id().hex(), commit3.id().hex())
|
&format!("roots({} | {})", commit2.id(), commit3.id())
|
||||||
),
|
),
|
||||||
vec![commit2.id().clone()]
|
vec![commit2.id().clone()]
|
||||||
);
|
);
|
||||||
@ -1153,7 +1153,7 @@ fn test_evaluate_expression_roots() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("roots({} | {})", commit1.id().hex(), commit3.id().hex())
|
&format!("roots({} | {})", commit1.id(), commit3.id())
|
||||||
),
|
),
|
||||||
vec![commit1.id().clone()]
|
vec![commit1.id().clone()]
|
||||||
);
|
);
|
||||||
@ -1195,53 +1195,44 @@ fn test_evaluate_expression_parents() {
|
|||||||
|
|
||||||
// Can find parents of a merge commit
|
// Can find parents of a merge commit
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("{}-", commit4.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("{}-", commit4.id())),
|
||||||
vec![commit3.id().clone(), commit2.id().clone()]
|
vec![commit3.id().clone(), commit2.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Parents of all commits in input are returned
|
// Parents of all commits in input are returned
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("({} | {})-", commit2.id(), commit3.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("({} | {})-", commit2.id().hex(), commit3.id().hex())
|
|
||||||
),
|
|
||||||
vec![commit1.id().clone(), root_commit.id().clone()]
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Parents already in input set are returned
|
// Parents already in input set are returned
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("({} | {})-", commit1.id(), commit2.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("({} | {})-", commit1.id().hex(), commit2.id().hex())
|
|
||||||
),
|
|
||||||
vec![commit1.id().clone(), root_commit.id().clone()]
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Parents shared among commits in input are not repeated
|
// Parents shared among commits in input are not repeated
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("({} | {})-", commit4.id(), commit5.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("({} | {})-", commit4.id().hex(), commit5.id().hex())
|
|
||||||
),
|
|
||||||
vec![commit3.id().clone(), commit2.id().clone()]
|
vec![commit3.id().clone(), commit2.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Can find parents of parents, which may be optimized to single query
|
// Can find parents of parents, which may be optimized to single query
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("{}--", commit4.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("{}--", commit4.id())),
|
||||||
vec![commit1.id().clone(), root_commit.id().clone()]
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("({} | {})--", commit4.id().hex(), commit5.id().hex())
|
&format!("({} | {})--", commit4.id(), commit5.id())
|
||||||
),
|
),
|
||||||
vec![commit1.id().clone(), root_commit.id().clone()]
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("({} | {})--", commit4.id().hex(), commit2.id().hex())
|
&format!("({} | {})--", commit4.id(), commit2.id())
|
||||||
),
|
),
|
||||||
vec![commit1.id().clone(), root_commit.id().clone()]
|
vec![commit1.id().clone(), root_commit.id().clone()]
|
||||||
);
|
);
|
||||||
@ -1287,10 +1278,7 @@ fn test_evaluate_expression_children() {
|
|||||||
// Children of all commits in input are returned, including those already in the
|
// Children of all commits in input are returned, including those already in the
|
||||||
// input set
|
// input set
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("({} | {})+", commit1.id(), commit2.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("({} | {})+", commit1.id().hex(), commit2.id().hex())
|
|
||||||
),
|
|
||||||
vec![
|
vec![
|
||||||
commit4.id().clone(),
|
commit4.id().clone(),
|
||||||
commit3.id().clone(),
|
commit3.id().clone(),
|
||||||
@ -1300,10 +1288,7 @@ fn test_evaluate_expression_children() {
|
|||||||
|
|
||||||
// Children shared among commits in input are not repeated
|
// Children shared among commits in input are not repeated
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("({} | {})+", commit3.id(), commit4.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("({} | {})+", commit3.id().hex(), commit4.id().hex())
|
|
||||||
),
|
|
||||||
vec![commit5.id().clone()]
|
vec![commit5.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1313,7 +1298,7 @@ fn test_evaluate_expression_children() {
|
|||||||
vec![commit4.id().clone(), commit2.id().clone()]
|
vec![commit4.id().clone(), commit2.id().clone()]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("(root() | {})++", commit1.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("(root() | {})++", commit1.id())),
|
||||||
vec![
|
vec![
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
commit4.id().clone(),
|
commit4.id().clone(),
|
||||||
@ -1324,7 +1309,7 @@ fn test_evaluate_expression_children() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("({} | {})++", commit4.id().hex(), commit2.id().hex())
|
&format!("({} | {})++", commit4.id(), commit2.id())
|
||||||
),
|
),
|
||||||
vec![commit6.id().clone(), commit5.id().clone()]
|
vec![commit6.id().clone(), commit5.id().clone()]
|
||||||
);
|
);
|
||||||
@ -1357,7 +1342,7 @@ fn test_evaluate_expression_ancestors() {
|
|||||||
// Can find ancestors of a specific commit. Commits reachable via multiple paths
|
// Can find ancestors of a specific commit. Commits reachable via multiple paths
|
||||||
// are not repeated.
|
// are not repeated.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("::{}", commit4.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("::{}", commit4.id())),
|
||||||
vec![
|
vec![
|
||||||
commit4.id().clone(),
|
commit4.id().clone(),
|
||||||
commit3.id().clone(),
|
commit3.id().clone(),
|
||||||
@ -1370,7 +1355,7 @@ fn test_evaluate_expression_ancestors() {
|
|||||||
// Can find ancestors of parents or parents of ancestors, which may be optimized
|
// Can find ancestors of parents or parents of ancestors, which may be optimized
|
||||||
// to single query
|
// to single query
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("::({}-)", commit4.id().hex()),),
|
resolve_commit_ids(mut_repo, &format!("::({}-)", commit4.id())),
|
||||||
vec![
|
vec![
|
||||||
commit3.id().clone(),
|
commit3.id().clone(),
|
||||||
commit2.id().clone(),
|
commit2.id().clone(),
|
||||||
@ -1381,7 +1366,7 @@ fn test_evaluate_expression_ancestors() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("(::({}|{}))-", commit3.id().hex(), commit2.id().hex()),
|
&format!("(::({}|{}))-", commit3.id(), commit2.id()),
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit2.id().clone(),
|
commit2.id().clone(),
|
||||||
@ -1392,7 +1377,7 @@ fn test_evaluate_expression_ancestors() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("::(({}|{})-)", commit3.id().hex(), commit2.id().hex()),
|
&format!("::(({}|{})-)", commit3.id(), commit2.id()),
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit2.id().clone(),
|
commit2.id().clone(),
|
||||||
@ -1403,15 +1388,15 @@ fn test_evaluate_expression_ancestors() {
|
|||||||
|
|
||||||
// Can find last n ancestors of a commit
|
// Can find last n ancestors of a commit
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("ancestors({}, 0)", commit2.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("ancestors({}, 0)", commit2.id())),
|
||||||
vec![]
|
vec![]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("ancestors({}, 1)", commit3.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("ancestors({}, 1)", commit3.id())),
|
||||||
vec![commit3.id().clone()]
|
vec![commit3.id().clone()]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("ancestors({}, 3)", commit3.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("ancestors({}, 3)", commit3.id())),
|
||||||
vec![
|
vec![
|
||||||
commit3.id().clone(),
|
commit3.id().clone(),
|
||||||
commit2.id().clone(),
|
commit2.id().clone(),
|
||||||
@ -1440,28 +1425,19 @@ fn test_evaluate_expression_range() {
|
|||||||
|
|
||||||
// Linear range
|
// Linear range
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{}..{}", commit1.id(), commit3.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{}..{}", commit1.id().hex(), commit3.id().hex())
|
|
||||||
),
|
|
||||||
vec![commit3.id().clone(), commit2.id().clone()]
|
vec![commit3.id().clone(), commit2.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Empty range (descendant first)
|
// Empty range (descendant first)
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{}..{}", commit3.id(), commit1.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{}..{}", commit3.id().hex(), commit1.id().hex())
|
|
||||||
),
|
|
||||||
vec![]
|
vec![]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Range including a merge
|
// Range including a merge
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{}..{}", commit1.id(), commit4.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{}..{}", commit1.id().hex(), commit4.id().hex())
|
|
||||||
),
|
|
||||||
vec![
|
vec![
|
||||||
commit4.id().clone(),
|
commit4.id().clone(),
|
||||||
commit3.id().clone(),
|
commit3.id().clone(),
|
||||||
@ -1471,31 +1447,25 @@ fn test_evaluate_expression_range() {
|
|||||||
|
|
||||||
// Range including merge ancestors: commit4-- == root | commit2
|
// Range including merge ancestors: commit4-- == root | commit2
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{}--..{}", commit4.id(), commit3.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{}--..{}", commit4.id().hex(), commit3.id().hex())
|
|
||||||
),
|
|
||||||
vec![commit3.id().clone()]
|
vec![commit3.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Sibling commits
|
// Sibling commits
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{}..{}", commit2.id(), commit3.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{}..{}", commit2.id().hex(), commit3.id().hex())
|
|
||||||
),
|
|
||||||
vec![commit3.id().clone()]
|
vec![commit3.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Left operand defaults to root()
|
// Left operand defaults to root()
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("..{}", commit2.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("..{}", commit2.id())),
|
||||||
vec![commit2.id().clone(), commit1.id().clone()]
|
vec![commit2.id().clone(), commit1.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Right operand defaults to visible_heads()
|
// Right operand defaults to visible_heads()
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("{}..", commit2.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("{}..", commit2.id())),
|
||||||
vec![commit4.id().clone(), commit3.id().clone()]
|
vec![commit4.id().clone(), commit3.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1534,10 +1504,7 @@ fn test_evaluate_expression_dag_range() {
|
|||||||
|
|
||||||
// Linear range
|
// Linear range
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{}::{}", root_commit_id, commit2.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{}::{}", root_commit_id.hex(), commit2.id().hex())
|
|
||||||
),
|
|
||||||
vec![
|
vec![
|
||||||
commit2.id().clone(),
|
commit2.id().clone(),
|
||||||
commit1.id().clone(),
|
commit1.id().clone(),
|
||||||
@ -1547,16 +1514,13 @@ fn test_evaluate_expression_dag_range() {
|
|||||||
|
|
||||||
// Empty range
|
// Empty range
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{}::{}", commit2.id(), commit4.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{}::{}", commit2.id().hex(), commit4.id().hex())
|
|
||||||
),
|
|
||||||
vec![]
|
vec![]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Empty root
|
// Empty root
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("none()::{}", commit5.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("none()::{}", commit5.id())),
|
||||||
vec![],
|
vec![],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1564,12 +1528,7 @@ fn test_evaluate_expression_dag_range() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!("({}|{})::{}", commit1.id(), commit2.id(), commit3.id())
|
||||||
"({}|{})::{}",
|
|
||||||
commit1.id().hex(),
|
|
||||||
commit2.id().hex(),
|
|
||||||
commit3.id().hex()
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit3.id().clone(),
|
commit3.id().clone(),
|
||||||
@ -1580,10 +1539,7 @@ fn test_evaluate_expression_dag_range() {
|
|||||||
|
|
||||||
// Including a merge
|
// Including a merge
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{}::{}", commit1.id(), commit5.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{}::{}", commit1.id().hex(), commit5.id().hex())
|
|
||||||
),
|
|
||||||
vec![
|
vec![
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
commit4.id().clone(),
|
commit4.id().clone(),
|
||||||
@ -1595,10 +1551,7 @@ fn test_evaluate_expression_dag_range() {
|
|||||||
|
|
||||||
// Including a merge, but ancestors only from one side
|
// Including a merge, but ancestors only from one side
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{}::{}", commit2.id(), commit5.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{}::{}", commit2.id().hex(), commit5.id().hex())
|
|
||||||
),
|
|
||||||
vec![
|
vec![
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
commit3.id().clone(),
|
commit3.id().clone(),
|
||||||
@ -1649,11 +1602,7 @@ fn test_evaluate_expression_connected() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!("connected({} | {})", root_commit_id, commit2.id())
|
||||||
"connected({} | {})",
|
|
||||||
root_commit_id.hex(),
|
|
||||||
commit2.id().hex()
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
vec![commit2.id().clone(), commit1.id().clone(), root_commit_id]
|
vec![commit2.id().clone(), commit1.id().clone(), root_commit_id]
|
||||||
);
|
);
|
||||||
@ -1662,7 +1611,7 @@ fn test_evaluate_expression_connected() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("connected({} | {})", commit2.id().hex(), commit4.id().hex())
|
&format!("connected({} | {})", commit2.id(), commit4.id())
|
||||||
),
|
),
|
||||||
vec![commit4.id().clone(), commit2.id().clone()]
|
vec![commit4.id().clone(), commit2.id().clone()]
|
||||||
);
|
);
|
||||||
@ -1671,7 +1620,7 @@ fn test_evaluate_expression_connected() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("connected({} | {})", commit1.id().hex(), commit5.id().hex())
|
&format!("connected({} | {})", commit1.id(), commit5.id())
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
@ -1686,7 +1635,7 @@ fn test_evaluate_expression_connected() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("connected({} | {})", commit2.id().hex(), commit5.id().hex())
|
&format!("connected({} | {})", commit2.id(), commit5.id())
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
@ -1748,8 +1697,8 @@ fn test_evaluate_expression_reachable() {
|
|||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!(
|
||||||
"reachable({}, all() ~ ::{})",
|
"reachable({}, all() ~ ::{})",
|
||||||
graph1commit2.id().hex(),
|
graph1commit2.id(),
|
||||||
graph1commit1.id().hex()
|
graph1commit1.id()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
vec![graph1commit3.id().clone(), graph1commit2.id().clone(),]
|
vec![graph1commit3.id().clone(), graph1commit2.id().clone(),]
|
||||||
@ -1759,8 +1708,8 @@ fn test_evaluate_expression_reachable() {
|
|||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!(
|
||||||
"reachable({}, all() ~ ::{})",
|
"reachable({}, all() ~ ::{})",
|
||||||
graph1commit2.id().hex(),
|
graph1commit2.id(),
|
||||||
graph1commit3.id().hex()
|
graph1commit3.id()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
vec![]
|
vec![]
|
||||||
@ -1774,7 +1723,7 @@ fn test_evaluate_expression_reachable() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("reachable({}, all() ~ root())", commit.id().hex())
|
&format!("reachable({}, all() ~ root())", commit.id())
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
graph1commit3.id().clone(),
|
graph1commit3.id().clone(),
|
||||||
@ -1793,7 +1742,7 @@ fn test_evaluate_expression_reachable() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("reachable({}, all() ~ root())", commit.id().hex())
|
&format!("reachable({}, all() ~ root())", commit.id())
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
graph2commit3.id().clone(),
|
graph2commit3.id().clone(),
|
||||||
@ -1820,7 +1769,7 @@ fn test_evaluate_expression_reachable() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("reachable({}, all() ~ root())", commit.id().hex())
|
&format!("reachable({}, all() ~ root())", commit.id())
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
graph3commit7.id().clone(),
|
graph3commit7.id().clone(),
|
||||||
@ -1842,8 +1791,8 @@ fn test_evaluate_expression_reachable() {
|
|||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!(
|
||||||
"reachable({}, all() ~ ::{})",
|
"reachable({}, all() ~ ::{})",
|
||||||
graph3commit4.id().hex(),
|
graph3commit4.id(),
|
||||||
graph3commit5.id().hex()
|
graph3commit5.id()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
@ -1902,7 +1851,7 @@ fn test_evaluate_expression_descendants() {
|
|||||||
|
|
||||||
// Can find descendants of a specific commit
|
// Can find descendants of a specific commit
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("{}::", commit2.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("{}::", commit2.id())),
|
||||||
vec![
|
vec![
|
||||||
commit6.id().clone(),
|
commit6.id().clone(),
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
@ -1914,7 +1863,7 @@ fn test_evaluate_expression_descendants() {
|
|||||||
// Can find descendants of children or children of descendants, which may be
|
// Can find descendants of children or children of descendants, which may be
|
||||||
// optimized to single query
|
// optimized to single query
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("({}+)::", commit1.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("({}+)::", commit1.id())),
|
||||||
vec![
|
vec![
|
||||||
commit6.id().clone(),
|
commit6.id().clone(),
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
@ -1924,7 +1873,7 @@ fn test_evaluate_expression_descendants() {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("({}++)::", commit1.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("({}++)::", commit1.id())),
|
||||||
vec![
|
vec![
|
||||||
commit6.id().clone(),
|
commit6.id().clone(),
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
@ -1934,7 +1883,7 @@ fn test_evaluate_expression_descendants() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("(({}|{})::)+", commit4.id().hex(), commit2.id().hex()),
|
&format!("(({}|{})::)+", commit4.id(), commit2.id()),
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit6.id().clone(),
|
commit6.id().clone(),
|
||||||
@ -1945,7 +1894,7 @@ fn test_evaluate_expression_descendants() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("(({}|{})+)::", commit4.id().hex(), commit2.id().hex()),
|
&format!("(({}|{})+)::", commit4.id(), commit2.id()),
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit6.id().clone(),
|
commit6.id().clone(),
|
||||||
@ -1956,15 +1905,15 @@ fn test_evaluate_expression_descendants() {
|
|||||||
|
|
||||||
// Can find next n descendants of a commit
|
// Can find next n descendants of a commit
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("descendants({}, 0)", commit2.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("descendants({}, 0)", commit2.id())),
|
||||||
vec![]
|
vec![]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("descendants({}, 1)", commit3.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("descendants({}, 1)", commit3.id())),
|
||||||
vec![commit3.id().clone()]
|
vec![commit3.id().clone()]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("descendants({}, 3)", commit3.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("descendants({}, 3)", commit3.id())),
|
||||||
vec![
|
vec![
|
||||||
commit6.id().clone(),
|
commit6.id().clone(),
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
@ -2485,7 +2434,7 @@ fn test_evaluate_expression_merges() {
|
|||||||
);
|
);
|
||||||
// Searches only among candidates if specified
|
// Searches only among candidates if specified
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("::{} & merges()", commit5.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("::{} & merges()", commit5.id())),
|
||||||
vec![commit5.id().clone()]
|
vec![commit5.id().clone()]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2611,7 +2560,7 @@ fn test_evaluate_expression_author() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("root().. & (author(name1) | {})", commit3.id().hex())
|
&format!("root().. & (author(name1) | {})", commit3.id())
|
||||||
),
|
),
|
||||||
vec![commit3.id().clone(), commit1.id().clone()]
|
vec![commit3.id().clone(), commit1.id().clone()]
|
||||||
);
|
);
|
||||||
@ -2812,10 +2761,7 @@ fn test_evaluate_expression_mine() {
|
|||||||
);
|
);
|
||||||
// Filter by union of pure predicate and set
|
// Filter by union of pure predicate and set
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("root().. & (mine() | {})", commit1.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("root().. & (mine() | {})", commit1.id().hex())
|
|
||||||
),
|
|
||||||
vec![
|
vec![
|
||||||
commit3.id().clone(),
|
commit3.id().clone(),
|
||||||
commit2.id().clone(),
|
commit2.id().clone(),
|
||||||
@ -3048,7 +2994,7 @@ fn test_evaluate_expression_union() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("::{} | ::{}", commit4.id().hex(), commit5.id().hex())
|
&format!("::{} | ::{}", commit4.id(), commit5.id())
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit5.id().clone(),
|
commit5.id().clone(),
|
||||||
@ -3066,9 +3012,9 @@ fn test_evaluate_expression_union() {
|
|||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!(
|
||||||
"(::{} ~ ::{}) | ::{}",
|
"(::{} ~ ::{}) | ::{}",
|
||||||
commit4.id().hex(),
|
commit4.id(),
|
||||||
commit2.id().hex(),
|
commit2.id(),
|
||||||
commit5.id().hex()
|
commit5.id()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
@ -3087,9 +3033,9 @@ fn test_evaluate_expression_union() {
|
|||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!(
|
||||||
"(::{} ~ ::{}) | {}",
|
"(::{} ~ ::{}) | {}",
|
||||||
commit4.id().hex(),
|
commit4.id(),
|
||||||
commit2.id().hex(),
|
commit2.id(),
|
||||||
commit5.id().hex(),
|
commit5.id(),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
@ -3114,7 +3060,7 @@ fn test_evaluate_expression_machine_generated_union() {
|
|||||||
|
|
||||||
// This query shouldn't trigger stack overflow. Here we use "x::y" in case
|
// This query shouldn't trigger stack overflow. Here we use "x::y" in case
|
||||||
// we had optimization path for trivial "commit_id|.." expression.
|
// we had optimization path for trivial "commit_id|.." expression.
|
||||||
let revset_str = iter::repeat(format!("({}::{})", commit1.id().hex(), commit2.id().hex()))
|
let revset_str = iter::repeat(format!("({}::{})", commit1.id(), commit2.id()))
|
||||||
.take(5000)
|
.take(5000)
|
||||||
.join("|");
|
.join("|");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -3143,7 +3089,7 @@ fn test_evaluate_expression_intersection() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("::{} & ::{}", commit4.id().hex(), commit5.id().hex())
|
&format!("::{} & ::{}", commit4.id(), commit5.id())
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit2.id().clone(),
|
commit2.id().clone(),
|
||||||
@ -3154,10 +3100,7 @@ fn test_evaluate_expression_intersection() {
|
|||||||
|
|
||||||
// Intersection of disjoint sets
|
// Intersection of disjoint sets
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(mut_repo, &format!("{} & {}", commit4.id(), commit2.id())),
|
||||||
mut_repo,
|
|
||||||
&format!("{} & {}", commit4.id().hex(), commit2.id().hex())
|
|
||||||
),
|
|
||||||
vec![]
|
vec![]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -3180,7 +3123,7 @@ fn test_evaluate_expression_difference() {
|
|||||||
|
|
||||||
// Difference from all
|
// Difference from all
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("~::{}", commit5.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("~::{}", commit5.id())),
|
||||||
vec![commit4.id().clone(), commit3.id().clone()]
|
vec![commit4.id().clone(), commit3.id().clone()]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -3188,28 +3131,28 @@ fn test_evaluate_expression_difference() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("::{} ~ ::{}", commit4.id().hex(), commit5.id().hex())
|
&format!("::{} ~ ::{}", commit4.id(), commit5.id())
|
||||||
),
|
),
|
||||||
vec![commit4.id().clone(), commit3.id().clone()]
|
vec![commit4.id().clone(), commit3.id().clone()]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("::{} ~ ::{}", commit5.id().hex(), commit4.id().hex())
|
&format!("::{} ~ ::{}", commit5.id(), commit4.id())
|
||||||
),
|
),
|
||||||
vec![commit5.id().clone()]
|
vec![commit5.id().clone()]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("~::{} & ::{}", commit4.id().hex(), commit5.id().hex())
|
&format!("~::{} & ::{}", commit4.id(), commit5.id())
|
||||||
),
|
),
|
||||||
vec![commit5.id().clone()]
|
vec![commit5.id().clone()]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!("::{} ~ ::{}", commit4.id().hex(), commit2.id().hex())
|
&format!("::{} ~ ::{}", commit4.id(), commit2.id())
|
||||||
),
|
),
|
||||||
vec![commit4.id().clone(), commit3.id().clone()]
|
vec![commit4.id().clone(), commit3.id().clone()]
|
||||||
);
|
);
|
||||||
@ -3218,12 +3161,7 @@ fn test_evaluate_expression_difference() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!("::{} ~ {} ~ {}", commit4.id(), commit2.id(), commit3.id())
|
||||||
"::{} ~ {} ~ {}",
|
|
||||||
commit4.id().hex(),
|
|
||||||
commit2.id().hex(),
|
|
||||||
commit3.id().hex()
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
vec![
|
vec![
|
||||||
commit4.id().clone(),
|
commit4.id().clone(),
|
||||||
@ -3238,10 +3176,10 @@ fn test_evaluate_expression_difference() {
|
|||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!(
|
||||||
"(::{} ~ ::{}) ~ (::{} ~ ::{})",
|
"(::{} ~ ::{}) ~ (::{} ~ ::{})",
|
||||||
commit4.id().hex(),
|
commit4.id(),
|
||||||
commit1.id().hex(),
|
commit1.id(),
|
||||||
commit3.id().hex(),
|
commit3.id(),
|
||||||
commit1.id().hex(),
|
commit1.id(),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
vec![commit4.id().clone()]
|
vec![commit4.id().clone()]
|
||||||
@ -3302,10 +3240,7 @@ fn test_evaluate_expression_filter_combinator() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(
|
resolve_commit_ids(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!("{}.. & (description(1) | description(2))", commit1.id()),
|
||||||
"{}.. & (description(1) | description(2))",
|
|
||||||
commit1.id().hex(),
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
vec![commit2.id().clone()],
|
vec![commit2.id().clone()],
|
||||||
);
|
);
|
||||||
@ -3413,10 +3348,7 @@ fn test_evaluate_expression_file() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids_in_workspace(
|
resolve_commit_ids_in_workspace(
|
||||||
mut_repo,
|
mut_repo,
|
||||||
&format!(
|
&format!(r#"{}:: & files("added_modified_clean")"#, commit2.id()),
|
||||||
r#"{}:: & files("added_modified_clean")"#,
|
|
||||||
commit2.id().hex()
|
|
||||||
),
|
|
||||||
&test_workspace.workspace,
|
&test_workspace.workspace,
|
||||||
Some(test_workspace.workspace.workspace_root()),
|
Some(test_workspace.workspace.workspace_root()),
|
||||||
),
|
),
|
||||||
@ -3425,7 +3357,7 @@ fn test_evaluate_expression_file() {
|
|||||||
|
|
||||||
// empty() revset, which is identical to ~file(".")
|
// empty() revset, which is identical to ~file(".")
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
resolve_commit_ids(mut_repo, &format!("{}:: & empty()", commit1.id().hex())),
|
resolve_commit_ids(mut_repo, &format!("{}:: & empty()", commit1.id())),
|
||||||
vec![commit4.id().clone()]
|
vec![commit4.id().clone()]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -430,18 +430,13 @@ pub fn dump_tree(store: &Arc<Store>, tree_id: &MergedTreeId) -> String {
|
|||||||
Ok(Some(TreeValue::File { id, executable: _ })) => {
|
Ok(Some(TreeValue::File { id, executable: _ })) => {
|
||||||
let file_buf = read_file(store, &path, &id);
|
let file_buf = read_file(store, &path, &id);
|
||||||
let file_contents = String::from_utf8_lossy(&file_buf);
|
let file_contents = String::from_utf8_lossy(&file_buf);
|
||||||
writeln!(
|
writeln!(&mut buf, " file {path:?} ({id}): {file_contents:?}").unwrap();
|
||||||
&mut buf,
|
|
||||||
" file {path:?} ({}): {file_contents:?}",
|
|
||||||
id.hex()
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
Ok(Some(TreeValue::Symlink(id))) => {
|
Ok(Some(TreeValue::Symlink(id))) => {
|
||||||
writeln!(&mut buf, " symlink {path:?} ({})", id.hex()).unwrap();
|
writeln!(&mut buf, " symlink {path:?} ({id})").unwrap();
|
||||||
}
|
}
|
||||||
Ok(Some(TreeValue::GitSubmodule(id))) => {
|
Ok(Some(TreeValue::GitSubmodule(id))) => {
|
||||||
writeln!(&mut buf, " submodule {path:?} ({})", id.hex()).unwrap();
|
writeln!(&mut buf, " submodule {path:?} ({id})").unwrap();
|
||||||
}
|
}
|
||||||
entry => {
|
entry => {
|
||||||
unimplemented!("dumping tree entry {entry:?}");
|
unimplemented!("dumping tree entry {entry:?}");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user