[go: up one dir, main page]

Upgrade ocamlformat

Context

Upgrade ocamlformat to 0.21.0. This is in preparation to upgrade to ocaml.4.14. Specifically, this is the largest but also least significant changeset. It is pulled into its own MR for ease of review.

Manual changes in preparation of the version bump:

  • 021bdb51 update dune, opam, and config files (Note: also add a constraint to dune to avoid upgrading everything at once, can be removed soon after, ping @hhugo1 )
  • 2f44f2e0 update CI and build files
  • 210551f3 deactivate odoc fatal warnings because the newer odoc is more picky on a wider range of comments. See #2971 (closed)
  • ab98370b manually re-indent some comments which would be re-indented automatically by ocamlformat
  • 709ac9b2 add missing line to .ocamlformat-ignore in proto-env-v4

Automatic changes:
The default and supported values for some of the options have changed. This causes multiple changes when autoformating. You will notice:

  • parentheses around tuples are removed (let x, y = … instead of let (x, y) = …),
  • less line-breaking

HOW TO REBASE YOUR MR

This MR 5257 is likely to conflict with most MRs. For this reason, we include a guide to rebasing. We include two actually: the first one should work fine, but in case you have a particularly weird MR you might need to use the other method.

The easy way

  1. Getting your repo ready (you only need to do that once, even if you need to rebase more than one MR)

    1. Switch to the master branch and get the latest version: git switch master, git pull
    2. Update your dev environment: make build-deps (or one of the equivalent alternatives)
    3. Check that ocamlformat is now at version 0.21.0: ocamlformat --version
  2. Getting merge-fmt (you only need to do that once, even if you need to rebase more than one MR)

    1. Install merge-fmt
      • If you use make build-dev-deps, then you have the global opam repo available and you can simply opam install merge-fmt
      • Otherwise, you can install the package in a different switch and copy the binary over or use it with a fully qualified path.
  3. Working on your MR (repeat this for each of your MR that needs rebasing)

    1. Make sure the repo is clean and you have pushed all your commits upstream. You can use the remote branch to restore the state should your rebase be complicated.
    2. Start the rebase: git rebase master
      • When you encounter conflicts, call merge-fmt
      • If merge-fmt cannot resolve all the conflicts, it means you have conflicts which are not related to the formatting. Resolve those like you would in a normal rebasing session.

The hard way (you keep more control, you have more responsibility)

In case you cannot use the method above, here's a more hands-on (more error-prone, more finicky, more complicated) approach:

  • Rebase your branch to the point just before this MR 5257.
  • Make sure master is up to date and you have the recent ocamlformat.0.21.0 (see above)
  • Reformat all your commits:
    git rebase \
        --exec "make fmt-ocaml || true && git add . && git commit --amend --no-edit" \
        --strategy recursive --strategy-option theirs \
        $(git merge-base HEAD master)
  • Rebase all the way to master: git rebase master

This approach may lead to more serious issues which require some good knowledge of git to work your way out of. Beware.

Manually testing the MR

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Hugo Heuzard

Merge request reports

Loading