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YC75DJZ5LYXOQPJAC
struct CopyTxn {}
impl ::sanakirja::AllocPage for CopyTxn {
/// Allocate a single page.
unsafe fn alloc_page(&mut self) -> Result<::sanakirja::MutPage, Self::Error> {
unimplemented!()
}
/// Allocate a single page.
unsafe fn alloc_page_no_dirty(&mut self) -> Result<::sanakirja::MutPage, Self::Error> {
unimplemented!()
}
/// Allocate many contiguous pages, return the first one
unsafe fn alloc_contiguous(&mut self, _: u64) -> Result<::sanakirja::MutPage, Self::Error> {
unimplemented!()
}
/// Increment the reference count for page `off`.
fn incr_rc(&mut self, _: u64) -> Result<usize, Self::Error> {
unimplemented!()
}
unsafe fn decr_rc(&mut self, _: u64) -> Result<usize, Self::Error> {
unimplemented!()
}
unsafe fn decr_rc_owned(&mut self, _: u64) -> Result<usize, Self::Error> {
unimplemented!()
}
}
impl ::sanakirja::LoadPage for CopyTxn {
type Error = std::convert::Infallible;
unsafe fn load_page(&self, _: u64) -> Result<::sanakirja::CowPage, Self::Error> {
unimplemented!()
}
}
use crate::pristine::sanakirja::Db;
let gr: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(db.graph);
Ok(::sanakirja::btree::get(self, &gr, key, value)?.map(|(_, v)| v))
unsafe {
use crate::pristine::sanakirja::Db;
let gr: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(db.graph);
Ok(::sanakirja::btree::get(self, &gr, key, value)?.map(|(_, v)| v))
}
use crate::pristine::sanakirja::UDb;
let gr: UDb<ChangeId, SerializedHash> = UDb::from_page(self.header.offsets.external);
Ok(::sanakirja::btree::get(self, &gr, int, None)?.map(|(_, v)| v))
unsafe {
use crate::pristine::sanakirja::UDb;
let gr: UDb<ChangeId, SerializedHash> = UDb::from_page(self.header.offsets.external);
Ok(::sanakirja::btree::get(self, &gr, int, None)?.map(|(_, v)| v))
}
use crate::pristine::sanakirja::UDb;
let gr: UDb<SerializedHash, ChangeId> = UDb::from_page(self.header.offsets.internal);
Ok(::sanakirja::btree::get(self, &gr, int, None)?.map(|(_, v)| v))
unsafe {
use crate::pristine::sanakirja::UDb;
let gr: UDb<SerializedHash, ChangeId> = UDb::from_page(self.header.offsets.internal);
Ok(::sanakirja::btree::get(self, &gr, int, None)?.map(|(_, v)| v))
}
let edge = SerializedEdge::new(min_flag, dest.change, dest.pos, ChangeId::ROOT);
use crate::pristine::sanakirja::Db;
let gr: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(g.graph);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &gr)?;
cursor.set(self, &key, Some(&edge))?;
Ok(Self::Adj {
cursor,
key,
min_flag,
max_flag,
})
unsafe {
let edge = SerializedEdge::new(min_flag, dest.change, dest.pos, ChangeId::ROOT);
use crate::pristine::sanakirja::Db;
let gr: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(g.graph);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &gr)?;
cursor.set(self, &key, Some(&edge))?;
Ok(Self::Adj {
cursor,
key,
min_flag,
max_flag,
})
}
use crate::pristine::sanakirja::Db;
let gr: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(graph.graph);
Ok(crate::pristine::sanakirja::find_block(self, &gr, p)?)
unsafe {
use crate::pristine::sanakirja::Db;
let gr: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(graph.graph);
Ok(crate::pristine::sanakirja::find_block(self, &gr, p)?)
}
use crate::pristine::sanakirja::Db;
let gr: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(graph.graph);
Ok(crate::pristine::sanakirja::find_block_end(self, &gr, p)?)
unsafe {
use crate::pristine::sanakirja::Db;
let gr: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(graph.graph);
Ok(crate::pristine::sanakirja::find_block_end(self, &gr, p)?)
}
use crate::pristine::sanakirja::Db;
let db: Db<ChangeId, L64> = Db::from_page(*channel);
match ::sanakirja::btree::get(self, &db, c, None) {
Ok(Some((k, x))) if k == c => Ok(Some(x)),
Ok(x) => {
debug!("get_changeset = {:?}", x);
Ok(None)
unsafe {
use crate::pristine::sanakirja::Db;
let db: Db<ChangeId, L64> = Db::from_page(*channel);
match ::sanakirja::btree::get(self, &db, c, None) {
Ok(Some((k, x))) if k == c => Ok(Some(x)),
Ok(x) => {
debug!("get_changeset = {:?}", x);
Ok(None)
}
Err(e) => {
error!("{:?}", e);
Err(TxnErr(SanakirjaError::PristineCorrupt).into())
}
use crate::pristine::sanakirja::UDb;
let db: UDb<L64, Pair<ChangeId, SerializedMerkle>> = UDb::from_page(*revchanges);
match ::sanakirja::btree::get(self, &db, c, None) {
Ok(Some((k, x))) if k == c => Ok(Some(x)),
Ok(_) => Ok(None),
Err(e) => {
error!("{:?}", e);
Err(TxnErr(SanakirjaError::PristineCorrupt).into())
unsafe {
use crate::pristine::sanakirja::UDb;
let db: UDb<L64, Pair<ChangeId, SerializedMerkle>> = UDb::from_page(*revchanges);
match ::sanakirja::btree::get(self, &db, c, None) {
Ok(Some((k, x))) if k == c => Ok(Some(x)),
Ok(_) => Ok(None),
Err(e) => {
error!("{:?}", e);
Err(TxnErr(SanakirjaError::PristineCorrupt).into())
}
use crate::pristine::sanakirja::Db;
let db: Db<ChangeId, L64> = Db::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &db)?;
if let Some(k) = pos {
cursor.set(self, &k, None)?;
unsafe {
use crate::pristine::sanakirja::Db;
let db: Db<ChangeId, L64> = Db::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &db)?;
if let Some(k) = pos {
cursor.set(self, &k, None)?;
}
Ok(Cursor {
cursor,
txn: self,
k: std::marker::PhantomData,
v: std::marker::PhantomData,
t: std::marker::PhantomData,
})
use crate::pristine::sanakirja::UDb;
let db: UDb<L64, Pair<ChangeId, SerializedMerkle>> = UDb::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(&*txn, &db)?;
if let Some(k) = pos {
cursor.set(&*txn, &k, None)?;
unsafe {
use crate::pristine::sanakirja::UDb;
let db: UDb<L64, Pair<ChangeId, SerializedMerkle>> = UDb::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(&*txn, &db)?;
if let Some(k) = pos {
cursor.set(&*txn, &k, None)?;
}
Ok(Cursor {
cursor,
txn,
k: std::marker::PhantomData,
v: std::marker::PhantomData,
t: std::marker::PhantomData,
})
use crate::pristine::sanakirja::UDb;
let db: UDb<L64, Pair<ChangeId, SerializedMerkle>> = UDb::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &db)?;
if let Some(ref pos) = pos {
cursor.set(self, pos, None)?;
} else {
cursor.set_last(self)?;
};
Ok(RevCursor {
cursor,
txn: self,
k: std::marker::PhantomData,
v: std::marker::PhantomData,
t: std::marker::PhantomData,
})
unsafe {
use crate::pristine::sanakirja::UDb;
let db: UDb<L64, Pair<ChangeId, SerializedMerkle>> = UDb::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &db)?;
if let Some(ref pos) = pos {
cursor.set(self, pos, None)?;
} else {
cursor.set_last(self)?;
};
Ok(RevCursor {
cursor,
txn: self,
k: std::marker::PhantomData,
v: std::marker::PhantomData,
t: std::marker::PhantomData,
})
}
use crate::pristine::sanakirja::UDb;
let db: UDb<SerializedMerkle, L64> = UDb::from_page(*channel);
match ::sanakirja::btree::get(self, &db, m, None)? {
Some((k, v)) if k == m => Ok(Some(*v)),
_ => Ok(None),
unsafe {
use crate::pristine::sanakirja::UDb;
let db: UDb<SerializedMerkle, L64> = UDb::from_page(*channel);
match ::sanakirja::btree::get(self, &db, m, None)? {
Some((k, v)) if k == m => Ok(Some(*v)),
_ => Ok(None),
}
use crate::pristine::sanakirja::Db;
let db: Db<L64, Pair<SerializedMerkle, SerializedMerkle>> = Db::from_page(*tags);
let t: L64 = t.into();
match ::sanakirja::btree::get(self, &db, &t, None)? {
Some((k, _)) => Ok(k == &t),
_ => Ok(false),
unsafe {
use crate::pristine::sanakirja::Db;
let db: Db<L64, Pair<SerializedMerkle, SerializedMerkle>> = Db::from_page(*tags);
let t: L64 = t.into();
match ::sanakirja::btree::get(self, &db, &t, None)? {
Some((k, _)) => Ok(k == &t),
_ => Ok(false),
}
use crate::pristine::sanakirja::Db;
let db: Db<L64, Pair<SerializedMerkle, SerializedMerkle>> = Db::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &db)?;
if let Some(k) = k {
cursor.set(self, &k, None)?;
unsafe {
use crate::pristine::sanakirja::Db;
let db: Db<L64, Pair<SerializedMerkle, SerializedMerkle>> = Db::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &db)?;
if let Some(k) = k {
cursor.set(self, &k, None)?;
}
Ok(Cursor {
cursor,
txn: self,
k: std::marker::PhantomData,
v: std::marker::PhantomData,
t: std::marker::PhantomData,
})
use crate::pristine::sanakirja::Db;
let db: Db<L64, Pair<SerializedMerkle, SerializedMerkle>> = Db::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &db)?;
if let Some(from) = from {
cursor.set(self, &from.into(), None)?;
} else {
cursor.set_last(self)?;
};
Ok(RevCursor {
cursor,
txn: self,
k: std::marker::PhantomData,
v: std::marker::PhantomData,
t: std::marker::PhantomData,
})
unsafe {
use crate::pristine::sanakirja::Db;
let db: Db<L64, Pair<SerializedMerkle, SerializedMerkle>> = Db::from_page(*channel);
let mut cursor = ::sanakirja::btree::cursor::Cursor::new(self, &db)?;
if let Some(from) = from {
cursor.set(self, &from.into(), None)?;
} else {
cursor.set_last(self)?;
};
Ok(RevCursor {
cursor,
txn: self,
k: std::marker::PhantomData,
v: std::marker::PhantomData,
t: std::marker::PhantomData,
})
}
let mut txn = ::sanakirja::Env::mut_txn_begin(self.env.clone()).unwrap();
if let Some(version) = txn.root(Root::Version as usize) {
if L64(version) != VERSION {
return Err(SanakirjaError::Version.into());
unsafe {
let mut txn = ::sanakirja::Env::mut_txn_begin(self.env.clone()).unwrap();
if let Some(version) = txn.root(Root::Version as usize) {
if version != VERSION {
return Err(SanakirjaError::Version.into());
}
} else {
txn.set_root(Root::Version as usize, VERSION);
} else {
txn.set_root(Root::Version as usize, VERSION.0);
Ok(MutTxn {
channels: if let Some(db) = txn.root_db(Root::Channels as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
external: if let Some(db) = txn.root_db(Root::External as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
internal: if let Some(db) = txn.root_db(Root::Internal as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
inodes: if let Some(db) = txn.root_db(Root::Inodes as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
revinodes: if let Some(db) = txn.root_db(Root::RevInodes as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
tree: if let Some(db) = txn.root_db(Root::Tree as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
revtree: if let Some(db) = txn.root_db(Root::RevTree as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
revdep: if let Some(db) = txn.root_db(Root::RevDep as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
dep: if let Some(db) = txn.root_db(Root::Dep as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
touched_files: if let Some(db) = txn.root_db(Root::TouchedFiles as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
rev_touched_files: if let Some(db) = txn.root_db(Root::RevTouchedFiles as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
partials: if let Some(db) = txn.root_db(Root::Partials as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
remotes: if let Some(db) = txn.root_db(Root::Remotes as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
open_channels: Mutex::new(HashMap::default()),
open_remotes: Mutex::new(HashMap::default()),
txn,
counter: 0,
cur_channel: None,
})
Ok(MutTxn {
channels: if let Some(db) = txn.root_db(Root::Channels as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
external: if let Some(db) = txn.root_db(Root::External as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
internal: if let Some(db) = txn.root_db(Root::Internal as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
inodes: if let Some(db) = txn.root_db(Root::Inodes as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
revinodes: if let Some(db) = txn.root_db(Root::RevInodes as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
tree: if let Some(db) = txn.root_db(Root::Tree as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
revtree: if let Some(db) = txn.root_db(Root::RevTree as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
revdep: if let Some(db) = txn.root_db(Root::RevDep as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
dep: if let Some(db) = txn.root_db(Root::Dep as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
touched_files: if let Some(db) = txn.root_db(Root::TouchedFiles as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
rev_touched_files: if let Some(db) = txn.root_db(Root::RevTouchedFiles as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
partials: if let Some(db) = txn.root_db(Root::Partials as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
remotes: if let Some(db) = txn.root_db(Root::Remotes as usize) {
db
} else {
btree::create_db_(&mut txn)?
},
open_channels: Mutex::new(HashMap::default()),
open_remotes: Mutex::new(HashMap::default()),
txn,
counter: 0,
cur_channel: None,
})
use ::sanakirja::debug::Check;
debug!("check: internal 0x{:x}", self.internal.db);
self.internal.add_refs(&self.txn, refs).unwrap();
debug!("check: external 0x{:x}", self.external.db);
self.external.add_refs(&self.txn, refs).unwrap();
debug!("check: inodes 0x{:x}", self.inodes.db);
self.inodes.add_refs(&self.txn, refs).unwrap();
debug!("check: revinodes 0x{:x}", self.revinodes.db);
self.revinodes.add_refs(&self.txn, refs).unwrap();
debug!("check: tree 0x{:x}", self.tree.db);
self.tree.add_refs(&self.txn, refs).unwrap();
debug!("check: revtree 0x{:x}", self.revtree.db);
self.revtree.add_refs(&self.txn, refs).unwrap();
debug!("check: revdep 0x{:x}", self.revdep.db);
self.revdep.add_refs(&self.txn, refs).unwrap();
debug!("check: dep 0x{:x}", self.dep.db);
self.dep.add_refs(&self.txn, refs).unwrap();
debug!("check: touched_files 0x{:x}", self.touched_files.db);
self.touched_files.add_refs(&self.txn, refs).unwrap();
debug!("check: rev_touched_files 0x{:x}", self.rev_touched_files.db);
self.rev_touched_files.add_refs(&self.txn, refs).unwrap();
debug!("check: partials 0x{:x}", self.partials.db);
self.partials.add_refs(&self.txn, refs).unwrap();
debug!("check: channels 0x{:x}", self.channels.db);
self.channels.add_refs(&self.txn, refs).unwrap();
for x in btree::iter(&self.txn, &self.channels, None).unwrap() {
let (name, tup) = x.unwrap();
debug!("check: channel name: {:?}", name.as_str());
let graph: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(tup.graph.into());
let changes: Db<ChangeId, L64> = Db::from_page(tup.changes.into());
let revchanges: UDb<L64, Pair<ChangeId, SerializedMerkle>> =
UDb::from_page(tup.revchanges.into());
let states: UDb<SerializedMerkle, L64> = UDb::from_page(tup.states.into());
let tags: Db<L64, Pair<SerializedMerkle, SerializedMerkle>> =
Db::from_page(tup.tags.into());
debug!("check: graph 0x{:x}", graph.db);
graph.add_refs(&self.txn, refs).unwrap();
debug!("check: changes 0x{:x}", changes.db);
changes.add_refs(&self.txn, refs).unwrap();
debug!("check: revchanges 0x{:x}", revchanges.db);
revchanges.add_refs(&self.txn, refs).unwrap();
debug!("check: states 0x{:x}", states.db);
states.add_refs(&self.txn, refs).unwrap();
debug!("check: tags 0x{:x}", tags.db);
tags.add_refs(&self.txn, refs).unwrap();
}
debug!("check: remotes 0x{:x}", self.remotes.db);
self.remotes.add_refs(&self.txn, refs).unwrap();
for x in btree::iter(&self.txn, &self.remotes, None).unwrap() {
let (name, tup) = x.unwrap();
debug!("check: remote name: {:?}", name);
let remote: UDb<L64, Pair<SerializedHash, SerializedMerkle>> =
UDb::from_page(tup.remote.into());
unsafe {
use ::sanakirja::debug::Check;
debug!("check: internal 0x{:x}", self.internal.db);
self.internal.add_refs(&self.txn, refs).unwrap();
debug!("check: external 0x{:x}", self.external.db);
self.external.add_refs(&self.txn, refs).unwrap();
debug!("check: inodes 0x{:x}", self.inodes.db);
self.inodes.add_refs(&self.txn, refs).unwrap();
debug!("check: revinodes 0x{:x}", self.revinodes.db);
self.revinodes.add_refs(&self.txn, refs).unwrap();
debug!("check: tree 0x{:x}", self.tree.db);
self.tree.add_refs(&self.txn, refs).unwrap();
debug!("check: revtree 0x{:x}", self.revtree.db);
self.revtree.add_refs(&self.txn, refs).unwrap();
debug!("check: revdep 0x{:x}", self.revdep.db);
self.revdep.add_refs(&self.txn, refs).unwrap();
debug!("check: dep 0x{:x}", self.dep.db);
self.dep.add_refs(&self.txn, refs).unwrap();
debug!("check: touched_files 0x{:x}", self.touched_files.db);
self.touched_files.add_refs(&self.txn, refs).unwrap();
debug!("check: rev_touched_files 0x{:x}", self.rev_touched_files.db);
self.rev_touched_files.add_refs(&self.txn, refs).unwrap();
debug!("check: partials 0x{:x}", self.partials.db);
self.partials.add_refs(&self.txn, refs).unwrap();
debug!("check: channels 0x{:x}", self.channels.db);
self.channels.add_refs(&self.txn, refs).unwrap();
for x in btree::iter(&self.txn, &self.channels, None).unwrap() {
let (name, tup) = x.unwrap();
debug!("check: channel name: {:?}", name.as_str());
let graph: Db<Vertex<ChangeId>, SerializedEdge> = Db::from_page(tup.graph.into());
let changes: Db<ChangeId, L64> = Db::from_page(tup.changes.into());
let revchanges: UDb<L64, Pair<ChangeId, SerializedMerkle>> =
UDb::from_page(tup.revchanges.into());
let states: UDb<SerializedMerkle, L64> = UDb::from_page(tup.states.into());
let tags: Db<L64, Pair<SerializedMerkle, SerializedMerkle>> =
Db::from_page(tup.tags.into());
debug!("check: graph 0x{:x}", graph.db);
graph.add_refs(&self.txn, refs).unwrap();
debug!("check: changes 0x{:x}", changes.db);
changes.add_refs(&self.txn, refs).unwrap();
debug!("check: revchanges 0x{:x}", revchanges.db);
revchanges.add_refs(&self.txn, refs).unwrap();
debug!("check: states 0x{:x}", states.db);
states.add_refs(&self.txn, refs).unwrap();
debug!("check: tags 0x{:x}", tags.db);
tags.add_refs(&self.txn, refs).unwrap();
}
debug!("check: remotes 0x{:x}", self.remotes.db);
self.remotes.add_refs(&self.txn, refs).unwrap();
for x in btree::iter(&self.txn, &self.remotes, None).unwrap() {
let (name, tup) = x.unwrap();
debug!("check: remote name: {:?}", name);
let remote: UDb<L64, Pair<SerializedHash, SerializedMerkle>> =
UDb::from_page(tup.remote.into());
let rev: UDb<SerializedHash, L64> = UDb::from_page(tup.rev.into());
let states: UDb<SerializedMerkle, L64> = UDb::from_page(tup.states.into());
let tags: UDb<L64, Pair<SerializedMerkle, SerializedMerkle>> =
UDb::from_page(tup.tags.into());
debug!("check: remote 0x{:x}", remote.db);
remote.add_refs(&self.txn, refs).unwrap();
debug!("check: rev 0x{:x}", rev.db);
rev.add_refs(&self.txn, refs).unwrap();
debug!("check: states 0x{:x}", states.db);
states.add_refs(&self.txn, refs).unwrap();
debug!("check: tags 0x{:x}", tags.db);
tags.add_refs(&self.txn, refs).unwrap();
let rev: UDb<SerializedHash, L64> = UDb::from_page(tup.rev.into());
let states: UDb<SerializedMerkle, L64> = UDb::from_page(tup.states.into());
let tags: UDb<L64, Pair<SerializedMerkle, SerializedMerkle>> =
UDb::from_page(tup.tags.into());
debug!("check: remote 0x{:x}", remote.db);
remote.add_refs(&self.txn, refs).unwrap();
debug!("check: rev 0x{:x}", rev.db);
rev.add_refs(&self.txn, refs).unwrap();
debug!("check: states 0x{:x}", states.db);
states.add_refs(&self.txn, refs).unwrap();
debug!("check: tags 0x{:x}", tags.db);
tags.add_refs(&self.txn, refs).unwrap();
}
::sanakirja::debug::add_free_refs(&self.txn, refs).unwrap();
::sanakirja::debug::check_free(&self.txn, &refs);
let name = name.to_owned();
match self.open_remotes.lock().entry(name.clone()) {
Entry::Vacant(v) => match btree::get(&self.txn, &self.remotes, &name, None)? {
Some((name_, remote)) if name == *name_ => {
debug!("load_remote: {:?} {:?}", name_, remote);
let r = Remote {
remote: UDb::from_page(remote.remote.into()),
rev: UDb::from_page(remote.rev.into()),
states: UDb::from_page(remote.states.into()),
id_rev: remote.id_rev.into(),
tags: Db::from_page(remote.tags.into()),
path: remote.path.to_owned(),
};
for x in btree::iter(&self.txn, &r.remote, None).unwrap() {
debug!("remote -> {:?}", x);
}
for x in btree::iter(&self.txn, &r.rev, None).unwrap() {
debug!("rev -> {:?}", x);
}
for x in btree::iter(&self.txn, &r.states, None).unwrap() {
debug!("states -> {:?}", x);
}
unsafe {
let name = name.to_owned();
match self.open_remotes.lock().entry(name.clone()) {
Entry::Vacant(v) => match btree::get(&self.txn, &self.remotes, &name, None)? {
Some((name_, remote)) if name == *name_ => {
debug!("load_remote: {:?} {:?}", name_, remote);
let r = Remote {
remote: UDb::from_page(remote.remote.into()),
rev: UDb::from_page(remote.rev.into()),
states: UDb::from_page(remote.states.into()),
id_rev: remote.id_rev.into(),
tags: Db::from_page(remote.tags.into()),
path: remote.path.to_owned(),
};
for x in btree::iter(&self.txn, &r.remote, None).unwrap() {
debug!("remote -> {:?}", x);
}
for x in btree::iter(&self.txn, &r.rev, None).unwrap() {
debug!("rev -> {:?}", x);
}
for x in btree::iter(&self.txn, &r.states, None).unwrap() {
debug!("states -> {:?}", x);
}
let r = RemoteRef {
db: Arc::new(Mutex::new(r)),
id: name,
};
Ok(Some(v.insert(r).clone()))
}
_ => return Ok(None),
},
Entry::Occupied(occ) => Ok(Some(occ.get().clone())),
_ => return Ok(None),
},
Entry::Occupied(occ) => Ok(Some(occ.get().clone())),
}
let name = name.to_owned();
match self.open_remotes.lock().entry(name.clone()) {
Entry::Vacant(v) => match btree::get(&self.txn, &self.remotes, &name, None)? {
Some((name_, remote)) if *name_ == name => {
let r = RemoteRef {
db: Arc::new(Mutex::new(Remote {
remote: UDb::from_page(remote.remote.into()),
rev: UDb::from_page(remote.rev.into()),
states: UDb::from_page(remote.states.into()),
id_rev: remote.id_rev.into(),
tags: Db::from_page(remote.tags.into()),
path: remote.path.to_owned(),
})),
id: name,
};
v.insert(r);
}
_ => return Ok(None),
},
Entry::Occupied(_) => {}
unsafe {
let name = name.to_owned();
match self.open_remotes.lock().entry(name.clone()) {
Entry::Vacant(v) => match btree::get(&self.txn, &self.remotes, &name, None)? {
Some((name_, remote)) if *name_ == name => {
let r = RemoteRef {
db: Arc::new(Mutex::new(Remote {
remote: UDb::from_page(remote.remote.into()),
rev: UDb::from_page(remote.rev.into()),
states: UDb::from_page(remote.states.into()),
id_rev: remote.id_rev.into(),
tags: Db::from_page(remote.tags.into()),
path: remote.path.to_owned(),
})),
id: name,
};
v.insert(r);
}
_ => return Ok(None),
},
Entry::Occupied(_) => {}
}
Ok(self.open_remotes.lock().get(&name).cloned())
let name = crate::small_string::SmallString::from_str(name);
let mut commit = None;
let result = match self.open_channels.lock().entry(name.clone()) {
Entry::Vacant(v) => {
let r = match btree::get(&self.txn, &self.channels, &name, None)? {
Some((name_, b)) if name_ == name.as_ref() => ChannelRef {
r: Arc::new(RwLock::new(Channel {
graph: Db::from_page(b.graph.into()),
changes: Db::from_page(b.changes.into()),
revchanges: UDb::from_page(b.revchanges.into()),
states: UDb::from_page(b.states.into()),
tags: Db::from_page(b.tags.into()),
apply_counter: b.apply_counter.into(),
last_modified: b.last_modified.into(),
id: b.id,
name: name.clone(),
})),
},
_ => {
let br = ChannelRef {
unsafe {
let name = crate::small_string::SmallString::from_str(name);
let mut commit = None;
let result = match self.open_channels.lock().entry(name.clone()) {
Entry::Vacant(v) => {
let r = match btree::get(&self.txn, &self.channels, &name, None)? {
Some((name_, b)) if name_ == name.as_ref() => ChannelRef {
graph: btree::create_db_(&mut self.txn)?,
changes: btree::create_db_(&mut self.txn)?,
revchanges: btree::create_db_(&mut self.txn)?,
states: btree::create_db_(&mut self.txn)?,
tags: btree::create_db_(&mut self.txn)?,
id: {
let mut rng = rand::thread_rng();
use rand::Rng;
let mut x = RemoteId([0; 16]);
for x in x.0.iter_mut() {
*x = rng.gen()
}
x
},
apply_counter: 0,
last_modified: 0,
graph: Db::from_page(b.graph.into()),
changes: Db::from_page(b.changes.into()),
revchanges: UDb::from_page(b.revchanges.into()),
states: UDb::from_page(b.states.into()),
tags: Db::from_page(b.tags.into()),
apply_counter: b.apply_counter.into(),
last_modified: b.last_modified.into(),
id: b.id,
};
commit = Some(br.clone());
br
}
};
v.insert(r).clone()
},
_ => {
let br = ChannelRef {
r: Arc::new(RwLock::new(Channel {
graph: btree::create_db_(&mut self.txn)?,
changes: btree::create_db_(&mut self.txn)?,
revchanges: btree::create_db_(&mut self.txn)?,
states: btree::create_db_(&mut self.txn)?,
tags: btree::create_db_(&mut self.txn)?,
id: {
let mut rng = rand::thread_rng();
use rand::Rng;
let mut x = RemoteId([0; 16]);
for x in x.0.iter_mut() {
*x = rng.gen()
}
x
},
apply_counter: 0,
last_modified: 0,
name: name.clone(),
})),
};
commit = Some(br.clone());
br
}
};
v.insert(r).clone()
}
Entry::Occupied(occ) => occ.get().clone(),
};
if let Some(commit) = commit {
self.put_channel(commit)?;
debug!(target: "drop_channel", "drop channel {:?}", name0);
let name = SmallString::from_str(name0);
let channel = if let Some(channel) = self.open_channels.lock().remove(&name) {
let channel = Arc::try_unwrap(channel.r)
.map_err(|_| SanakirjaError::ChannelRc {
c: name0.to_string(),
})?
.into_inner();
Some((
channel.graph,
channel.changes,
channel.revchanges,
channel.states,
channel.tags,
))
} else if let Some((name_, chan)) = btree::get(&self.txn, &self.channels, &name, None)? {
if name_ == name.as_ref() {
unsafe {
debug!(target: "drop_channel", "drop channel {:?}", name0);
let name = SmallString::from_str(name0);
let channel = if let Some(channel) = self.open_channels.lock().remove(&name) {
let channel = Arc::try_unwrap(channel.r)
.map_err(|_| SanakirjaError::ChannelRc {
c: name0.to_string(),
})?
.into_inner();
Db::from_page(chan.graph.into()),
Db::from_page(chan.changes.into()),
UDb::from_page(chan.revchanges.into()),
UDb::from_page(chan.states.into()),
Db::from_page(chan.tags.into()),
channel.graph,
channel.changes,
channel.revchanges,
channel.states,
channel.tags,
} else if let Some((name_, chan)) = btree::get(&self.txn, &self.channels, &name, None)?
{
if name_ == name.as_ref() {
Some((
Db::from_page(chan.graph.into()),
Db::from_page(chan.changes.into()),
UDb::from_page(chan.revchanges.into()),
UDb::from_page(chan.states.into()),
Db::from_page(chan.tags.into()),
))
} else {
None
}
}
} else {
None
};
btree::del(&mut self.txn, &mut self.channels, &name, None)?;
if let Some((a, b, c, d, e)) = channel {
let mut unused_changes = Vec::new();
'outer: for x in btree::rev_iter(&self.txn, &c, None)? {
let (_, p) = x?;
let chan = chan.read();
assert_ne!(chan.name.as_str(), name0);
if self
.channel_has_state(&chan.states, &p.b)
.map_err(|e| e.0)?
.is_some()
{
// This other channel is in the same state as
// our dropped channel is, so all subsequent
// patches are in use.
break 'outer;
};
btree::del(&mut self.txn, &mut self.channels, &name, None)?;
if let Some((a, b, c, d, e)) = channel {
let mut unused_changes = Vec::new();
'outer: for x in btree::rev_iter(&self.txn, &c, None)? {
let (_, p) = x?;
debug!(target: "drop_channel", "testing unused change: {:?}", p);
for chan in self.channels("").map_err(|e| e.0)? {
debug!(target: "drop_channel", "channel: {:?}", name);
let chan = chan.read();
assert_ne!(chan.name.as_str(), name0);
if self
.channel_has_state(&chan.states, &p.b)
.map_err(|e| e.0)?
.is_some()
{
// This other channel is in the same state as
// our dropped channel is, so all subsequent
// patches are in use.
break 'outer;
}
if self
.get_changeset(&chan.changes, &p.a)
.map_err(|e| e.0)?
.is_some()
{
// This channel has a patch, move on.
continue 'outer;
}
if self
.get_changeset(&chan.changes, &p.a)
.map_err(|e| e.0)?
.is_some()
{
// This channel has a patch, move on.
continue 'outer;
debug!(target: "drop_channel", "actually unused: {:?}", p);
unused_changes.push(p.a);
}
let mut deps = Vec::new();
for ch in unused_changes.iter() {
for x in btree::iter(&self.txn, &self.dep, Some((ch, None)))? {
let (k, v) = x?;
if k > ch {
break;
}
deps.push((*k, *v));
}
debug!(target: "drop_channel", "actually unused: {:?}", p);
unused_changes.push(p.a);
}
let mut deps = Vec::new();
for ch in unused_changes.iter() {
for x in btree::iter(&self.txn, &self.dep, Some((ch, None)))? {
let (k, v) = x?;
if k > ch {
break;
for (k, v) in deps.drain(..) {
debug!(target: "drop_channel", "deleting from revdep: {:?} {:?}", k, v);
btree::del(&mut self.txn, &mut self.dep, &k, Some(&v))?;
btree::del(&mut self.txn, &mut self.revdep, &v, Some(&k))?;
for (k, v) in deps.drain(..) {
debug!(target: "drop_channel", "deleting from revdep: {:?} {:?}", k, v);
btree::del(&mut self.txn, &mut self.dep, &k, Some(&v))?;
btree::del(&mut self.txn, &mut self.revdep, &v, Some(&k))?;
}
btree::drop(&mut self.txn, a)?;
btree::drop(&mut self.txn, b)?;
btree::drop(&mut self.txn, c)?;
btree::drop(&mut self.txn, d)?;
btree::drop(&mut self.txn, e)?;
Ok(true)
} else {
Ok(false)
btree::drop(&mut self.txn, a)?;
btree::drop(&mut self.txn, b)?;
btree::drop(&mut self.txn, c)?;
btree::drop(&mut self.txn, d)?;
btree::drop(&mut self.txn, e)?;
Ok(true)
} else {
Ok(false)
let mut commit = None;
match self.open_remotes.lock().entry(id) {
Entry::Vacant(v) => {
let r = match btree::get(&self.txn, &self.remotes, &id, None)? {
Some((name_, remote)) if *name_ == id => RemoteRef {
db: Arc::new(Mutex::new(Remote {
remote: UDb::from_page(remote.remote.into()),
rev: UDb::from_page(remote.rev.into()),
states: UDb::from_page(remote.states.into()),
id_rev: remote.id_rev.into(),
tags: Db::from_page(remote.tags.into()),
path: SmallString::from_str(path),
})),
id,
},
_ => {
let br = RemoteRef {
unsafe {
let mut commit = None;
match self.open_remotes.lock().entry(id) {
Entry::Vacant(v) => {
let r = match btree::get(&self.txn, &self.remotes, &id, None)? {
Some((name_, remote)) if *name_ == id => RemoteRef {
remote: btree::create_db_(&mut self.txn)?,
rev: btree::create_db_(&mut self.txn)?,
states: btree::create_db_(&mut self.txn)?,
id_rev: 0u64.into(),
tags: btree::create_db(&mut self.txn)?,
remote: UDb::from_page(remote.remote.into()),
rev: UDb::from_page(remote.rev.into()),
states: UDb::from_page(remote.states.into()),
id_rev: remote.id_rev.into(),
tags: Db::from_page(remote.tags.into()),
};
commit = Some(br.clone());
br
}
};
v.insert(r);
},
_ => {
let br = RemoteRef {
db: Arc::new(Mutex::new(Remote {
remote: btree::create_db_(&mut self.txn)?,
rev: btree::create_db_(&mut self.txn)?,
states: btree::create_db_(&mut self.txn)?,
id_rev: 0u64.into(),
tags: btree::create_db(&mut self.txn)?,
path: SmallString::from_str(path),
})),
id,
};
commit = Some(br.clone());
br
}
};
v.insert(r);
}
Entry::Occupied(_) => {}
.set_root(Root::RevInodes as usize, self.revinodes.db);
self.txn.set_root(Root::Internal as usize, self.internal.db);
self.txn.set_root(Root::External as usize, self.external.db);
self.txn.set_root(Root::RevDep as usize, self.revdep.db);
self.txn.set_root(Root::Channels as usize, self.channels.db);
self.txn.set_root(Root::Remotes as usize, self.remotes.db);
.set_root(Root::Tree as usize, u64::from(self.tree.db).into());
self.txn
.set_root(Root::RevTree as usize, u64::from(self.revtree.db).into());
self.txn
.set_root(Root::Inodes as usize, u64::from(self.inodes.db).into());
self.txn
.set_root(Root::RevInodes as usize, self.revinodes.db.into());
self.txn
.set_root(Root::Internal as usize, self.internal.db.into());
self.txn
.set_root(Root::External as usize, self.external.db.into());
self.txn
.set_root(Root::RevDep as usize, self.revdep.db.into());
self.txn
.set_root(Root::Channels as usize, self.channels.db.into());
.set_root(Root::TouchedFiles as usize, self.touched_files.db.into());
self.txn.set_root(Root::Dep as usize, self.dep.db.into());
self.txn.set_root(
Root::RevTouchedFiles as usize,
self.rev_touched_files.db.into(),
);
self.txn
.set_root(Root::Partials as usize, self.partials.db.into());
let name = SmallString::from_str(name);
match btree::get(&self.txn, &self.channels, &name, None)? {
Some((name_, c)) if name.as_ref() == name_ => {
debug!("load_const_channel = {:?} {:?}", name_, c);
Ok(Some(Channel {
graph: Db::from_page(c.graph.into()),
changes: Db::from_page(c.changes.into()),
revchanges: UDb::from_page(c.revchanges.into()),
states: UDb::from_page(c.states.into()),
tags: Db::from_page(c.tags.into()),
apply_counter: c.apply_counter.into(),
last_modified: c.last_modified.into(),
id: c.id,
name,
}))
unsafe {
let name = SmallString::from_str(name);
match btree::get(&self.txn, &self.channels, &name, None)? {
Some((name_, c)) if name.as_ref() == name_ => {
debug!("load_const_channel = {:?} {:?}", name_, c);
Ok(Some(Channel {
graph: Db::from_page(c.graph.into()),
changes: Db::from_page(c.changes.into()),
revchanges: UDb::from_page(c.revchanges.into()),
states: UDb::from_page(c.states.into()),
tags: Db::from_page(c.tags.into()),
apply_counter: c.apply_counter.into(),
last_modified: c.last_modified.into(),
id: c.id,
name,
}))
}
_ => Ok(None),
graph: channel.graph.db.into(),
changes: channel.changes.db.into(),
revchanges: channel.revchanges.db.into(),
states: channel.states.db.into(),
tags: channel.tags.db.into(),
graph: u64::from(channel.graph.db).into(),
changes: u64::from(channel.changes.db).into(),
revchanges: u64::from(channel.revchanges.db).into(),
states: u64::from(channel.states.db).into(),
tags: u64::from(channel.tags.db).into(),
.set_root(Root::RevTouchedFiles as usize, self.rev_touched_files.db);
self.txn.set_root(Root::Partials as usize, self.partials.db);
debug!(target: "drop_channel", "testing unused change: {:?}", p);
for chan in self.channels("").map_err(|e| e.0)? {
debug!(target: "drop_channel", "channel: {:?}", name);
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct L64(pub u64);
impl From<usize> for L64 {
fn from(u: usize) -> Self {
L64((u as u64).to_le())
}
}
impl From<u64> for L64 {
fn from(u: u64) -> Self {
L64(u.to_le())
}
}
impl From<L64> for u64 {
fn from(u: L64) -> Self {
u64::from_le(u.0)
}
}
impl From<L64> for usize {
fn from(u: L64) -> Self {
u64::from_le(u.0) as usize
}
}
impl L64 {
pub fn as_u64(&self) -> u64 {
u64::from_le(self.0)
}
pub fn as_usize(&self) -> usize {
u64::from_le(self.0) as usize
}
}
impl std::fmt::Display for L64 {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
self.0.fmt(fmt)
}
}
impl Ord for L64 {
fn cmp(&self, x: &Self) -> std::cmp::Ordering {
u64::from_le(self.0).cmp(&u64::from_le(x.0))
}
}
impl PartialOrd for L64 {
fn partial_cmp(&self, x: &Self) -> Option<std::cmp::Ordering> {
Some(u64::from_le(self.0).cmp(&u64::from_le(x.0)))
}
}
impl std::ops::Add<L64> for L64 {
type Output = Self;
fn add(self, x: L64) -> L64 {
L64((u64::from_le(self.0) + u64::from_le(x.0)).to_le())
}
}
impl std::ops::Add<usize> for L64 {
type Output = Self;
fn add(self, x: usize) -> L64 {
L64((u64::from_le(self.0) + x as u64).to_le())
}
}
impl std::ops::SubAssign<usize> for L64 {
fn sub_assign(&mut self, x: usize) {
self.0 = ((u64::from_le(self.0)) - x as u64).to_le()
}
}
impl L64 {
pub fn from_slice_le(s: &[u8]) -> Self {
let mut u = 0u64;
assert!(s.len() >= 8);
unsafe { std::ptr::copy_nonoverlapping(s.as_ptr(), &mut u as *mut u64 as *mut u8, 8) }
L64(u)
}
pub fn to_slice_le(&self, s: &mut [u8]) {
assert!(s.len() >= 8);
unsafe {
std::ptr::copy_nonoverlapping(&self.0 as *const u64 as *const u8, s.as_mut_ptr(), 8)
}
}
}
let (mut deps, extra) =
dependencies(txn, &channel.read(), change.hashed.changes.iter())?;
let (mut deps, extra) = dependencies(txn, &channel.read(), change.hashed.changes.iter())?;
if has_missing_context_nondeleted(
txn,
channel,
change_id,
e,
)
.map_err(LocalApplyError::from_missing)?
if has_missing_context_nondeleted(txn, channel, change_id, e)
.map_err(LocalApplyError::from_missing)?