Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-webrev: add flags --base and --head #716

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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 {