History

refactor: mark `Timestamp` struct as `Copy`

Mateusz Mikuła committed 2 years ago

Commit 8dd30031 parent 76f40e59 files · +26 −26Browse files

Unified · Split

9 files
  1. cli/src/commands/commit.rs +1 −1
  2. cli/src/commands/describe.rs +2 −2
  3. cli/src/operation_templater.rs +2 −2
  4. lib/src/backend.rs +1 −1
  5. lib/src/commit_builder.rs +1 −1
  6. lib/src/op_store.rs +1 −1
  7. lib/src/settings.rs +1 −1
  8. lib/src/transaction.rs +1 −1
  9. lib/tests/test_revset.rs +16 −16
cli/src/commands/commit.rs+1−1
@@ -122,7 +122,7 @@ new working-copy commit. · 121 unmodified lines
122122 let new_author = Signature {
123123 name,
124124 email,
125− timestamp: commit_builder.author().timestamp.clone(),
125+ timestamp: commit_builder.author().timestamp,
126126 };
127127 commit_builder.set_author(new_author);
128128 }
cli/src/commands/describe.rs+2−2
@@ -155,7 +155,7 @@ pub(crate) fn cmd_describe( · 154 unmodified lines
155155 let new_author = Signature {
156156 name,
157157 email,
158− timestamp: commit.author().timestamp.clone(),
158+ timestamp: commit.author().timestamp,
159159 };
160160 commit_builder.set_author(new_author);
161161 }
@@ -250,7 +250,7 @@ pub(crate) fn cmd_describe( · 88 unmodified lines
250250 let new_author = Signature {
251251 name,
252252 email,
253− timestamp: commit_builder.author().timestamp.clone(),
253+ timestamp: commit_builder.author().timestamp,
254254 };
255255 commit_builder = commit_builder.set_author(new_author);
256256 }
cli/src/operation_templater.rs+2−2
@@ -279,8 +279,8 @@ fn builtin_operation_methods() -> OperationTemplateBuildMethodFnMap<Operation> { · 278 unmodified lines
279279 map.insert("time", |_language, _build_ctx, self_property, function| {
280280 function.expect_no_arguments()?;
281281 let out_property = self_property.map(|op| TimestampRange {
282− start: op.metadata().start_time.clone(),
283− end: op.metadata().end_time.clone(),
282+ start: op.metadata().start_time,
283+ end: op.metadata().end_time,
284284 });
285285 Ok(L::wrap_timestamp_range(out_property))
286286 });
lib/src/backend.rs+1−1
@@ -53,7 +53,7 @@ id_type!(pub ConflictId); · 52 unmodified lines
5353 #[derive(ContentHash, Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
5454 pub struct MillisSinceEpoch(pub i64);
5555
56−#[derive(ContentHash, Debug, PartialEq, Eq, Clone, PartialOrd, Ord)]
56+#[derive(ContentHash, Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
5757 pub struct Timestamp {
5858 pub timestamp: MillisSinceEpoch,
5959 // time zone offset in minutes
lib/src/commit_builder.rs+1−1
@@ -205,7 +205,7 @@ impl DetachedCommitBuilder { · 204 unmodified lines
205205 && commit.author.email == commit.committer.email
206206 && predecessor.is_discardable(repo).unwrap_or_default()
207207 {
208− commit.author.timestamp = commit.committer.timestamp.clone();
208+ commit.author.timestamp = commit.committer.timestamp;
209209 }
210210
211211 DetachedCommitBuilder {
lib/src/op_store.rs+1−1
@@ -374,7 +374,7 @@ impl Operation { · 373 unmodified lines
374374 tz_offset: 0,
375375 };
376376 let metadata = OperationMetadata {
377− start_time: timestamp.clone(),
377+ start_time: timestamp,
378378 end_time: timestamp,
379379 description: "".to_string(),
380380 hostname: "".to_string(),
lib/src/settings.rs+1−1
@@ -211,7 +211,7 @@ impl UserSettings { · 210 unmodified lines
211211 }
212212
213213 pub fn signature(&self) -> Signature {
214− let timestamp = self.timestamp.clone().unwrap_or_else(Timestamp::now);
214+ let timestamp = self.timestamp.unwrap_or_else(Timestamp::now);
215215 Signature {
216216 name: self.user_name(),
217217 email: self.user_email(),
lib/src/transaction.rs+1−1
@@ -150,7 +150,7 @@ pub fn create_op_metadata( · 149 unmodified lines
150150 let start_time = user_settings
151151 .operation_timestamp()
152152 .unwrap_or_else(Timestamp::now);
153− let end_time = start_time.clone();
153+ let end_time = start_time;
154154 let hostname = user_settings.operation_hostname();
155155 let username = user_settings.operation_username();
156156 OperationMetadata {
lib/tests/test_revset.rs+16−16
@@ -2456,7 +2456,7 @@ fn test_evaluate_expression_author() { · 2455 unmodified lines
24562456 .set_author(Signature {
24572457 name: "name1".to_string(),
24582458 email: "email1".to_string(),
2459− timestamp: timestamp.clone(),
2459+ timestamp,
24602460 })
24612461 .write()
24622462 .unwrap();
@@ -2465,7 +2465,7 @@ fn test_evaluate_expression_author() { · 2 unmodified lines
24652465 .set_author(Signature {
24662466 name: "name2".to_string(),
24672467 email: "email2".to_string(),
2468− timestamp: timestamp.clone(),
2468+ timestamp,
24692469 })
24702470 .write()
24712471 .unwrap();
@@ -2543,12 +2543,12 @@ fn test_evaluate_expression_author_date() { · 71 unmodified lines
25432543 .set_author(Signature {
25442544 name: "name1".to_string(),
25452545 email: "email1".to_string(),
2546− timestamp: timestamp1.clone(),
2546+ timestamp: timestamp1,
25472547 })
25482548 .set_committer(Signature {
25492549 name: "name1".to_string(),
25502550 email: "email1".to_string(),
2551− timestamp: timestamp2.clone(),
2551+ timestamp: timestamp2,
25522552 })
25532553 .write()
25542554 .unwrap();
@@ -2557,12 +2557,12 @@ fn test_evaluate_expression_author_date() { · 2 unmodified lines
25572557 .set_author(Signature {
25582558 name: "name2".to_string(),
25592559 email: "email2".to_string(),
2560− timestamp: timestamp2.clone(),
2560+ timestamp: timestamp2,
25612561 })
25622562 .set_committer(Signature {
25632563 name: "name1".to_string(),
25642564 email: "email1".to_string(),
2565− timestamp: timestamp2.clone(),
2565+ timestamp: timestamp2,
25662566 })
25672567 .write()
25682568 .unwrap();
@@ -2576,7 +2576,7 @@ fn test_evaluate_expression_author_date() { · 7 unmodified lines
25762576 .set_committer(Signature {
25772577 name: "name1".to_string(),
25782578 email: "email1".to_string(),
2579− timestamp: timestamp2.clone(),
2579+ timestamp: timestamp2,
25802580 })
25812581 .write()
25822582 .unwrap();
@@ -2610,12 +2610,12 @@ fn test_evaluate_expression_committer_date() { · 27 unmodified lines
26102610 .set_author(Signature {
26112611 name: "name1".to_string(),
26122612 email: "email1".to_string(),
2613− timestamp: timestamp2.clone(),
2613+ timestamp: timestamp2,
26142614 })
26152615 .set_committer(Signature {
26162616 name: "name1".to_string(),
26172617 email: "email1".to_string(),
2618− timestamp: timestamp1.clone(),
2618+ timestamp: timestamp1,
26192619 })
26202620 .write()
26212621 .unwrap();
@@ -2624,12 +2624,12 @@ fn test_evaluate_expression_committer_date() { · 2 unmodified lines
26242624 .set_author(Signature {
26252625 name: "name2".to_string(),
26262626 email: "email2".to_string(),
2627− timestamp: timestamp2.clone(),
2627+ timestamp: timestamp2,
26282628 })
26292629 .set_committer(Signature {
26302630 name: "name1".to_string(),
26312631 email: "email1".to_string(),
2632− timestamp: timestamp2.clone(),
2632+ timestamp: timestamp2,
26332633 })
26342634 .write()
26352635 .unwrap();
@@ -2638,7 +2638,7 @@ fn test_evaluate_expression_committer_date() { · 2 unmodified lines
26382638 .set_author(Signature {
26392639 name: "name3".to_string(),
26402640 email: "email3".to_string(),
2641− timestamp: timestamp2.clone(),
2641+ timestamp: timestamp2,
26422642 })
26432643 .set_committer(Signature {
26442644 name: "name1".to_string(),
@@ -2676,7 +2676,7 @@ fn test_evaluate_expression_mine() { · 31 unmodified lines
26762676 .set_author(Signature {
26772677 name: "name1".to_string(),
26782678 email: "email1".to_string(),
2679− timestamp: timestamp.clone(),
2679+ timestamp,
26802680 })
26812681 .write()
26822682 .unwrap();
@@ -2685,7 +2685,7 @@ fn test_evaluate_expression_mine() { · 2 unmodified lines
26852685 .set_author(Signature {
26862686 name: "name2".to_string(),
26872687 email: settings.user_email(),
2688− timestamp: timestamp.clone(),
2688+ timestamp,
26892689 })
26902690 .write()
26912691 .unwrap();
@@ -2745,7 +2745,7 @@ fn test_evaluate_expression_committer() { · 53 unmodified lines
27452745 .set_committer(Signature {
27462746 name: "name1".to_string(),
27472747 email: "email1".to_string(),
2748− timestamp: timestamp.clone(),
2748+ timestamp,
27492749 })
27502750 .write()
27512751 .unwrap();
@@ -2754,7 +2754,7 @@ fn test_evaluate_expression_committer() { · 2 unmodified lines
27542754 .set_committer(Signature {
27552755 name: "name2".to_string(),
27562756 email: "email2".to_string(),
2757− timestamp: timestamp.clone(),
2757+ timestamp,
27582758 })
27592759 .write()
27602760 .unwrap();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t