RFR: vcs: add ReadOnlyRepository.commitMetadataFor

Erik Helin ehelin at openjdk.java.net
Tue Mar 16 08:15:41 UTC 2021


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

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

Commit messages:
 - vcs: add ReadOnlyRepository.commitMetadataFor

Changes: https://git.openjdk.java.net/skara/pull/1058/files
 Webrev: https://webrevs.openjdk.java.net/?repo=skara&pr=1058&range=00
  Stats: 71 lines in 5 files changed: 71 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/skara/pull/1058.diff
  Fetch: git fetch https://git.openjdk.java.net/skara pull/1058/head:pull/1058

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


More information about the skara-dev mailing list