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IRZZH53AC L4JXJHWXYNCL4QGJXNKKTOKKTAXKKXBJUUY7HFZGEUZ5A2V5H34QC I52XSRUH5RVHQBFWVMAQPTUSPAJ4KNVID2RMI3UGCVKFLYUO6WZAC YN63NUZO4LVJ7XPMURDULTXBVJKW5MVCTZ24R7Z52QMHO3HPDUVQC 2D7P2VKJASU7QDQZHGCLBIT6G2V5WUFYLWTCEVVEI2EZHGM6XYRAC QE64ATLZWMKHYABCD3VA547PYXCK6YN3K7RE2TX3SCQNKG7XLVAQC B3QWIGDERNMB3M6P5WTWP5CN2DB3KCS7MVTEPC2XVJ237ZXVQGMAC A6R6SGCPLFM45QNWJLISFBR3EEXVITYHCWEUOPNH4UIGIWJRTZAQC 5SLOJYHGPMZVCOE3IS7ICNMJJYX3RBT6CDG5MAV6T4CJIOW7YZ6QC GHO6DWPILBBTL6CVZKERJBTFL3EY6ZT4YM4E5R4S6YPGVFKFHCVAC 2RXOCWUWOGHEKHT5W73LAHJSOZVRTOGS7BWLSIGEEEBJGMCZBXQAC ENKQ3QZGH2QW246C7GSZRKYLODJOQHKZZSYV7QHB7VPOFP5PASVQC pub fn config_path(&self) -> PathBuf {self.path.join(DOT_DIR).join(CONFIG_FILE)}pub fn save_config(&self) -> Result<(), anyhow::Error> {self.config.save(&self.config_path())?;Ok(())}
Ok(())}}impl Config {pub fn save(&self, path: &std::path::Path) -> Result<(), anyhow::Error> {let config = toml::to_string(self)?;let mut file = std::fs::File::create(path)?;file.write_all(config.as_bytes())?;
}pub fn get_current_channel<'a>(&'a self, alt: Option<&'a str>) -> (&'a str, bool) {if let Some(channel) = alt {(channel.as_ref(), alt == self.current_channel.as_deref())} else if let Some(ref channel) = self.current_channel {(channel.as_str(), true)} else {(crate::DEFAULT_CHANNEL, true)}}pub fn current_channel(&self) -> Option<&str> {if let Some(ref channel) = self.current_channel {Some(channel.as_str())} else {None}
let channel = if let Some(channel) = txn.load_channel(channel_name)? {
let cur = txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL);let channel_name = if let Some(ref c) = self.channel {c} else {cur};let is_current_channel = cur == channel_name;let channel = if let Some(channel) = txn.load_channel(&channel_name)? {
let channel_name = repo.config.get_current_channel(channel.as_deref()).0.to_string();
let mut txn = repo.pristine.mut_txn_begin()?;let channel_name = if let Some(ref c) = channel {c} else {txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL)};
let config_path = repo.config_path();let mut config = repo.config;let (channel_name, _) = config.get_current_channel(self.channel.as_deref());
let channel_name = if let Some(ref c) = self.channel {c} else {txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL)};
let (current_channel, _) = config.get_current_channel(None);if self.channel.as_deref() == Some(current_channel) {
let current_channel = txn.read().unwrap().current_channel().unwrap_or(crate::DEFAULT_CHANNEL).to_string();if self.channel.as_deref() == Some(¤t_channel) {
let (channel_name, _) = repo.config.get_current_channel(self.from_channel.as_deref());
let mut txn = repo.pristine.mut_txn_begin()?;let channel_name = if let Some(ref c) = self.from_channel {c} else {txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL)}.to_string();
let (channel_name, is_current_channel) =repo.config.get_current_channel(self.to_channel.as_deref());let mut channel = txn.open_or_create_channel(channel_name)?;
let cur = txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL);let channel_name = if let Some(ref c) = self.from_channel {c} else {cur}.to_string();let is_current_channel = channel_name == cur;let mut channel = txn.open_or_create_channel(&channel_name)?;
let (channel_name, _) = repo.config.get_current_channel(self.channel.as_deref());if let Some(channel) = txn.load_channel(channel_name)? {
let channel_name = if let Some(ref c) = self.channel {c} else {txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL)}.to_string();if let Some(channel) = txn.load_channel(&channel_name)? {
let channel =txn.open_or_create_channel(repo.config.get_current_channel(self.channel.as_deref()).0)?;
let channel = if let Some(ref c) = self.channel {c} else {txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL)}.to_string();let channel = txn.open_or_create_channel(&channel)?;
config.current_channel = Some(self.channel);if let crate::remote::RemoteRepo::Local(ref l) = remote {config.default_remote = std::fs::canonicalize(&l.root)?.to_str().map(|x| x.to_string());} else {config.default_remote = Some(self.remote);}config.save(&config_path)?;
let mut repo = Repository::find_root(self.repo_path).await?;let current = repo.config.current_channel();
let repo = Repository::find_root(self.repo_path).await?;
let (channel_name, _) = repo.config.get_current_channel(None);let channel = if let Some(channel) = txn.load_channel(channel_name)? {
let channel_name = txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL);let channel = if let Some(channel) = txn.load_channel(&channel_name)? {
let (channel_name, is_current_channel) =repo.config.get_current_channel(self.channel.as_deref());
let cur = txn.current_channel().unwrap_or(crate::DEFAULT_CHANNEL);let channel_name = if let Some(ref c) = self.channel {c} else {cur};let is_current_channel = channel_name == cur;
fn current_channel(&self) -> Result<&str, Self::GraphError> {if let Some(ref c) = self.cur_channel {Ok(c)} else {unsafe {let b = self.txn.root_page();let len = b[4096 - 256] as usize;if len == 0 {Ok("main")} else {let s = std::slice::from_raw_parts(b.as_ptr().add(4096 - 255), len);Ok(std::str::from_utf8(s).unwrap_or("main"))}}}}