1 use crate::change::Change;
2 use crate::changestore::ChangeStore;
3 use crate::pristine::*;
4 use crate::record::{Algorithm, Builder};
5 use crate::working_copy::WorkingCopy;
6 use crate::*;
7 use chrono::*;
8
9 mod add_file;
10 mod change;
11 mod clone;
12 mod conflict;
13 mod diff;
14 mod file_conflicts;
15 mod filesystem;
16 mod missing_context;
17 mod partial;
18 mod performance;
19 mod rm_file;
20 mod rollback;
21 mod text;
22 mod unrecord;
23
record_all_change< T: MutTxnT + Send + Sync + 'static, R: WorkingCopy + Clone + Send + Sync + 'static, P: ChangeStore + Clone + Send + 'static, >( repo: &R, store: &P, txn: &ArcTxn<T>, channel: &ChannelRef<T>, prefix: &str, ) -> Result<(Hash, Change), anyhow::Error> where R::Error: Send + Sync + 'static,24 fn record_all_change<
25 T: MutTxnT + Send + Sync + 'static,
26 R: WorkingCopy + Clone + Send + Sync + 'static,
27 P: ChangeStore + Clone + Send + 'static,
28 >(
29 repo: &R,
30 store: &P,
31 txn: &ArcTxn<T>,
32 channel: &ChannelRef<T>,
33 prefix: &str,
34 ) -> Result<(Hash, Change), anyhow::Error>
35 where
36 R::Error: Send + Sync + 'static,
37 {
38 let mut state = Builder::new();
39 state.record(
40 txn.clone(),
41 Algorithm::default(),
42 channel.clone(),
43 repo,
44 store,
45 prefix,
46 1,
47 )?;
48
49 let rec = state.finish();
50 let changes = rec
51 .actions
52 .into_iter()
53 .map(|rec| rec.globalize(&*txn.read()).unwrap())
54 .collect();
55 let change0 = crate::change::Change::make_change(
56 &*txn.read(),
57 &channel.clone(),
58 changes,
59 std::mem::take(&mut *rec.contents.lock()),
60 crate::change::ChangeHeader {
61 message: "test".to_string(),
62 authors: vec![],
63 description: None,
64 // Beware of changing the following line: two changes
65 // doing the same thing will be equal. Sometimes we don't
66 // want that, as in tests::unrecord::unrecord_double.
67 timestamp: Utc::now(),
68 },
69 Vec::new(),
70 )
71 .unwrap();
72 let hash = store.save_change(&change0)?;
73 if log_enabled!(log::Level::Debug) {
74 change0
75 .write(store, Some(hash), true, &mut std::io::stderr())
76 .unwrap();
77 }
78 apply::apply_local_change(
79 &mut *txn.write(),
80 &channel,
81 &change0,
82 &hash,
83 &rec.updatables,
84 )?;
85 Ok((hash, change0))
86 }
87
record_all<T: MutTxnT, R: WorkingCopy, P: ChangeStore>( repo: &R, store: &P, txn: &ArcTxn<T>, channel: &ChannelRef<T>, prefix: &str, ) -> Result<Hash, anyhow::Error> where T: MutTxnT + Send + Sync + 'static, R: WorkingCopy + Clone + Send + Sync + 'static, P: ChangeStore + Clone + Send + 'static, R::Error: Send + Sync + 'static,88 fn record_all<T: MutTxnT, R: WorkingCopy, P: ChangeStore>(
89 repo: &R,
90 store: &P,
91 txn: &ArcTxn<T>,
92 channel: &ChannelRef<T>,
93 prefix: &str,
94 ) -> Result<Hash, anyhow::Error>
95 where
96 T: MutTxnT + Send + Sync + 'static,
97 R: WorkingCopy + Clone + Send + Sync + 'static,
98 P: ChangeStore + Clone + Send + 'static,
99 R::Error: Send + Sync + 'static,
100 {
101 let (hash, _) = record_all_change(repo, store, txn, channel, prefix)?;
102 Ok(hash)
103 }
104
record_all_output< T: MutTxnT + Send + Sync + 'static, R: WorkingCopy + Clone + Send + Sync + 'static, P: ChangeStore + Clone + Send + Sync + 'static, >( repo: &R, changes: P, txn: &ArcTxn<T>, channel: &ChannelRef<T>, prefix: &str, ) -> Result<Hash, anyhow::Error> where T: MutTxnT + Send + Sync + 'static, R: WorkingCopy + Clone + Send + Sync + 'static, P: ChangeStore + Clone + Send + Sync + 'static, R::Error: Send + Sync + 'static,105 fn record_all_output<
106 T: MutTxnT + Send + Sync + 'static,
107 R: WorkingCopy + Clone + Send + Sync + 'static,
108 P: ChangeStore + Clone + Send + Sync + 'static,
109 >(
110 repo: &R,
111 changes: P,
112 txn: &ArcTxn<T>,
113 channel: &ChannelRef<T>,
114 prefix: &str,
115 ) -> Result<Hash, anyhow::Error>
116 where
117 T: MutTxnT + Send + Sync + 'static,
118 R: WorkingCopy + Clone + Send + Sync + 'static,
119 P: ChangeStore + Clone + Send + Sync + 'static,
120 R::Error: Send + Sync + 'static,
121 {
122 let hash = record_all(repo, &changes, txn, channel, prefix)?;
123 output::output_repository_no_pending(repo, &changes, txn, channel, "", true, None, 1, 0)
124 .unwrap();
125 Ok(hash)
126 }
127