RFR: 1452: Can never notify on first commit [v6]

Erik Joelsson erikj at openjdk.org
Fri Oct 7 13:09:54 UTC 2022

On Fri, 7 Oct 2022 05:54:18 GMT, Guoxiong Li <gli at openjdk.org> wrote:

>> Zhao Song has updated the pull request incrementally with one additional commit since the last revision:
>>   Deleted some comments
> vcs/src/main/java/org/openjdk/skara/vcs/git/GitRepository.java line 51:
>> 49:     private final Logger log = Logger.getLogger("org.openjdk.skara.vcs.git");
>> 50:     private Path cachedRoot = null;
>> 51:     public static final Hash EMPTY_TREE = new Hash("4b825dc642cb6eb9a060e54bf8d69288fbee4904");
> It is better to create a new small method in interface `ReadOnlyRepository` to return the empty tree hash (such as named `emptyTreeHash`) and implement this method in `GitRepository` and `HgRepository`. So the code can be run in mercurial(HG) repository rightly. And then this field can be `private` if the new method is implemented.

That's a good idea. In mercurial this is called the null revision and the hash is all (40) zeros.

> vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java line 1501:
>> 1499:     public int commitCount() throws IOException {
>> 1500:         try (var p = capture("hg", "id", "--num", "--rev", "tip")) {
>> 1501:             return Integer.parseInt(await(p).stdout().get(0)) + 1;
> A question: Is the plus one `+ 1` intentional? I don't know HG well.

Yes, in Mercurial every commit is assigned an ever increasing numerical ID. The "tip" is defined as the commit with the highest ID number. The first commit has ID 0, so to get the total count we add one to the ID number of "tip". (There are situations where this will not be strictly correct, but counting like this is good enough for this purpose)


PR: https://git.openjdk.org/skara/pull/1385

More information about the skara-dev mailing list