channel switch as an alias to reset

[?]
Nov 21, 2020, 7:03 PM
VQPAUKBQ2POZKL7CZFAZK5ZQKEBYL27XZYZWYUSH5AH25KK6DWKAC

Dependencies

  • [2] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [3] NLGQAH4H Credit and reset relative to current directory instead of the root
  • [4] M3VTIZCP Validate change before reset
  • [5] L4JXJHWX pijul/*: reorganize imports and remove extern crate

Change contents

  • edit in pijul/src/main.rs at line 150
    [2.87776]
    [2.87776]
    #[error("Cannot delete the current channel")]
    CannotDeleteCurrentChannel,
  • edit in pijul/src/config.rs at line 62
    [2.91609]
    [2.91609]
    }
    }
    pub fn current_channel<'a>(&'a self) -> Option<&'a str> {
    if let Some(ref channel) = self.current_channel {
    Some(channel.as_str())
    } else {
    None
  • replacement in pijul/src/commands/reset.rs at line 13
    [2.97874][2.97874:97906]()
    repo_path: Option<PathBuf>,
    [2.97874]
    [2.97906]
    pub repo_path: Option<PathBuf>,
  • replacement in pijul/src/commands/reset.rs at line 15
    [2.97936][2.97936:97965]()
    channel: Option<String>,
    [2.97936]
    [2.97965]
    pub channel: Option<String>,
  • replacement in pijul/src/commands/reset.rs at line 17
    [2.97995][2.97995:98014]()
    dry_run: bool,
    [2.97995]
    [2.98014]
    pub dry_run: bool,
  • replacement in pijul/src/commands/reset.rs at line 19
    [2.98043][2.98043:98096]()
    change: Option<String>,
    files: Vec<PathBuf>,
    [2.98043]
    [2.98096]
    pub change: Option<String>,
    pub files: Vec<PathBuf>,
  • edit in pijul/src/commands/reset.rs at line 25
    [2.98164]
    [2.98164]
    self.reset(true)
    }
    pub fn switch(self) -> Result<(), anyhow::Error> {
    self.reset(false)
    }
    fn reset(self, overwrite_changes: bool) -> Result<(), anyhow::Error> {
  • replacement in pijul/src/commands/reset.rs at line 72
    [2.99700][2.99700:99838]()
    if self.channel.is_some()
    && self.channel.as_ref().map(|x| x.as_str()) != Some(current_channel)
    {
    [2.99700]
    [2.99838]
    if self.channel.as_ref().map(|x| x.as_str()) == Some(current_channel) {
    if !overwrite_changes {
    // No need to change channel, no need to reset.
    return Ok(())
    }
    } else if self.channel.is_some() {
  • edit in pijul/src/commands/channel.rs at line 22
    [2.187365]
    [2.187365]
    #[clap(name = "switch")]
    Switch { to: Option<String> },
  • edit in pijul/src/commands/channel.rs at line 28
    [2.187435][2.187435:187494]()
    let repo = Repository::find_root(self.repo_path)?;
  • edit in pijul/src/commands/channel.rs at line 29
    [2.187538][2.187538:187685]()
    let current = if let Some(ref c) = repo.config.current_channel {
    Some(c.as_str())
    } else {
    None
    };
  • edit in pijul/src/commands/channel.rs at line 31
    [2.187735]
    [2.187735]
    let repo = Repository::find_root(self.repo_path)?;
    let current = repo.config.current_channel();
  • edit in pijul/src/commands/channel.rs at line 45
    [2.188244]
    [2.188244]
    let repo = Repository::find_root(self.repo_path)?;
    let current = repo.config.current_channel();
    if Some(delete.as_str()) == current {
    return Err(crate::Error::CannotDeleteCurrentChannel.into())
    }
  • edit in pijul/src/commands/channel.rs at line 54
    [2.188393]
    [2.188393]
    Some(SubCommand::Switch { to }) => {
    (crate::commands::reset::Reset {
    repo_path: self.repo_path,
    channel: to,
    dry_run: false,
    change: None,
    files: Vec::new(),
    }).switch()?;
    }
  • edit in pijul/src/commands/channel.rs at line 64
    [2.188456]
    [2.188456]
    let repo = Repository::find_root(self.repo_path)?;
    let current = repo.config.current_channel();