Skip to content

Commit c18ef63

Browse files
Vladimir Kotalahornace
authored andcommitted
add tillRevision constraint
1 parent 703d577 commit c18ef63

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/MercurialRepository.java

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ String determineBranch(CommandTimeoutType cmdType) throws IOException {
145145
return executor.getOutputString().trim();
146146
}
147147

148+
private String getRevisionNum(String changeset) throws HistoryException {
149+
String[] parts = changeset.split(":");
150+
if (parts.length == 2) {
151+
return parts[0];
152+
} else {
153+
throw new HistoryException("Don't know how to parse changeset identifier: " + changeset);
154+
}
155+
}
156+
148157
/**
149158
* Get an executor to be used for retrieving the history log for the named
150159
* file or directory.
@@ -168,17 +177,27 @@ Executor getHistoryLogExecutor(File file, String sinceRevision, String tillRevis
168177
cmd.add("log");
169178

170179
if (file.isDirectory()) {
171-
// If this is non-default branch we would like to get the changesets
172-
// on that branch and also follow any changesets from the parent branch.
173-
// TODO tillRevision
174-
if (sinceRevision != null) {
175-
cmd.add("-r");
176-
String[] parts = sinceRevision.split(":");
177-
if (parts.length == 2) {
178-
cmd.add("reverse(" + parts[0] + "::'" + getBranch() + "')");
180+
if ((sinceRevision != null) || (tillRevision != null)) {
181+
StringBuilder stringBuilder = new StringBuilder();
182+
stringBuilder.append("-r");
183+
if (!revisionsOnly) {
184+
stringBuilder.append("reverse(");
185+
}
186+
if (sinceRevision != null) {
187+
stringBuilder.append(getRevisionNum(sinceRevision));
188+
}
189+
stringBuilder.append("::");
190+
if (tillRevision != null) {
191+
stringBuilder.append(getRevisionNum(tillRevision));
179192
} else {
180-
throw new HistoryException("Don't know how to parse changeset identifier: " + sinceRevision);
193+
// If this is non-default branch we would like to get the changesets
194+
// on that branch and also follow any changesets from the parent branch.
195+
stringBuilder.append("'" + getBranch() + "'");
196+
}
197+
if (!revisionsOnly) {
198+
stringBuilder.append(")");
181199
}
200+
cmd.add(stringBuilder.toString());
182201
} else {
183202
cmd.add("-r");
184203
cmd.add("reverse(0::'" + getBranch() + "')");

0 commit comments

Comments
 (0)