RFR: vcs: add ReadOnlyRepository.commitMetadataFor

Robin Westberg rwestberg at openjdk.java.net
Tue Mar 16 08:25:21 UTC 2021

On Tue, 16 Mar 2021 08:12:19 GMT, Erik Helin <ehelin at openjdk.org> wrote:

> Hi all,
> please review this patch that adds the method `ReadOnlyRepository.commitMetadataFor`. I opted to *not* implement the Mercurial version due to the way `HgRepository` tries to mimic Git branches using bookmarks. The Skara code that uses `HgRepository` has never needed to use branches, so the the current bookmark implementation is more of a proof-of-concept. The implementation of the `ReadOnlyRepository.commitMetadataFor` for `HgRepository` would look something like the following:
> @Override
> public List<CommitMetadata> commitMetadataFor(List<Branch> branches) throws IOException {
>     var cmd = new ArrayList<String>();
>     cmd.addAll(List.of("hg", "log", "--template", HgCommitMetadata.TEMPLATE));
>     for (var branch : branches) {
>         cmd.add("--rev");
>         cmd.add("0:" + branch.name());
>     }
>     return readMetadata(cmd);
> }
> The above will get messy however if `branches` contains a proper branch (e.g. `default`) and not just a bookmark. This can be solved, but I don't think it is worth it right now. If we ever need to write a tool interacting with Mercurial repositories that needs `commitMetadataFor` then we can implement the method then.
> Please also note that I had to name the method `commitMetadataFor` instead of just overloading `commitMetadata` since we already have `commitMetadata(List<Path>)`.
> Thanks,
> Erik

Sounds reasonable!


Marked as reviewed by rwestberg (Reviewer).

PR: https://git.openjdk.java.net/skara/pull/1058

More information about the skara-dev mailing list