@@ -145,6 +145,15 @@ String determineBranch(CommandTimeoutType cmdType) throws IOException {
145
145
return executor .getOutputString ().trim ();
146
146
}
147
147
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
+
148
157
/**
149
158
* Get an executor to be used for retrieving the history log for the named
150
159
* file or directory.
@@ -168,17 +177,27 @@ Executor getHistoryLogExecutor(File file, String sinceRevision, String tillRevis
168
177
cmd .add ("log" );
169
178
170
179
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 ));
179
192
} 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 (")" );
181
199
}
200
+ cmd .add (stringBuilder .toString ());
182
201
} else {
183
202
cmd .add ("-r" );
184
203
cmd .add ("reverse(0::'" + getBranch () + "')" );
0 commit comments