Refactor push/pull commands' handling of repo and channel

dblsaiko
Mar 30, 2024, 8:42 PM
OSWFAKWMXL7N3ZHL74TKXEUDGSBDUHBNFAPI25LUB6RBTQKFC6EQC

Dependencies

  • [2] Y2Y4OOIE Move `pijul::DEFAULT_CHANNEL` to `libpijul`
  • [3] G7HJHNFD Migrate from `pijul_interaction::progress` to `pijul_interaction`
  • [4] QQS7LII4 Add value hints to arguments
  • [5] GKSVBEUW Refactor Repository constructors to take Option<&Path> instead of Option<PathBuf>
  • [6] AEPEFS7O Write help for each argument
  • [7] MU5GSJAW Partial push and pull (WARNING: breaks the existing protocol)
  • [8] KWAMD2KR A few fixes in the documentation comments
  • [9] 367UBQ6K Forwarding SSH stderr, and progress bar for push
  • [10] 5OGOE4VW Store the current channel in the pristine
  • [11] JL4WKA5P Implement the Sanakirja concurrency model in a cross-process way
  • [12] 3KRGVQFU Do not update the mtime of unmodified files
  • [13] IVLLXQ5Z Improved push/pull reporting
  • [14] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [15] I24UEJQL Various post-fire fixes
  • [16] PIQCNEEB Upgrading to Clap 3.0.0-alpha.5
  • [17] A3RM526Y Integrating identity malleability
  • [18] RUBBHYZ7 Removing unnecessary async/await
  • [19] 5HF7C67M push/pull: fixed "changes" arguments
  • [20] HQ2C4VT5 Pull: confusion between from and to channels
  • [21] VMPAOJS2 Don't output after pushing to a local channel
  • [22] ABQDWHNG Migrate from `pijul::repository` to `pijul-repository`
  • [23] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [24] YN63NUZO Sanakirja 1.0
  • [25] ZBNKSYA6 Fixing a bus error when starting a transaction on a full disk
  • [26] SLJ3OHD4 unrecord: show list of changes if none were given as arguments
  • [27] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [28] 6ZPDI7QG pull uses None as the base case path when outputing repo
  • [29] LGEJSLTY Fixing output (including its uses in reset and pull)
  • [30] QWD7UE76 push/pull: rename `channel` option
  • [31] 4H2XTVJ2 Fix some mistakes in the docs

