Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fetch/pull/push results more intuitive #684

Merged
merged 3 commits into from
May 24, 2019

Conversation

zshipko
Copy link
Contributor

@zshipko zshipko commented May 9, 2019

Instead of #683, where the documentation doesn't really help clarify the cases that much, I've updated the API to only use `Msg of string.

@zshipko zshipko requested review from hannesm and samoht and removed request for hannesm May 9, 2019 21:58
@samoht
Copy link
Member

samoht commented May 10, 2019

I agree that we should treat empty repository properly (e.g. not throw an error when it's not needed) but I'm not sure it makes sense to completely remove the error structure. But maybe there's nothing else to do than printing with these errors?

Also your patch seems to change the semantics of the return of few of the operations, do you mind giving a summary of the changes? Did you try to avoid having No_head on both the ok and the error side?

@zshipko
Copy link
Contributor Author

zshipko commented May 10, 2019

Well the `Not_available error seems misleading. It seems like it would indicate that the remote is unreachable, but really signals that the action is not supported, which seems like something you would just print rather than handle. I think the best case there is to use `Msg, with a more specific message about which function is not available.

I guess the significant changes are in pull/push where `No_head is now ignored. I agree that throwing away that information is not ideal, but hadn't thought about using `No_head in the Ok case. I think that sounds like it could be a nice way to preserve the existing semantics of push/pull while cleaning up the API a little.

Just to be clear, this would look something like:

val pull :
    db ->
    ?depth:int ->
    remote ->
    [ `Merge of Info.f | `Set ] -> 
    ([`No_head | `Success], pull_error) result Lwt.t

val push :
    db -> 
    ?depth:int -> 
    remote -> 
    ([`No_head | `Success], [ `Msg of string | `Detached_head]) result Lwt.t

@hannesm
Copy link
Member

hannesm commented May 13, 2019

in fetch and pull, I do understand that this may result in `No_head, but how so in push? or, the other way around, let's assume I pulled an empty repository (--> `No_head), do a commit and push, that should lead to success (and not `No_head), no?

@zshipko
Copy link
Contributor Author

zshipko commented May 13, 2019

You will only get `No_head on push when the local repository (the one you're pushing from) has no commits. So your example is correct, the result will be `Success since the repo is no longer empty.

@samoht
Copy link
Member

samoht commented May 13, 2019

I'm not totally sure about No_head. Maybe something more explicit like:

type status = [ `Empty | `Head of commit ]
... (status, {push,pull}_error) result Lwt.t

What do you think?

Also, I don't remember what's the Detached_head error means :-)

@zshipko
Copy link
Contributor Author

zshipko commented May 13, 2019

Yeah, returning the commit like that seems better, I will update this PR.

The Detached_head error only occurs here:

| `Commit _ -> Lwt.return (Error `Detached_head)

@zshipko
Copy link
Contributor Author

zshipko commented May 14, 2019

Hmm, these test errors on CI just started showing up and I'm not sure why. I don't think it's specific to this branch because they can be seen both here and here

@zshipko
Copy link
Contributor Author

zshipko commented May 22, 2019

Well, the tests are back to passing. I'm hoping the failures were related to this: ocaml/opam-repository#14154 (comment)

@zshipko zshipko merged commit 5503fd1 into mirage:master May 24, 2019
@zshipko zshipko deleted the sync-results branch May 24, 2019 19:42
samoht added a commit to samoht/opam-repository that referenced this pull request Nov 20, 2019
…t, irmin-chunk, irmin-pack, irmin-mirage-graphql, irmin-mirage, irmin-graphql, irmin-http, irmin-git and irmin-test (2.0.0)

CHANGES:

#### Added

- **irmin-pack** (_new_):
  - Created a new Irmin backend, `irmin-pack`, which uses a space-optimised
    on-disk format.

