Skip to content

Commit

Permalink
better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
kilork committed Sep 15, 2019
1 parent 5c9d177 commit 9e48a62
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 51 deletions.
20 changes: 16 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hg-git-fast-import"
version = "1.2.4"
version = "1.2.5"
authors = ["Alexander Korolev <[email protected]>"]
license = "Unlicense OR MIT"
description = """
Expand All @@ -20,10 +20,12 @@ regex = "1"
lazy_static = "1"
toml = "0.5"
structopt = "0.3"
hg-parser = "0.2"
hg-parser = "0.3"
ordered-parallel-iterator = "0.1"
indicatif = "0.12"
dialoguer = "0.4"
failure = "0.1"
exitfailure = "0.5"

[dependencies.serde]
version = "1.0"
Expand All @@ -33,4 +35,5 @@ features = ["derive"]
pretty_assertions = "0.6"

[profile.release]
lto = true
lto = true
incremental = true
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ From source:

```bash
$ hg-git-fast-import --help
hg-git-fast-import 1.2.4
hg-git-fast-import 1.2.5
Alexander Korolev <[email protected]>
A utility to import single and multiple Mercurial repositories to Git.

Expand All @@ -57,7 +57,7 @@ Import of single repository:

```bash
$ hg-git-fast-import single --help
hg-git-fast-import-single 1.2.4
hg-git-fast-import-single 1.2.5
Alexander Korolev <[email protected]>
Exports single Mercurial repository to Git fast-import compatible format

Expand Down Expand Up @@ -94,7 +94,7 @@ Import of multiple repositories:
```bash
$ hg-git-fast-import multi --help
hg-git-fast-import-multi 1.2.4
hg-git-fast-import-multi 1.2.5
Alexander Korolev <[email protected]>
Exports multiple Mercurial repositories to single Git repo in fast-import compatible format

Expand Down Expand Up @@ -125,7 +125,7 @@ Rebuild saved state of repo:
```bash
$ hg-git-fast-import build-marks --help
hg-git-fast-import-build-marks 1.2.4
hg-git-fast-import-build-marks 1.2.5
Alexander Korolev <[email protected]>
Rebuilds saved state of repo

Expand Down
7 changes: 7 additions & 0 deletions build-pgo-generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

rm -rf /tmp/pgo-data

# STEP 1: Build the instrumented binaries
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" \
cargo build --release
10 changes: 10 additions & 0 deletions build-pgo-use.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

PATH=$PATH:~/.rustup/toolchains/`rustup show active-toolchain | cut -f1 -d" "`/lib/rustlib/x86_64-apple-darwin/bin/

# STEP 3: Merge the `.profraw` files into a `.profdata` file
llvm-profdata merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data

# STEP 4: Use the `.profdata` file for guiding optimizations
RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata" \
cargo build --release
10 changes: 9 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#[derive(Debug)]
use failure::Fail;

#[derive(Fail, Debug)]
pub enum ErrorKind {
#[fail(display = "lib parser {}", _0)]
HgParserFailure(hg_parser::ErrorKind),
#[fail(display = "source error {}", _0)]
Source(crate::SourceRepositoryError),
#[fail(display = "target error {}", _0)]
Target(crate::TargetRepositoryError),
#[fail(display = "encoding error {}", _0)]
Encoding(std::str::Utf8Error),
#[fail(display = "io error {}", _0)]
IO(std::io::Error),
#[fail(display = "verify error {}", _0)]
VerifyFailure(String),
}

Expand Down
24 changes: 18 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cargo install --path .
```bash
$ hg-git-fast-import --help
hg-git-fast-import 1.2.4
hg-git-fast-import 1.2.5
Alexander Korolev <[email protected]>
A utility to import single and multiple Mercurial repositories to Git.
Expand All @@ -57,7 +57,7 @@ Import of single repository:
```bash
$ hg-git-fast-import single --help
hg-git-fast-import-single 1.2.4
hg-git-fast-import-single 1.2.5
Alexander Korolev <[email protected]>
Exports single Mercurial repository to Git fast-import compatible format
Expand Down Expand Up @@ -94,7 +94,7 @@ Import of multiple repositories:
```bash
$ hg-git-fast-import multi --help
hg-git-fast-import-multi 1.2.4
hg-git-fast-import-multi 1.2.5
Alexander Korolev <[email protected]>
Exports multiple Mercurial repositories to single Git repo in fast-import compatible format
Expand Down Expand Up @@ -125,7 +125,7 @@ Rebuild saved state of repo:
```bash
$ hg-git-fast-import build-marks --help
hg-git-fast-import-build-marks 1.2.4
hg-git-fast-import-build-marks 1.2.5
Alexander Korolev <[email protected]>
Rebuilds saved state of repo
Expand Down Expand Up @@ -320,6 +320,8 @@ use std::path::Path;
use std::path::PathBuf;
use std::process::ExitStatus;

use failure::Fail;

pub mod config;
pub mod env;
pub mod error;
Expand Down Expand Up @@ -351,16 +353,25 @@ fn to_string(bytes: &[u8]) -> String {
to_str(bytes).into()
}

#[derive(Debug)]
#[derive(Debug, Fail)]
pub enum TargetRepositoryError {
#[fail(display = "unknown")]
Nope,
#[fail(display = "is not a directory")]
IsNotDir,
#[fail(display = "saved state does not exist")]
SavedStateDoesNotExist,
#[fail(display = "cannot init repository {}", _0)]
CannotInitRepo(ExitStatus),
#[fail(display = "cannot configure repository {}", _0)]
CannotConfigRepo(ExitStatus),
#[fail(display = "import failed {}", _0)]
ImportFailed(ExitStatus),
#[fail(display = "git failure {}", _0)]
GitFailure(ExitStatus),
#[fail(display = "io error {}", _0)]
IOError(std::io::Error),
#[fail(display = "verification failed")]
VerifyFail,
}

Expand Down Expand Up @@ -415,8 +426,9 @@ pub trait TargetRepository {
}
}

#[derive(Debug)]
#[derive(Debug, Fail)]
pub enum SourceRepositoryError {
#[fail(display = "pull fail {}", _0)]
PullFail(String),
}

Expand Down
Loading

0 comments on commit 9e48a62

Please sign in to comment.