replacement in pijul/src/commands/tag.rs at line 97
[4.2499]→[4.2762:2924](∅→∅) − if txn
− .read()
− .get_tags(&channel.read().tags, &last_t)?
− .is_some()
− {
+ if txn.read().is_tagged(&channel.read().tags, last_t)? {
replacement in pijul/src/commands/tag.rs at line 108
[4.3053]→[4.2925:3025](∅→∅),
[4.3025]→[4.3145:3230](∅→∅),
[4.3145]→[4.3145:3230](∅→∅),
[4.3230]→[3.102:149](∅→∅) − let h = libpijul::tag::from_channel(&*txn.read(), &channel_name, &header, &mut w)?;
− libpijul::changestore::filesystem::push_filename(&mut tag_path, &h);
− tag_path.set_extension("tag");
+ let h: libpijul::Merkle =
+ libpijul::tag::from_channel(&*txn.read(), &channel_name, &header, &mut w)?;
+ libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
replacement in pijul/src/commands/tag.rs at line 114
[4.3358]→[4.3026:3128](∅→∅) − txn.write()
− .put_tags(&mut *channel.write(), last_t.into(), &h)?;
+ txn.write().put_tags(&mut *channel.write(), last_t.into())?;
replacement in pijul/src/commands/tag.rs at line 125
[4.157]→[4.3591:3678](∅→∅),
[3.211]→[4.3591:3678](∅→∅),
[4.222]→[4.3591:3678](∅→∅),
[4.3591]→[4.3591:3678](∅→∅),
[4.3678]→[4.223:312](∅→∅),
[4.312]→[3.212:263](∅→∅) − let h = if let Some(h) = libpijul::Hash::from_base32(tag.as_bytes()) {
− libpijul::changestore::filesystem::push_filename(&mut tag_path, &h);
− tag_path.set_extension("tag");
+ let h = if let Some(h) = libpijul::Merkle::from_base32(tag.as_bytes()) {
+ libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
replacement in pijul/src/commands/tag.rs at line 142
[4.4198]→[3.264:368](∅→∅) − let mut f = libpijul::tag::OpenTagFile::open(&tag_path)?;
− f.check(&h)?;
+ let f = libpijul::tag::OpenTagFile::open(&tag_path, &h)?;
replacement in pijul/src/commands/tag.rs at line 150
[3.430]→[4.5830:6006](∅→∅),
[4.5830]→[4.5830:6006](∅→∅),
[4.6006]→[3.431:482](∅→∅) − let h = if let Some(h) = libpijul::Hash::from_base32(tag.as_bytes()) {
− libpijul::changestore::filesystem::push_filename(&mut tag_path, &h);
− tag_path.set_extension("tag");
+ let h = if let Some(h) = libpijul::Merkle::from_base32(tag.as_bytes()) {
+ libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &h);
replacement in pijul/src/commands/tag.rs at line 196
[4.3209]→[4.930:1110](∅→∅),
[4.930]→[4.930:1110](∅→∅),
[4.1110]→[3.621:672](∅→∅),
[3.672]→[4.1110:1188](∅→∅),
[4.1110]→[4.1110:1188](∅→∅) − let (_, h) = t?;
− let h: libpijul::Hash = h.into();
− libpijul::changestore::filesystem::push_filename(&mut tag_path, &h);
− tag_path.set_extension("tag");
− let mut f = libpijul::tag::OpenTagFile::open(&tag_path)?;
+ let t = (*t?).into();
+ let (_, m) = txn.get_changes(&channel, t)?.unwrap();
+ libpijul::changestore::filesystem::push_tag_filename(&mut tag_path, &m);
+ let mut f = libpijul::tag::OpenTagFile::open(&tag_path, &m)?;
replacement in pijul/src/commands/tag.rs at line 201
[4.1234]→[4.1234:1298](∅→∅) − writeln!(stdout, "Tag {}", h.to_base32())?;
+ writeln!(stdout, "State {}", m.to_base32())?;
edit in pijul/src/commands/tag.rs at line 204
[4.1438]→[4.1438:1513](∅→∅) − writeln!(stdout, "State: {}", f.state().to_base32())?;
replacement in pijul/src/commands/mod.rs at line 267
− fn find_hash(path: &mut std::path::PathBuf, hash: &str) -> Result<libpijul::Hash, anyhow::Error> {
− use libpijul::Base32;
+ fn find_hash<B: libpijul::Base32>(
+ path: &mut std::path::PathBuf,
+ hash: &str,
+ ) -> Result<B, anyhow::Error> {
replacement in pijul/src/commands/mod.rs at line 298
− if let Some(h) = libpijul::Hash::from_base32(f.as_bytes()) {
+ if let Some(h) = B::from_base32(f.as_bytes()) {
replacement in libpijul/src/tag.rs at line 60
[4.7538]→[3.673:805](∅→∅) − #[error("Wrong hash, expected {}, got {}", expected.to_base32(), got.to_base32())]
− WrongHash { expected: Hash, got: Hash },
+ #[error("Wrong state, expected {}, got {}", expected.to_base32(), got.to_base32())]
+ WrongHash { expected: Merkle, got: Merkle },
replacement in libpijul/src/tag.rs at line 77
[4.7694]→[4.7694:7760](∅→∅) − pub fn open<P: AsRef<Path>>(p: P) -> Result<Self, TagError> {
+ pub fn open<P: AsRef<Path>>(p: P, expected: &Merkle) -> Result<Self, TagError> {
replacement in libpijul/src/tag.rs at line 81
[4.7917]→[4.140:219](∅→∅),
[4.219]→[4.7967:8008](∅→∅),
[4.7967]→[4.7967:8008](∅→∅) − let header = bincode::deserialize(&off).map_err(TagError::BincodeDe)?;
− Ok(OpenTagFile { header, file })
+ let header: FileHeader = bincode::deserialize(&off).map_err(TagError::BincodeDe)?;
+ if &header.state == expected {
+ Ok(OpenTagFile { header, file })
+ } else {
+ Err(TagError::WrongHash {
+ expected: *expected,
+ got: header.state,
+ })
+ }
edit in libpijul/src/tag.rs at line 99
[4.1977]→[4.1977:1983](∅→∅),
[4.1983]→[3.806:1736](∅→∅) − }
−
− pub fn check(&mut self, expected: &Hash) -> Result<(), TagError> {
− let mut hasher = Hasher::default();
− self.file.seek(SeekFrom::Start(0))?;
−
− let mut buf = Vec::new();
− // Reading the FileHeader
− buf.resize(self.header.header as usize, 0);
− self.file.read_exact(&mut buf)?;
− hasher.update(&buf);
−
− // Reading the Header
− buf.resize((self.header.channel - self.header.header) as usize, 0);
− self.file.read_exact(&mut buf)?;
− hasher.update(&buf);
−
− // Reading the Header
− buf.resize((self.header.unhashed - self.header.channel) as usize, 0);
− self.file.read_exact(&mut buf)?;
− hasher.update(&buf);
− let got = hasher.finish();
− if &got != expected {
− Err(TagError::WrongHash {
− expected: *expected,
− got,
− })
− } else {
− Ok(())
− }
replacement in libpijul/src/tag.rs at line 227
[4.12064]→[4.12064:12122](∅→∅) − |_, _, k: &L64, v: &SerializedHash| Ok((*k, *v)),
+ |_, _, k: &L64, v: &()| Ok((*k, *v)),
replacement in libpijul/src/tag.rs at line 351
[4.15209]→[4.15209:15239](∅→∅) − ) -> Result<Hash, TagError> {
+ ) -> Result<Merkle, TagError> {
replacement in libpijul/src/tag.rs at line 366
[4.15714]→[4.15714:15729](∅→∅) replacement in libpijul/src/tag.rs at line 372
[4.15923]→[4.15923:15963](∅→∅) − let mut hasher = Hasher::default();
edit in libpijul/src/tag.rs at line 377
[4.16149]→[4.16149:16178](∅→∅) − hasher.update(&off_buf);
edit in libpijul/src/tag.rs at line 379
[4.16260]→[4.16260:16292](∅→∅) − hasher.update(&header_buf);
replacement in libpijul/src/tag.rs at line 381
[4.16353]→[4.16353:16402](∅→∅) − hasher.update(&out);
− Ok(hasher.finish())
replacement in libpijul/src/tag/txn.rs at line 53
[4.1336]→[2.142:228](∅→∅) − pub fn new<P: AsRef<std::path::Path>>(p: P, h: &Hash) -> Result<Self, TagError> {
+ pub fn new<P: AsRef<std::path::Path>>(p: P, expected: &Merkle) -> Result<Self, TagError> {
edit in libpijul/src/tag/txn.rs at line 58
+ if &header.state != expected {
+ return Err(TagError::WrongHash {
+ expected: *expected,
+ got: header.state,
+ })
+ }
edit in libpijul/src/tag/txn.rs at line 68
replacement in libpijul/src/tag/txn.rs at line 405
[4.12692]→[4.12692:13093](∅→∅) − fn get_tags(
− &self,
− channel: &Self::Tags,
− c: &L64,
− ) -> Result<Option<&SerializedHash>, TxnErr<Self::GraphError>> {
− use crate::pristine::sanakirja::UDb;
− let db: UDb<L64, SerializedHash> = UDb::from_page(*channel);
− match ::sanakirja::btree::get(self, &db, c, None)? {
− Some((k, v)) if k == c => Ok(Some(v)),
− _ => Ok(None),
+ type TagsCursor =
+ ::sanakirja::btree::cursor::Cursor<L64, (), P<L64, ()>>;
+
+ fn is_tagged(&self, tags: &Self::Tags, t: u64) -> Result<bool, TxnErr<Self::GraphError>> {
+ use crate::pristine::sanakirja::Db;
+ let db: Db<L64, ()> = Db::from_page(*tags);
+ let t: L64 = t.into();
+ match ::sanakirja::btree::get(self, &db, &t, None)? {
+ Some((k, _)) => Ok(k == &t),
+ _ => Ok(false)
edit in libpijul/src/tag/txn.rs at line 418
[4.13110]→[4.13110:13222](∅→∅) − type TagsCursor =
− ::sanakirja::btree::cursor::Cursor<L64, SerializedHash, UP<L64, SerializedHash>>;
replacement in libpijul/src/tag/txn.rs at line 423
[4.13339]→[4.13339:13429](∅→∅) − crate::pristine::Cursor<Self, &'txn Self, Self::TagsCursor, L64, SerializedHash>,
+ crate::pristine::Cursor<Self, &'txn Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/tag/txn.rs at line 426
[4.13471]→[4.13471:13585](∅→∅) − use crate::pristine::sanakirja::UDb;
− let db: UDb<L64, SerializedHash> = UDb::from_page(*channel);
+ use crate::pristine::sanakirja::Db;
+ let db: Db<L64, ()> = Db::from_page(*channel);
replacement in libpijul/src/tag/txn.rs at line 443
[4.14025]→[4.14025:14102](∅→∅) − ) -> Result<Option<(&L64, &SerializedHash)>, TxnErr<Self::GraphError>> {
+ ) -> Result<Option<&L64>, TxnErr<Self::GraphError>> {
replacement in libpijul/src/tag/txn.rs at line 445
[4.14145]→[4.14145:14163](∅→∅) replacement in libpijul/src/tag/txn.rs at line 454
[4.14340]→[4.14340:14417](∅→∅) − ) -> Result<Option<(&L64, &SerializedHash)>, TxnErr<Self::GraphError>> {
+ ) -> Result<Option<&L64>, TxnErr<Self::GraphError>> {
replacement in libpijul/src/tag/txn.rs at line 456
[4.14460]→[4.14460:14478](∅→∅) replacement in libpijul/src/tag/txn.rs at line 467
[4.14675]→[4.14675:14760](∅→∅) − crate::pristine::Cursor<Self, &Self, Self::TagsCursor, L64, SerializedHash>,
+ crate::pristine::Cursor<Self, &Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/tag/txn.rs at line 478
[4.14973]→[4.14973:15061](∅→∅) − crate::pristine::RevCursor<Self, &Self, Self::TagsCursor, L64, SerializedHash>,
+ crate::pristine::RevCursor<Self, &Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/tag/txn.rs at line 481
[4.15103]→[4.15103:15217](∅→∅) − use crate::pristine::sanakirja::UDb;
− let db: UDb<L64, SerializedHash> = UDb::from_page(*channel);
+ use crate::pristine::sanakirja::Db;
+ let db: Db<L64, ()> = Db::from_page(*channel);
edit in libpijul/src/tag/txn.rs at line 640
+ fn is_tagged(&self, tags: &Self::Tags, t: u64) -> Result<bool, TxnErr<Self::GraphError>> {
+ self.tag.is_tagged(tags, t)
+ }
+
edit in libpijul/src/tag/txn.rs at line 746
[4.22648]→[4.22648:22841](∅→∅) − fn get_tags(
− &self,
− channel: &Self::Tags,
− c: &L64,
− ) -> Result<Option<&SerializedHash>, TxnErr<Self::GraphError>> {
− self.tag.get_tags(channel, c)
− }
−
replacement in libpijul/src/tag/txn.rs at line 752
[4.23017]→[4.23017:23107](∅→∅) − crate::pristine::Cursor<Self, &'txn Self, Self::TagsCursor, L64, SerializedHash>,
+ crate::pristine::Cursor<Self, &'txn Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/tag/txn.rs at line 760
[4.23298]→[4.23298:23375](∅→∅) − ) -> Result<Option<(&L64, &SerializedHash)>, TxnErr<Self::GraphError>> {
+ ) -> Result<Option<&L64>, TxnErr<Self::GraphError>> {
replacement in libpijul/src/tag/txn.rs at line 767
[4.23503]→[4.23503:23580](∅→∅) − ) -> Result<Option<(&L64, &SerializedHash)>, TxnErr<Self::GraphError>> {
+ ) -> Result<Option<&L64>, TxnErr<Self::GraphError>> {
replacement in libpijul/src/tag/txn.rs at line 776
[4.23728]→[4.23728:23813](∅→∅) − crate::pristine::Cursor<Self, &Self, Self::TagsCursor, L64, SerializedHash>,
+ crate::pristine::Cursor<Self, &Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/tag/txn.rs at line 787
[4.24038]→[4.24038:24126](∅→∅) − crate::pristine::RevCursor<Self, &Self, Self::TagsCursor, L64, SerializedHash>,
+ crate::pristine::RevCursor<Self, &Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/pristine/sanakirja.rs at line 726
[4.70500]→[4.23047:23087](∅→∅) − pub tags: UDb<L64, SerializedHash>,
replacement in libpijul/src/pristine/sanakirja.rs at line 926
[4.23105]→[4.23105:23430](∅→∅) − type Tags = UDb<L64, SerializedHash>;
− fn get_tags(
− &self,
− channel: &Self::Tags,
− c: &L64,
− ) -> Result<Option<&SerializedHash>, TxnErr<Self::GraphError>> {
− match btree::get(&self.txn, channel, c, None)? {
− Some((k, v)) if k == c => Ok(Some(v)),
− _ => Ok(None),
+ type Tags = Db<L64, ()>;
+
+ fn is_tagged(&self, tags: &Self::Tags, t: u64) -> Result<bool, TxnErr<Self::GraphError>> {
+ let t: L64 = t.into();
+ match btree::get(&self.txn, tags, &t, None)? {
+ Some((k, _)) => Ok(k == &t),
+ _ => Ok(false)
replacement in libpijul/src/pristine/sanakirja.rs at line 937
[4.23469]→[4.23469:23559](∅→∅) − ::sanakirja::btree::cursor::Cursor<L64, SerializedHash, UP<L64, SerializedHash>>;
+ ::sanakirja::btree::cursor::Cursor<L64, (), P<L64, ()>>;
replacement in libpijul/src/pristine/sanakirja.rs at line 943
[4.23676]→[4.23676:23766](∅→∅) − crate::pristine::Cursor<Self, &'txn Self, Self::TagsCursor, L64, SerializedHash>,
+ crate::pristine::Cursor<Self, &'txn Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/pristine/sanakirja.rs at line 961
[4.24249]→[4.24249:24326](∅→∅) − ) -> Result<Option<(&L64, &SerializedHash)>, TxnErr<Self::GraphError>> {
+ ) -> Result<Option<&L64>, TxnErr<Self::GraphError>> {
replacement in libpijul/src/pristine/sanakirja.rs at line 963
[4.24374]→[4.24374:24392](∅→∅) replacement in libpijul/src/pristine/sanakirja.rs at line 972
[4.24562]→[4.24562:24639](∅→∅) − ) -> Result<Option<(&L64, &SerializedHash)>, TxnErr<Self::GraphError>> {
+ ) -> Result<Option<&L64>, TxnErr<Self::GraphError>> {
replacement in libpijul/src/pristine/sanakirja.rs at line 974
[4.24687]→[4.24687:24705](∅→∅) replacement in libpijul/src/pristine/sanakirja.rs at line 985
[4.2184]→[4.2184:2259](∅→∅) − super::Cursor<Self, &Self, Self::TagsCursor, L64, SerializedHash>,
+ super::Cursor<Self, &Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/pristine/sanakirja.rs at line 996
[4.2472]→[4.2472:2550](∅→∅) − super::RevCursor<Self, &Self, Self::TagsCursor, L64, SerializedHash>,
+ super::RevCursor<Self, &Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/pristine/sanakirja.rs at line 1174
[4.26643]→[4.26643:26702](∅→∅) − tags: UDb::from_page(tup.tags.into()),
+ tags: Db::from_page(tup.tags.into()),
edit in libpijul/src/pristine/sanakirja.rs at line 1731
[4.25300]→[4.25300:25318](∅→∅) replacement in libpijul/src/pristine/sanakirja.rs at line 1732
[4.25366]→[4.25366:25443](∅→∅) − btree::put(&mut self.txn, &mut channel.tags, &t.into(), &h.into())?;
+ btree::put(&mut self.txn, &mut channel.tags, &t.into(), &())?;
replacement in libpijul/src/pristine/sanakirja.rs at line 1838
[4.28817]→[4.28817:28882](∅→∅) − tags: UDb::from_page(b.tags.into()),
+ tags: Db::from_page(b.tags.into()),
replacement in libpijul/src/pristine/sanakirja.rs at line 1983
[4.30119]→[4.30119:30173](∅→∅) − UDb::from_page(chan.tags.into()),
+ Db::from_page(chan.tags.into()),
replacement in libpijul/src/pristine/sanakirja.rs at line 2188
[4.31856]→[4.31856:31913](∅→∅) − tags: UDb::from_page(c.tags.into()),
+ tags: Db::from_page(c.tags.into()),
replacement in libpijul/src/pristine/mod.rs at line 451
[4.26541]→[4.26541:26688](∅→∅) − fn get_tags(
− &self,
− channel: &Self::Tags,
− c: &L64,
− ) -> Result<Option<&SerializedHash>, TxnErr<Self::GraphError>>;
+ fn is_tagged(&self, tags: &Self::Tags, t: u64) -> Result<bool, TxnErr<Self::GraphError>>;
replacement in libpijul/src/pristine/mod.rs at line 459
[4.26829]→[4.26829:26919](∅→∅) − crate::pristine::Cursor<Self, &'txn Self, Self::TagsCursor, L64, SerializedHash>,
+ crate::pristine::Cursor<Self, &'txn Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/pristine/mod.rs at line 466
[4.27039]→[4.27039:27115](∅→∅) − ) -> Result<Option<(&L64, &SerializedHash)>, TxnErr<Self::GraphError>>;
+ ) -> Result<Option<&L64>, TxnErr<Self::GraphError>>;
replacement in libpijul/src/pristine/mod.rs at line 471
[4.27195]→[4.27195:27271](∅→∅) − ) -> Result<Option<(&L64, &SerializedHash)>, TxnErr<Self::GraphError>>;
+ ) -> Result<Option<&L64>, TxnErr<Self::GraphError>>;
replacement in libpijul/src/pristine/mod.rs at line 477
[4.3189]→[4.2544:2647](∅→∅) − ) -> Result<Cursor<Self, &Self, Self::TagsCursor, L64, SerializedHash>, TxnErr<Self::GraphError>>;
+ ) -> Result<Cursor<Self, &Self, Self::TagsCursor, L64, ()>, TxnErr<Self::GraphError>>;
replacement in libpijul/src/pristine/mod.rs at line 484
[4.3427]→[4.3427:3498](∅→∅) − RevCursor<Self, &Self, Self::TagsCursor, L64, SerializedHash>,
+ RevCursor<Self, &Self, Self::TagsCursor, L64, ()>,
replacement in libpijul/src/pristine/mod.rs at line 1501
[4.22745]→[4.3540:3690](∅→∅),
[4.68729]→[4.3540:3690](∅→∅) − initialized_cursor!(tags, L64, SerializedHash, ChannelTxnT, GraphError);
− initialized_rev_cursor!(tags, L64, SerializedHash, ChannelTxnT, GraphError);
+
+ impl<'a, T: ChannelTxnT> Iterator for crate::pristine::RevCursor<T, &'a T, T::TagsCursor, L64, ()>
+ {
+ type Item = Result<&'a L64, TxnErr<T::GraphError>>;
+ fn next(&mut self) -> Option<Self::Item> {
+ match self.txn.cursor_tags_prev(&mut self.cursor) {
+ Ok(Some(x)) => Some(Ok(x)),
+ Ok(None) => None,
+ Err(e) => Some(Err(e)),
+ }
+ }
+ }
+
+ impl<'a, T: ChannelTxnT>
+ crate::pristine::Cursor<T, &'a T, T::TagsCursor, L64, ()>
+ {
+ pub fn prev(&mut self) -> Option<Result<u64, TxnErr<T::GraphError>>> {
+ match self.txn.cursor_tags_prev(&mut self.cursor) {
+ Ok(Some(x)) => Some(Ok((*x).into())),
+ Ok(None) => None,
+ Err(e) => Some(Err(e)),
+ }
+ }
+ }
+
+ impl<'a, T: ChannelTxnT> Iterator for crate::pristine::Cursor<T, &'a T, T::TagsCursor, L64, ()>
+ {
+ type Item = Result<u64, TxnErr<T::GraphError>>;
+ fn next(&mut self) -> Option<Self::Item> {
+ match self.txn.cursor_tags_next(&mut self.cursor) {
+ Ok(Some(x)) => Some(Ok((*x).into())),
+ Ok(None) => None,
+ Err(e) => Some(Err(e)),
+ }
+ }
+ }
edit in libpijul/src/pristine/mod.rs at line 1789
[4.27411]→[4.27411:27429](∅→∅) replacement in libpijul/src/changestore/filesystem.rs at line 3
[4.824124]→[4.824124:824179](∅→∅) − use crate::pristine::{Base32, ChangeId, Hash, Vertex};
+ use crate::pristine::{Base32, ChangeId, Hash, Vertex, Merkle};
edit in libpijul/src/changestore/filesystem.rs at line 41
+ }
+
+ pub fn push_tag_filename(changes_dir: &mut PathBuf, hash: &Merkle) {
+ let h32 = hash.to_base32();
+ let (a, b) = h32.split_at(2);
+ changes_dir.push(a);
+ changes_dir.push(b);
+ changes_dir.set_extension("tag");