- **irmin-graphql** (_new_):
  - Created a new package, `irmin-graphql`, which provides a GraphQL server
    implementation that can be used with both the MirageOS and Unix backends.
    Additionally, a `graphql` command has been added to the command-line
    interface for starting `irmin-graphql` servers. (mirage/irmin#558, @andreas, @zshipko)

  - Contents can now be queried directly using `irmin-graphql` with
    `Irmin_graphql.Server.Make_ext` and the `Irmin_graphql.Server.PRESENTER`
    interface. (mirage/irmin#643, @andreas)

- **irmin-test** (_new_):
  - Added a new package, `irmin-test`, which allows for packages to access the
    Irmin test-suite. This package can now be used for new packages that
    implement custom backends to test their implementations against the same
    tests that the core backends are tested against. (mirage/irmin#508, @zshipko)

- **irmin-unix**:
  - Add `Cli` module to expose some methods to simplify building command-line
    interfaces using Irmin. (mirage/irmin#517, @zshipko)

  - Add global config file `$HOME/.irmin/config.yml` which may be overridden by
    either `$PWD/.irmin.yml` or by passing `--config <PATH>`. See `irmin help
    irmin.yml` for details. (mirage/irmin#513, @zshipko)

- **irmin-git**:
  - Allow import/export of Git repositories using Irmin slices. (mirage/irmin#561, @samoht)

- **irmin-http**:
  - Expose a `/trees/merge` route for server-side merge operations. (mirage/irmin#714,
    @samoht)

- **irmin**:
  - Add `Json_value` and `Json` content types. (mirage/irmin#516 mirage/irmin#694, @zshipko)

  - Add optional seed parameter to the `Irmin.Type` generic hash functions.
    (mirage/irmin#712, @samoht)

  - Add `V1` submodules in `Commit`, `Contents` and `Hash` to provide
    compatibility with 1.x serialisation formats. (mirage/irmin#644 mirage/irmin#666, @samoht)

  - Add `Store.last_modified` function, which provides a list of commits where
    the given key was modified last. (mirage/irmin#617, @pascutto)

  - Add a `Content_addressable.unsafe_add` function allowing the key of the new
    value to be specified explicitly (for performance reasons). (mirage/irmin#783, @samoht)

  - Add `save_contents` function for saving contents to the database. (mirage/irmin#689,
    @samoht)

  - Add pretty-printers for the results of Sync operations. (mirage/irmin#789, @craigfe)

  - `Private.Lock` now exposes a `stats` function returning the number of held
    locks. (mirage/irmin#704, @samoht)

#### Changed

- **irmin-unix**:
  - Rename `irmin read` to `irmin get` and `irmin write` to `irmin set`. (mirage/irmin#501,
  @zshipko)

  - Switch from custom configuration format to YAML. (mirage/irmin#504, @zshipko)

- **irmin-git**:
  - Require `ocaml-git >= 2.0`. (mirage/irmin#545, @samoht)

  - Cleanup handling of remote stores. (mirage/irmin#552, @samoht)

- **irmin-http**:
  - Rename `CLIENT` to `HTTP_CLIENT` and simplify the signatures necessary to
    construct HTTP clients and servers. (mirage/irmin#701, @samoht)

- **irmin-mirage**
  - Split `irmin-mirage` into `irmin-{mirage,mirage-git,mirage-graphql}` to
    allow for more granular dependency selection. Any instances of
    `Irmin_mirage.Git` should be replaced with `Irmin_mirage_git`. (mirage/irmin#686,
    @zshipko)

- **irmin**:
  - Update to use dune (mirage/irmin#534, @samoht) and opam 2.0. (mirage/irmin#583, @samoht)

  - Replace `Irmin.Contents.S0` with `Irmin.Type.S`.

  - Rename `Type.pre_digest` -> `Type.pre_hash` and `Type.hash` ->
    `Type.short_hash`. (mirage/irmin#720, @samoht)

  - Change `Irmin.Type` to use _incremental_ hash functions (functions of type
    `'a -> (string -> unit) -> unit`) for performance reasons. (mirage/irmin#751, @samoht)

  - Simplify the `Irmin.Type.like` constructor and add a new `Irmin.Type.map`
    with the previous behaviour.

  - Improvements to `Irmin.Type` combinators. (mirage/irmin#550 mirage/irmin#538 mirage/irmin#652 mirage/irmin#653 mirage/irmin#655 mirage/irmin#656
    mirage/irmin#688, @samoht)

  - Modify `Store.set` to return a result type and create a new `Store.set_exn`
    with the previous exception-raising behaviour. (mirage/irmin#572, @samoht)

  - Rename store module types to be more descriptive:
     - replace `Irmin.AO` with `Irmin.CONTENT_ADDRESSABLE_STORE`;
     - replace `Irmin.AO_MAKER` with `Irmin.CONTENT_ADDRESSABLE_STORE_MAKER`;
     - replace `Irmin.RW` with `Irmin.ATOMIC_WRITE_STORE`;
     - replace `Irmin.RW_MAKER` with `Irmin.ATOMIC_WRITE_STORE_MAKER`. (mirage/irmin#601,
       @samoht)

  - Rename `export_tree` to `save_tree` (mirage/irmin#689, @samoht) and add an option to
    conditionally clear the tree cache (mirage/irmin#702 mirage/irmin#725, @samoht).

  - Change hash function for `Irmin_{fs,mem,unix}.KV` to BLAKE2b rather than
    SHA1 for security reasons. (mirage/irmin#811, @craigfe)

  - Move `Irmin.remote_uri` to `Store.remote`, for stores that support remote
    operations. (mirage/irmin#552, @samoht)

  - Simplify the error cases of fetch/pull/push operations. (mirage/irmin#684, @zshipko)

  - A `batch` function has been added to the backend definition to allow for
    better control over how groups of operations are processed. (mirage/irmin#609, @samoht)

  - A `close` function has been added to allow backends to close any held
    resources (e.g. file descriptors for the `FS` backend). (mirage/irmin#845, @samoht)

  - Simplify `Private.Node.Make` parameters to use a simpler notion of 'path' in
    terms of a list of steps. (mirage/irmin#645, @samoht)

  - Rename `Node.update` to `Node.add`. (mirage/irmin#713, @samoht)

#### Fixed

- **irmin-unix**:
   - Fix parsing of commit hashes in `revert` command. (mirage/irmin#496, @zshipko)

- **irmin-git**:
  - Fix `Node.add` to preserve sharing. (mirage/irmin#802, @samoht)

- **irmin-http**:
  - Respond with a 404 if a non-existent resource is requested. (mirage/irmin#706, @samoht)

- **irmin**:
  - Fix a bug whereby `S.History.is_empty` would return `true` for a store with
    exactly one commit. (mirage/irmin#865, @pascutto)

#### Removed

- **irmin**:
  - Remove `pp` and `of_string` functions from `Irmin.Contents.S` in favour of
    `Irmin.Type.to_string` and `Irmin.Type.of_string`.

  - Remove `Bytes` content type. (mirage/irmin#708, @samoht)

  - Remove `Cstruct` dependency and content type. If possible, switch to
    `Irmin.Contents.String` or else use `Irmin.Type.map` to wrap the Cstruct
    type. (mirage/irmin#544, @samoht)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants