Webrev on a mercurial repo fails with:
% git webrev -N -r -2 -C -m
error: could not resolve reference '-2'
It also fails with an explicit hash of a rev known to be present, both the full hash and the short hash.
The problem maybe an incorrect expectation that --rev=x returns exactly 1 revision.
The patch below to set a --limit=1 seems to work.
git diff
diff --git a/vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java b/vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java
index 51f40a2b..552d3de9 100644
--- a/vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java
+++ b/vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java
@@ -195,7 +195,7 @@ public class HgRepository implements Repository {
@Override
public Optional<Hash> resolve(String ref) throws IOException {
- try (var p = capture("hg", "log", "--rev=" + ref, "--template={node}\n")) {
+ try (var p = capture("hg", "log", "--rev=" + ref, "--limit=1", "--template={node}\n")) {
var res = p.await();
if (res.status() == 0 && res.stdout().size() == 1) {
return Optional.of(new Hash(res.stdout().get(0)));
% git webrev -N -r -2 -C -m
error: could not resolve reference '-2'
It also fails with an explicit hash of a rev known to be present, both the full hash and the short hash.
The problem maybe an incorrect expectation that --rev=x returns exactly 1 revision.
The patch below to set a --limit=1 seems to work.
git diff
diff --git a/vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java b/vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java
index 51f40a2b..552d3de9 100644
--- a/vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java
+++ b/vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java
@@ -195,7 +195,7 @@ public class HgRepository implements Repository {
@Override
public Optional<Hash> resolve(String ref) throws IOException {
- try (var p = capture("hg", "log", "--rev=" + ref, "--template={node}\n")) {
+ try (var p = capture("hg", "log", "--rev=" + ref, "--limit=1", "--template={node}\n")) {
var res = p.await();
if (res.status() == 0 && res.stdout().size() == 1) {
return Optional.of(new Hash(res.stdout().get(0)));