mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-06 12:20:56 +01:00
Fix not found error when reading empty hg repository
This commit is contained in:
@@ -87,8 +87,8 @@ class HgFileviewCommandResultReader {
|
||||
if (stack.isEmpty()) {
|
||||
// if the stack is empty, the requested path is probably a file
|
||||
return of(last);
|
||||
} else if (stack.size() == 1 && stack.getFirst().isDirectory() && stack.getFirst().getChildren().isEmpty()) {
|
||||
// There are no empty directories in hg. When we get this,
|
||||
} else if (isEmptySubDirectory(stack)) {
|
||||
// There are no empty directories in hg (except the root). When we get this,
|
||||
// we just get the requested path as a directory, but it does not exist.
|
||||
return empty();
|
||||
} else {
|
||||
@@ -100,6 +100,16 @@ class HgFileviewCommandResultReader {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmptySubDirectory(Deque<FileObject> stack) {
|
||||
if (stack.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
final FileObject singleEntry = stack.getFirst();
|
||||
return singleEntry.isDirectory()
|
||||
&& singleEntry.getChildren().isEmpty()
|
||||
&& !singleEntry.getName().isEmpty();
|
||||
}
|
||||
|
||||
private FileObject read(HgInputStream stream) throws IOException {
|
||||
char type = (char) stream.read();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user