Change contents

  • edit in pijul/src/commands/pushpull.rs at line 3
    [6.1671][6.1671:1695]()
    use std::path::PathBuf;
  • replacement in pijul/src/commands/pushpull.rs at line 4
    [6.1696][6.2921:2969]()
    use super::{make_changelist, parse_changelist};
    [6.1696]
    [6.6849]
    use super::{get_channel, make_changelist, parse_changelist};
  • edit in pijul/src/commands/pushpull.rs at line 14
    [6.1761]
    [3.453]
    use crate::commands::common_opts::RepoPath;
  • edit in pijul/src/commands/pushpull.rs at line 21
    [6.111922]
    [6.111922]
    #[clap(flatten)]
    base: RepoPath,
  • edit in pijul/src/commands/pushpull.rs at line 25
    [6.111977][6.815:965](),[6.965][4.759:825](),[4.825][6.112010:112042](),[6.112010][6.112010:112042]()
    /// Set the repository where this command should run. Defaults to the first ancestor of the current directory that contains a `.pijul` directory.
    #[clap(long = "repository", value_hint = ValueHint::DirPath)]
    repo_path: Option<PathBuf>,
  • replacement in pijul/src/commands/pushpull.rs at line 39
    [6.1475][5.1640:1710]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [6.1475]
    [6.112314]
    let repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/pushpull.rs at line 76
    [6.113077][6.1106:1193](),[6.1193][4.826:892](),[4.892][6.113110:113142](),[6.113110][6.113110:113142]()
    /// Path to the repository. Uses the current repository if the argument is omitted
    #[clap(long = "repository", value_hint = ValueHint::DirPath)]
    repo_path: Option<PathBuf>,
    [6.113077]
    [6.1615]
    #[clap(flatten)]
    base: RepoPath,
  • replacement in pijul/src/commands/pushpull.rs at line 106
    [6.113567][6.966:1116](),[6.1116][4.954:1020](),[4.1020][6.113600:113632](),[6.113600][6.113600:113632]()
    /// Set the repository where this command should run. Defaults to the first ancestor of the current directory that contains a `.pijul` directory.
    #[clap(long = "repository", value_hint = ValueHint::DirPath)]
    repo_path: Option<PathBuf>,
    [6.113567]
    [6.2104]
    #[clap(flatten)]
    base: RepoPath,
  • replacement in pijul/src/commands/pushpull.rs at line 179
    [6.1981][5.1711:1781]()
    let repo = Repository::find_root(self.repo_path.as_deref())?;
    [6.1981]
    [6.114570]
    let repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/pushpull.rs at line 182
    [6.6681][6.6681:6754](),[6.6754][2.481:531]()
    let cur = txn
    .read()
    .current_channel()
    .unwrap_or(libpijul::DEFAULT_CHANNEL)
    [6.6681]
    [6.6801]
    let channel_name = get_channel(self.from_channel.as_deref(), &*txn.read())
    .0
  • edit in pijul/src/commands/pushpull.rs at line 185
    [6.6827][6.1772:1871](),[6.1772][6.1772:1871](),[6.1871][6.6828:6864]()
    let channel_name = if let Some(ref c) = self.from_channel {
    c
    } else {
    cur.as_str()
    };
  • replacement in pijul/src/commands/pushpull.rs at line 192
    [6.114936][6.114936:115226](),[6.115226][6.6865:6894](),[6.2010][6.115255:115325](),[6.6894][6.115255:115325](),[6.115255][6.115255:115325](),[6.115325][6.6895:6920](),[6.2045][6.115350:115361](),[6.6920][6.115350:115361](),[6.115350][6.115350:115361]()
    let mut push_channel = None;
    let remote_channel = if let Some(ref c) = self.to_channel {
    let c = CHANNEL.captures(c).unwrap();
    push_channel = c.get(3).map(|x| x.as_str());
    let c = c.get(1).unwrap().as_str();
    if c.is_empty() {
    channel_name
    } else {
    c
    }
    } else {
    channel_name
    };
    [6.114936]
    [6.115361]
    let (remote_channel, push_channel) = self
    .to_channel
    .as_deref()
    .map(|c| {
    let c = CHANNEL.captures(c).unwrap();
    let push_channel = c.get(3).map(|x| x.as_str());
    let remote_channel = Some(c.get(1).unwrap().as_str()).filter(|v| !v.is_empty());
    (remote_channel, push_channel)
    })
    .unwrap_or_default();
    let remote_channel = remote_channel.unwrap_or(&channel_name);
  • replacement in pijul/src/commands/pushpull.rs at line 364
    [6.117585][5.1782:1856]()
    let mut repo = Repository::find_root(self.repo_path.as_deref())?;
    [6.117585]
    [6.9020]
    let mut repo = Repository::find_root(self.base.repo_path())?;
  • replacement in pijul/src/commands/pushpull.rs at line 366
    [6.9070][6.9070:9143](),[6.9143][2.532:582](),[2.582][6.9190:9216](),[6.9190][6.9190:9216](),[6.9216][6.0:66](),[6.2188][6.0:66](),[6.66][6.2256:2287](),[6.2256][6.2256:2287](),[6.2287][6.9217:9253](),[6.9253][6.2335:2389](),[6.2335][6.2335:2389]()
    let cur = txn
    .read()
    .current_channel()
    .unwrap_or(libpijul::DEFAULT_CHANNEL)
    .to_string();
    let channel_name = if let Some(ref c) = self.to_channel {
    c
    } else {
    cur.as_str()
    };
    let is_current_channel = channel_name == cur;
    [6.9070]
    [6.9254]
    let txn_read = txn.read();
    let (channel_name, is_current_channel) =
    get_channel(self.to_channel.as_deref(), &*txn_read);
    let channel_name = channel_name.to_string();
    drop(txn_read);
  • replacement in pijul/src/commands/pushpull.rs at line 382
    [6.118138][6.118138:118237](),[6.118237][2.583:621](),[2.621][6.118272:118283](),[6.118272][6.118272:118283]()
    let from_channel = if let Some(ref c) = self.from_channel {
    c
    } else {
    libpijul::DEFAULT_CHANNEL
    };
    [6.118138]
    [6.1400]
    let from_channel = self
    .from_channel
    .as_deref()
    .unwrap_or(libpijul::DEFAULT_CHANNEL);