Integrated: vcs: add ReadOnlyRepository.commitMetadataFor

Erik Helin ehelin at openjdk.java.net
Tue Mar 16 08:36:48 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

This pull request has now been integrated.

Changeset: 902698ad
Author:    Erik Helin <ehelin at openjdk.org>
URL:       https://git.openjdk.java.net/skara/commit/902698ad
Stats:     71 lines in 5 files changed: 71 ins; 0 del; 0 mod

vcs: add ReadOnlyRepository.commitMetadataFor

Reviewed-by: rwestberg

-------------

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


More information about the skara-dev mailing list