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
122 let new_author = Signature {122 let new_author = Signature {
123 name,123 name,
124 email,124 email,
125 timestamp: commit_builder.author().timestamp.clone(),125 timestamp: commit_builder.author().timestamp,
126 };126 };
127 commit_builder.set_author(new_author);127 commit_builder.set_author(new_author);
128 }128 }
cli/src/commands/describe.rs+2−2
@@ -155,7 +155,7 @@ pub(crate) fn cmd_describe( · 154 unmodified lines
155 let new_author = Signature {155 let new_author = Signature {
156 name,156 name,
157 email,157 email,
158 timestamp: commit.author().timestamp.clone(),158 timestamp: commit.author().timestamp,
159 };159 };
160 commit_builder.set_author(new_author);160 commit_builder.set_author(new_author);
161 }161 }
@@ -250,7 +250,7 @@ pub(crate) fn cmd_describe( · 88 unmodified lines
250 let new_author = Signature {250 let new_author = Signature {
251 name,251 name,
252 email,252 email,
253 timestamp: commit_builder.author().timestamp.clone(),253 timestamp: commit_builder.author().timestamp,
254 };254 };
255 commit_builder = commit_builder.set_author(new_author);255 commit_builder = commit_builder.set_author(new_author);
256 }256 }
cli/src/operation_templater.rs+2−2
@@ -279,8 +279,8 @@ fn builtin_operation_methods() -> OperationTemplateBuildMethodFnMap<Operation> { · 278 unmodified lines
279 map.insert("time", |_language, _build_ctx, self_property, function| {279 map.insert("time", |_language, _build_ctx, self_property, function| {
280 function.expect_no_arguments()?;280 function.expect_no_arguments()?;
281 let out_property = self_property.map(|op| TimestampRange {281 let out_property = self_property.map(|op| TimestampRange {
282 start: op.metadata().start_time.clone(),282 start: op.metadata().start_time,
283 end: op.metadata().end_time.clone(),283 end: op.metadata().end_time,
284 });284 });
285 Ok(L::wrap_timestamp_range(out_property))285 Ok(L::wrap_timestamp_range(out_property))
286 });286 });
lib/src/backend.rs+1−1
@@ -53,7 +53,7 @@ id_type!(pub ConflictId); · 52 unmodified lines
53#[derive(ContentHash, Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]53#[derive(ContentHash, Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
54pub struct MillisSinceEpoch(pub i64);54pub struct MillisSinceEpoch(pub i64);
55 55
56#[derive(ContentHash, Debug, PartialEq, Eq, Clone, PartialOrd, Ord)]56#[derive(ContentHash, Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
57pub struct Timestamp {57pub struct Timestamp {
58 pub timestamp: MillisSinceEpoch,58 pub timestamp: MillisSinceEpoch,
59 // time zone offset in minutes59 // time zone offset in minutes
lib/src/commit_builder.rs+1−1
@@ -205,7 +205,7 @@ impl DetachedCommitBuilder { · 204 unmodified lines
205 && commit.author.email == commit.committer.email205 && commit.author.email == commit.committer.email
206 && predecessor.is_discardable(repo).unwrap_or_default()206 && predecessor.is_discardable(repo).unwrap_or_default()
207 {207 {
208 commit.author.timestamp = commit.committer.timestamp.clone();208 commit.author.timestamp = commit.committer.timestamp;
209 }209 }
210 210
211 DetachedCommitBuilder {211 DetachedCommitBuilder {
lib/src/op_store.rs+1−1
@@ -374,7 +374,7 @@ impl Operation { · 373 unmodified lines
374 tz_offset: 0,374 tz_offset: 0,
375 };375 };
376 let metadata = OperationMetadata {376 let metadata = OperationMetadata {
377 start_time: timestamp.clone(),377 start_time: timestamp,
378 end_time: timestamp,378 end_time: timestamp,
379 description: "".to_string(),379 description: "".to_string(),
380 hostname: "".to_string(),380 hostname: "".to_string(),
lib/src/settings.rs+1−1
@@ -211,7 +211,7 @@ impl UserSettings { · 210 unmodified lines
211 }211 }
212 212
213 pub fn signature(&self) -> Signature {213 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);
215 Signature {215 Signature {
216 name: self.user_name(),216 name: self.user_name(),
217 email: self.user_email(),217 email: self.user_email(),
lib/src/transaction.rs+1−1
@@ -150,7 +150,7 @@ pub fn create_op_metadata( · 149 unmodified lines
150 let start_time = user_settings150 let start_time = user_settings
151 .operation_timestamp()151 .operation_timestamp()
152 .unwrap_or_else(Timestamp::now);152 .unwrap_or_else(Timestamp::now);
153 let end_time = start_time.clone();153 let end_time = start_time;
154 let hostname = user_settings.operation_hostname();154 let hostname = user_settings.operation_hostname();
155 let username = user_settings.operation_username();155 let username = user_settings.operation_username();
156 OperationMetadata {156 OperationMetadata {
lib/tests/test_revset.rs+16−16
@@ -2456,7 +2456,7 @@ fn test_evaluate_expression_author() { · 2455 unmodified lines
2456 .set_author(Signature {2456 .set_author(Signature {
2457 name: "name1".to_string(),2457 name: "name1".to_string(),
2458 email: "email1".to_string(),2458 email: "email1".to_string(),
2459 timestamp: timestamp.clone(),2459 timestamp,
2460 })2460 })
2461 .write()2461 .write()
2462 .unwrap();2462 .unwrap();
@@ -2465,7 +2465,7 @@ fn test_evaluate_expression_author() { · 2 unmodified lines
2465 .set_author(Signature {2465 .set_author(Signature {
2466 name: "name2".to_string(),2466 name: "name2".to_string(),
2467 email: "email2".to_string(),2467 email: "email2".to_string(),
2468 timestamp: timestamp.clone(),2468 timestamp,
2469 })2469 })
2470 .write()2470 .write()
2471 .unwrap();2471 .unwrap();
@@ -2543,12 +2543,12 @@ fn test_evaluate_expression_author_date() { · 71 unmodified lines
2543 .set_author(Signature {2543 .set_author(Signature {
2544 name: "name1".to_string(),2544 name: "name1".to_string(),
2545 email: "email1".to_string(),2545 email: "email1".to_string(),
2546 timestamp: timestamp1.clone(),2546 timestamp: timestamp1,
2547 })2547 })
2548 .set_committer(Signature {2548 .set_committer(Signature {
2549 name: "name1".to_string(),2549 name: "name1".to_string(),
2550 email: "email1".to_string(),2550 email: "email1".to_string(),
2551 timestamp: timestamp2.clone(),2551 timestamp: timestamp2,
2552 })2552 })
2553 .write()2553 .write()
2554 .unwrap();2554 .unwrap();
@@ -2557,12 +2557,12 @@ fn test_evaluate_expression_author_date() { · 2 unmodified lines
2557 .set_author(Signature {2557 .set_author(Signature {
2558 name: "name2".to_string(),2558 name: "name2".to_string(),
2559 email: "email2".to_string(),2559 email: "email2".to_string(),
2560 timestamp: timestamp2.clone(),2560 timestamp: timestamp2,
2561 })2561 })
2562 .set_committer(Signature {2562 .set_committer(Signature {
2563 name: "name1".to_string(),2563 name: "name1".to_string(),
2564 email: "email1".to_string(),2564 email: "email1".to_string(),
2565 timestamp: timestamp2.clone(),2565 timestamp: timestamp2,
2566 })2566 })
2567 .write()2567 .write()
2568 .unwrap();2568 .unwrap();
@@ -2576,7 +2576,7 @@ fn test_evaluate_expression_author_date() { · 7 unmodified lines
2576 .set_committer(Signature {2576 .set_committer(Signature {
2577 name: "name1".to_string(),2577 name: "name1".to_string(),
2578 email: "email1".to_string(),2578 email: "email1".to_string(),
2579 timestamp: timestamp2.clone(),2579 timestamp: timestamp2,
2580 })2580 })
2581 .write()2581 .write()
2582 .unwrap();2582 .unwrap();
@@ -2610,12 +2610,12 @@ fn test_evaluate_expression_committer_date() { · 27 unmodified lines
2610 .set_author(Signature {2610 .set_author(Signature {
2611 name: "name1".to_string(),2611 name: "name1".to_string(),
2612 email: "email1".to_string(),2612 email: "email1".to_string(),
2613 timestamp: timestamp2.clone(),2613 timestamp: timestamp2,
2614 })2614 })
2615 .set_committer(Signature {2615 .set_committer(Signature {
2616 name: "name1".to_string(),2616 name: "name1".to_string(),
2617 email: "email1".to_string(),2617 email: "email1".to_string(),
2618 timestamp: timestamp1.clone(),2618 timestamp: timestamp1,
2619 })2619 })
2620 .write()2620 .write()
2621 .unwrap();2621 .unwrap();
@@ -2624,12 +2624,12 @@ fn test_evaluate_expression_committer_date() { · 2 unmodified lines
2624 .set_author(Signature {2624 .set_author(Signature {
2625 name: "name2".to_string(),2625 name: "name2".to_string(),
2626 email: "email2".to_string(),2626 email: "email2".to_string(),
2627 timestamp: timestamp2.clone(),2627 timestamp: timestamp2,
2628 })2628 })
2629 .set_committer(Signature {2629 .set_committer(Signature {
2630 name: "name1".to_string(),2630 name: "name1".to_string(),
2631 email: "email1".to_string(),2631 email: "email1".to_string(),
2632 timestamp: timestamp2.clone(),2632 timestamp: timestamp2,
2633 })2633 })
2634 .write()2634 .write()
2635 .unwrap();2635 .unwrap();
@@ -2638,7 +2638,7 @@ fn test_evaluate_expression_committer_date() { · 2 unmodified lines
2638 .set_author(Signature {2638 .set_author(Signature {
2639 name: "name3".to_string(),2639 name: "name3".to_string(),
2640 email: "email3".to_string(),2640 email: "email3".to_string(),
2641 timestamp: timestamp2.clone(),2641 timestamp: timestamp2,
2642 })2642 })
2643 .set_committer(Signature {2643 .set_committer(Signature {
2644 name: "name1".to_string(),2644 name: "name1".to_string(),
@@ -2676,7 +2676,7 @@ fn test_evaluate_expression_mine() { · 31 unmodified lines
2676 .set_author(Signature {2676 .set_author(Signature {
2677 name: "name1".to_string(),2677 name: "name1".to_string(),
2678 email: "email1".to_string(),2678 email: "email1".to_string(),
2679 timestamp: timestamp.clone(),2679 timestamp,
2680 })2680 })
2681 .write()2681 .write()
2682 .unwrap();2682 .unwrap();
@@ -2685,7 +2685,7 @@ fn test_evaluate_expression_mine() { · 2 unmodified lines
2685 .set_author(Signature {2685 .set_author(Signature {
2686 name: "name2".to_string(),2686 name: "name2".to_string(),
2687 email: settings.user_email(),2687 email: settings.user_email(),
2688 timestamp: timestamp.clone(),2688 timestamp,
2689 })2689 })
2690 .write()2690 .write()
2691 .unwrap();2691 .unwrap();
@@ -2745,7 +2745,7 @@ fn test_evaluate_expression_committer() { · 53 unmodified lines
2745 .set_committer(Signature {2745 .set_committer(Signature {
2746 name: "name1".to_string(),2746 name: "name1".to_string(),
2747 email: "email1".to_string(),2747 email: "email1".to_string(),
2748 timestamp: timestamp.clone(),2748 timestamp,
2749 })2749 })
2750 .write()2750 .write()
2751 .unwrap();2751 .unwrap();
@@ -2754,7 +2754,7 @@ fn test_evaluate_expression_committer() { · 2 unmodified lines
2754 .set_committer(Signature {2754 .set_committer(Signature {
2755 name: "name2".to_string(),2755 name: "name2".to_string(),
2756 email: "email2".to_string(),2756 email: "email2".to_string(),
2757 timestamp: timestamp.clone(),2757 timestamp,
2758 })2758 })
2759 .write()2759 .write()
2760 .unwrap();2760 .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