mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 16:53:25 +00:00
refactor: mark Timestamp
struct as Copy
This commit is contained in:
parent
76f40e5990
commit
8dd3003bec
9 changed files with 26 additions and 26 deletions
|
@ -122,7 +122,7 @@ new working-copy commit.
|
||||||
let new_author = Signature {
|
let new_author = Signature {
|
||||||
name,
|
name,
|
||||||
email,
|
email,
|
||||||
timestamp: commit_builder.author().timestamp.clone(),
|
timestamp: commit_builder.author().timestamp,
|
||||||
};
|
};
|
||||||
commit_builder.set_author(new_author);
|
commit_builder.set_author(new_author);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ pub(crate) fn cmd_describe(
|
||||||
let new_author = Signature {
|
let new_author = Signature {
|
||||||
name,
|
name,
|
||||||
email,
|
email,
|
||||||
timestamp: commit.author().timestamp.clone(),
|
timestamp: commit.author().timestamp,
|
||||||
};
|
};
|
||||||
commit_builder.set_author(new_author);
|
commit_builder.set_author(new_author);
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ pub(crate) fn cmd_describe(
|
||||||
let new_author = Signature {
|
let new_author = Signature {
|
||||||
name,
|
name,
|
||||||
email,
|
email,
|
||||||
timestamp: commit_builder.author().timestamp.clone(),
|
timestamp: commit_builder.author().timestamp,
|
||||||
};
|
};
|
||||||
commit_builder = commit_builder.set_author(new_author);
|
commit_builder = commit_builder.set_author(new_author);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,8 +279,8 @@ fn builtin_operation_methods() -> OperationTemplateBuildMethodFnMap<Operation> {
|
||||||
map.insert("time", |_language, _build_ctx, self_property, function| {
|
map.insert("time", |_language, _build_ctx, self_property, function| {
|
||||||
function.expect_no_arguments()?;
|
function.expect_no_arguments()?;
|
||||||
let out_property = self_property.map(|op| TimestampRange {
|
let out_property = self_property.map(|op| TimestampRange {
|
||||||
start: op.metadata().start_time.clone(),
|
start: op.metadata().start_time,
|
||||||
end: op.metadata().end_time.clone(),
|
end: op.metadata().end_time,
|
||||||
});
|
});
|
||||||
Ok(L::wrap_timestamp_range(out_property))
|
Ok(L::wrap_timestamp_range(out_property))
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,7 +53,7 @@ id_type!(pub ConflictId);
|
||||||
#[derive(ContentHash, Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
|
#[derive(ContentHash, Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
|
||||||
pub struct MillisSinceEpoch(pub i64);
|
pub struct MillisSinceEpoch(pub i64);
|
||||||
|
|
||||||
#[derive(ContentHash, Debug, PartialEq, Eq, Clone, PartialOrd, Ord)]
|
#[derive(ContentHash, Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
|
||||||
pub struct Timestamp {
|
pub struct Timestamp {
|
||||||
pub timestamp: MillisSinceEpoch,
|
pub timestamp: MillisSinceEpoch,
|
||||||
// time zone offset in minutes
|
// time zone offset in minutes
|
||||||
|
|
|
@ -205,7 +205,7 @@ impl DetachedCommitBuilder {
|
||||||
&& commit.author.email == commit.committer.email
|
&& commit.author.email == commit.committer.email
|
||||||
&& predecessor.is_discardable(repo).unwrap_or_default()
|
&& predecessor.is_discardable(repo).unwrap_or_default()
|
||||||
{
|
{
|
||||||
commit.author.timestamp = commit.committer.timestamp.clone();
|
commit.author.timestamp = commit.committer.timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
DetachedCommitBuilder {
|
DetachedCommitBuilder {
|
||||||
|
|
|
@ -374,7 +374,7 @@ impl Operation {
|
||||||
tz_offset: 0,
|
tz_offset: 0,
|
||||||
};
|
};
|
||||||
let metadata = OperationMetadata {
|
let metadata = OperationMetadata {
|
||||||
start_time: timestamp.clone(),
|
start_time: timestamp,
|
||||||
end_time: timestamp,
|
end_time: timestamp,
|
||||||
description: "".to_string(),
|
description: "".to_string(),
|
||||||
hostname: "".to_string(),
|
hostname: "".to_string(),
|
||||||
|
|
|
@ -211,7 +211,7 @@ impl UserSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signature(&self) -> Signature {
|
pub fn signature(&self) -> Signature {
|
||||||
let timestamp = self.timestamp.clone().unwrap_or_else(Timestamp::now);
|
let timestamp = self.timestamp.unwrap_or_else(Timestamp::now);
|
||||||
Signature {
|
Signature {
|
||||||
name: self.user_name(),
|
name: self.user_name(),
|
||||||
email: self.user_email(),
|
email: self.user_email(),
|
||||||
|
|
|
@ -150,7 +150,7 @@ pub fn create_op_metadata(
|
||||||
let start_time = user_settings
|
let start_time = user_settings
|
||||||
.operation_timestamp()
|
.operation_timestamp()
|
||||||
.unwrap_or_else(Timestamp::now);
|
.unwrap_or_else(Timestamp::now);
|
||||||
let end_time = start_time.clone();
|
let end_time = start_time;
|
||||||
let hostname = user_settings.operation_hostname();
|
let hostname = user_settings.operation_hostname();
|
||||||
let username = user_settings.operation_username();
|
let username = user_settings.operation_username();
|
||||||
OperationMetadata {
|
OperationMetadata {
|
||||||
|
|
|
@ -2456,7 +2456,7 @@ fn test_evaluate_expression_author() {
|
||||||
.set_author(Signature {
|
.set_author(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp.clone(),
|
timestamp,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2465,7 +2465,7 @@ fn test_evaluate_expression_author() {
|
||||||
.set_author(Signature {
|
.set_author(Signature {
|
||||||
name: "name2".to_string(),
|
name: "name2".to_string(),
|
||||||
email: "email2".to_string(),
|
email: "email2".to_string(),
|
||||||
timestamp: timestamp.clone(),
|
timestamp,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2543,12 +2543,12 @@ fn test_evaluate_expression_author_date() {
|
||||||
.set_author(Signature {
|
.set_author(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp1.clone(),
|
timestamp: timestamp1,
|
||||||
})
|
})
|
||||||
.set_committer(Signature {
|
.set_committer(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp2.clone(),
|
timestamp: timestamp2,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2557,12 +2557,12 @@ fn test_evaluate_expression_author_date() {
|
||||||
.set_author(Signature {
|
.set_author(Signature {
|
||||||
name: "name2".to_string(),
|
name: "name2".to_string(),
|
||||||
email: "email2".to_string(),
|
email: "email2".to_string(),
|
||||||
timestamp: timestamp2.clone(),
|
timestamp: timestamp2,
|
||||||
})
|
})
|
||||||
.set_committer(Signature {
|
.set_committer(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp2.clone(),
|
timestamp: timestamp2,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2576,7 +2576,7 @@ fn test_evaluate_expression_author_date() {
|
||||||
.set_committer(Signature {
|
.set_committer(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp2.clone(),
|
timestamp: timestamp2,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2610,12 +2610,12 @@ fn test_evaluate_expression_committer_date() {
|
||||||
.set_author(Signature {
|
.set_author(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp2.clone(),
|
timestamp: timestamp2,
|
||||||
})
|
})
|
||||||
.set_committer(Signature {
|
.set_committer(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp1.clone(),
|
timestamp: timestamp1,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2624,12 +2624,12 @@ fn test_evaluate_expression_committer_date() {
|
||||||
.set_author(Signature {
|
.set_author(Signature {
|
||||||
name: "name2".to_string(),
|
name: "name2".to_string(),
|
||||||
email: "email2".to_string(),
|
email: "email2".to_string(),
|
||||||
timestamp: timestamp2.clone(),
|
timestamp: timestamp2,
|
||||||
})
|
})
|
||||||
.set_committer(Signature {
|
.set_committer(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp2.clone(),
|
timestamp: timestamp2,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2638,7 +2638,7 @@ fn test_evaluate_expression_committer_date() {
|
||||||
.set_author(Signature {
|
.set_author(Signature {
|
||||||
name: "name3".to_string(),
|
name: "name3".to_string(),
|
||||||
email: "email3".to_string(),
|
email: "email3".to_string(),
|
||||||
timestamp: timestamp2.clone(),
|
timestamp: timestamp2,
|
||||||
})
|
})
|
||||||
.set_committer(Signature {
|
.set_committer(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
|
@ -2676,7 +2676,7 @@ fn test_evaluate_expression_mine() {
|
||||||
.set_author(Signature {
|
.set_author(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp.clone(),
|
timestamp,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2685,7 +2685,7 @@ fn test_evaluate_expression_mine() {
|
||||||
.set_author(Signature {
|
.set_author(Signature {
|
||||||
name: "name2".to_string(),
|
name: "name2".to_string(),
|
||||||
email: settings.user_email(),
|
email: settings.user_email(),
|
||||||
timestamp: timestamp.clone(),
|
timestamp,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2745,7 +2745,7 @@ fn test_evaluate_expression_committer() {
|
||||||
.set_committer(Signature {
|
.set_committer(Signature {
|
||||||
name: "name1".to_string(),
|
name: "name1".to_string(),
|
||||||
email: "email1".to_string(),
|
email: "email1".to_string(),
|
||||||
timestamp: timestamp.clone(),
|
timestamp,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -2754,7 +2754,7 @@ fn test_evaluate_expression_committer() {
|
||||||
.set_committer(Signature {
|
.set_committer(Signature {
|
||||||
name: "name2".to_string(),
|
name: "name2".to_string(),
|
||||||
email: "email2".to_string(),
|
email: "email2".to_string(),
|
||||||
timestamp: timestamp.clone(),
|
timestamp,
|
||||||
})
|
})
|
||||||
.write()
|
.write()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Reference in a new issue