diff --git a/cli/src/main/java/org/openjdk/skara/cli/GitWebrev.java b/cli/src/main/java/org/openjdk/skara/cli/GitWebrev.java index 04647a101..b40d61f15 100644 --- a/cli/src/main/java/org/openjdk/skara/cli/GitWebrev.java +++ b/cli/src/main/java/org/openjdk/skara/cli/GitWebrev.java @@ -95,7 +95,7 @@ private static void generate(String[] args) throws IOException { Option.shortcut("r") .fullname("rev") .describe("REV") - .helptext("Compare against a specified revision") + .helptext("Compare against a specified base revision (alias for --base)") .optional(), Option.shortcut("o") .fullname("output") @@ -127,6 +127,16 @@ private static void generate(String[] args) throws IOException { .describe("NAME") .helptext("Use remote to calculate outgoing changes") .optional(), + Option.shortcut("") + .fullname("base") + .describe("REV") + .helptext("Use specified revision as base for comparison") + .optional(), + Option.shortcut("") + .fullname("head") + .describe("REV") + .helptext("Use specified revision as head for comparison") + .optional(), Option.shortcut("s") .fullname("similarity") .describe("SIMILARITY") @@ -229,8 +239,21 @@ private static void generate(String[] args) throws IOException { } } + if (arguments.contains("base") && arguments.contains("rev")) { + System.err.println("error: cannot combine --base and --rev options"); + System.exit(1); + } + if (arguments.contains("head") && arguments.contains("rev")) { + System.err.println("error: cannot combine --head and --rev options"); + System.exit(1); + } + if (arguments.contains("head") && !arguments.contains("base")) { + System.err.println("error: cannot use --head without using --base"); + System.exit(1); + } + var rev = arguments.contains("rev") ? resolve(repo, arguments.get("rev").asString()) : null; - if (rev == null) { + if (rev == null && !(arguments.contains("base") && arguments.contains("head"))) { if (isMercurial) { resolve(repo, noOutgoing ? "tip" : "min(outgoing())^"); } else { @@ -284,6 +307,9 @@ private static void generate(String[] args) throws IOException { } } + var base = arguments.contains("base") ? resolve(repo, arguments.get("base").asString()) : rev; + var head = arguments.contains("head") ? resolve(repo, arguments.get("head").asString()) : null; + var issue = arguments.contains("cr") ? arguments.get("cr").asString() : null; if (issue != null) { if (issue.startsWith("http")) { @@ -388,7 +414,7 @@ private static void generate(String[] args) throws IOException { .version(version) .files(files) .similarity(similarity) - .generate(rev); + .generate(base, head); } private static void apply(String[] args) throws Exception {