Add progress-interval flag

andybalholm
Apr 18, 2023, 10:34 PM
EBE4NGXWTXMGB6B7M4AWJRMVQE2QYR2GODPPRWE67RKQLFAW7KBAC

Dependencies

Change contents

  • replacement in src/main.rs at line 1
    [4.67][4.0:14]()
    use std::env;
    [4.67]
    [4.35]
    use clap::Parser;
  • edit in src/main.rs at line 3
    [4.36][4.36:58](),[4.183][4.1471:1472](),[4.58][4.1471:1472]()
    use getopts::Options;
  • edit in src/main.rs at line 11
    [4.53]
    [4.68]
    #[derive(Parser)]
    struct Cli {
    #[arg(long, default_value = ".", help = "repository path")]
    repo: String,
    #[arg(long, default_value = "main", help = "channel to export")]
    channel: String,
    #[arg(long, help = "branch name in git")]
    branch: Option<String>,
    #[arg(long, help = "file to import and export marks")]
    marks: Option<String>,
    #[arg(
    long = "progress-interval",
    help = "report progress every N commits",
    value_name = "N"
    )]
    progress_interval: Option<i32>,
    }
  • replacement in src/main.rs at line 34
    [4.80][4.148:291](),[4.291][4.1540:1602](),[4.1602][4.54:116](),[4.116][4.0:119](),[4.116][4.291:342](),[4.119][4.291:342](),[4.1602][4.291:342](),[4.291][4.291:342](),[4.342][4.1505:1574](),[4.1574][4.1603:1673]()
    let args: Vec<String> = env::args().collect();
    let mut opts = Options::new();
    opts.optopt("r", "repo", "repository path", "PATH");
    opts.optopt("c", "channel", "channel to export", "NAME");
    opts.optopt("b", "branch", "branch name in git", "NAME");
    opts.optopt(
    "m",
    "marks",
    "file to import and export marks",
    "MARKS-FILE",
    );
    let matches = opts.parse(&args[1..]).unwrap();
    let repo_path = matches.opt_str("r").unwrap_or(".".to_string());
    let channel = matches.opt_str("c").unwrap_or("main".to_string());
    [4.80]
    [4.506]
    let cli = Cli::parse();
  • replacement in src/main.rs at line 36
    [4.507][4.1575:1633](),[4.1633][4.0:97]()
    let mut repo = Repository::load(&repo_path).unwrap();
    let mut stream = FastExportStream::new(matches.opt_str("b").unwrap_or(channel.to_string()));
    [4.507]
    [4.120]
    let mut repo = Repository::load(&cli.repo).unwrap();
    let mut stream = FastExportStream::new(cli.branch.unwrap_or(cli.channel.to_string()));
  • replacement in src/main.rs at line 39
    [4.121][4.121:219]()
    match matches.opt_str("m") {
    Some(filename) => stream.load_marks(&filename).unwrap(),
    [4.121]
    [4.219]
    match cli.marks {
    Some(ref filename) => stream.load_marks(filename).unwrap(),
  • replacement in src/main.rs at line 44
    [4.239][4.1674:1721](),[4.1633][4.1674:1721]()
    let changes = repo.log(&channel).unwrap();
    [4.239]
    [4.5643]
    let changes = repo.log(&cli.channel).unwrap();
  • edit in src/main.rs at line 46
    [4.5694]
    [4.5694]
    let mut count = 0;
  • edit in src/main.rs at line 58
    [4.556]
    [4.556]
    }
    count += 1;
    if let Some(p) = cli.progress_interval {
    if count % p == 0 {
    println!(
    "progress Exported {} changes; current change is {:?}",
    count, changes[i].hash
    );
    }
  • replacement in src/main.rs at line 70
    [4.573][4.573:671]()
    match matches.opt_str("m") {
    Some(filename) => stream.save_marks(&filename).unwrap(),
    [4.573]
    [4.671]
    match cli.marks {
    Some(ref filename) => stream.save_marks(filename).unwrap(),
  • edit in Cargo.toml at line 11
    [4.1872][4.946:962](),[4.331][4.946:962]()
    getopts = "0.2"
  • edit in Cargo.toml at line 20
    [2.6846]
    clap = { version = "4.2.3", features = ["derive"] }
  • edit in Cargo.lock at line 40
    [4.949]
    [4.949]
    ]
    [[package]]
    name = "anstream"
    version = "0.3.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371"
    dependencies = [
    "anstyle",
    "anstyle-parse",
    "anstyle-query",
    "anstyle-wincon",
    "colorchoice",
    "is-terminal",
    "utf8parse",
  • edit in Cargo.lock at line 58
    [4.964]
    [4.964]
    name = "anstyle"
    version = "1.0.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d"
    [[package]]
    name = "anstyle-parse"
    version = "0.2.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee"
    dependencies = [
    "utf8parse",
    ]
    [[package]]
    name = "anstyle-query"
    version = "1.0.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
    dependencies = [
    "windows-sys 0.48.0",
    ]
    [[package]]
    name = "anstyle-wincon"
    version = "1.0.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd"
    dependencies = [
    "anstyle",
    "windows-sys 0.48.0",
    ]
    [[package]]
  • edit in Cargo.lock at line 231
    [4.4793]
    [4.4793]
    ]
    [[package]]
    name = "clap"
    version = "4.2.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "49f9152d70e42172fdb87de2efd7327160beee37886027cf86f30a233d5b30b4"
    dependencies = [
    "clap_builder",
    "clap_derive",
    "once_cell",
    ]
    [[package]]
    name = "clap_builder"
    version = "4.2.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "e067b220911598876eb55d52725ddcc201ffe3f0904018195973bc5b012ea2ca"
    dependencies = [
    "anstream",
    "anstyle",
    "bitflags",
    "clap_lex",
    "strsim",
    ]
    [[package]]
    name = "clap_derive"
    version = "4.2.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4"
    dependencies = [
    "heck",
    "proc-macro2",
    "quote",
    "syn 2.0.15",
  • edit in Cargo.lock at line 270
    [4.4808]
    [4.4808]
    name = "clap_lex"
    version = "0.4.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1"
    [[package]]
  • edit in Cargo.lock at line 286
    [4.5062]
    [4.5062]
    name = "colorchoice"
    version = "1.0.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
    [[package]]
  • edit in Cargo.lock at line 564
    [4.978][4.978:1192](),[4.1192][4.11736:11751](),[4.11736][4.11736:11751]()
    name = "getopts"
    version = "0.2.21"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
    dependencies = [
    "unicode-width",
    ]
    [[package]]
  • edit in Cargo.lock at line 599
    [4.12556]
    [4.12556]
    name = "heck"
    version = "0.4.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
    [[package]]
  • edit in Cargo.lock at line 693
    [4.14356]
    [3.1567]
    "windows-sys 0.48.0",
    ]
    [[package]]
    name = "is-terminal"
    version = "0.4.7"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f"
    dependencies = [
    "hermit-abi 0.3.1",
    "io-lifetimes",
    "rustix",
  • replacement in Cargo.lock at line 963
    [4.1884][4.1193:1205](),[4.20468][4.1193:1205]()
    "getopts",
    [4.1884]
    [4.20468]
    "clap",
  • edit in Cargo.lock at line 1282
    [4.27699]
    [4.27699]
    name = "strsim"
    version = "0.10.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
    [[package]]
  • edit in Cargo.lock at line 1436
    [4.31477]
    [4.31477]
    [[package]]
    name = "utf8parse"
    version = "0.2.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"