mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-04 13:49:13 +01:00
Add truncated flag for hg
This commit is contained in:
@@ -60,6 +60,7 @@ import java.util.LinkedList;
|
||||
public class HgFileviewCommand extends AbstractCommand
|
||||
{
|
||||
|
||||
public static final char TRUNCATED_MARK = 't';
|
||||
private boolean disableLastCommit = false;
|
||||
|
||||
private HgFileviewCommand(Repository repository)
|
||||
@@ -186,7 +187,7 @@ public class HgFileviewCommand extends AbstractCommand
|
||||
HgInputStream stream = launchStream();
|
||||
|
||||
FileObject last = null;
|
||||
while (stream.peek() != -1) {
|
||||
while (stream.peek() != -1 && stream.peek() != TRUNCATED_MARK) {
|
||||
FileObject file = read(stream);
|
||||
|
||||
while (!stack.isEmpty()) {
|
||||
@@ -210,6 +211,9 @@ public class HgFileviewCommand extends AbstractCommand
|
||||
return last;
|
||||
} else {
|
||||
// if the stack is not empty, the requested path is a directory
|
||||
if (stream.read() == TRUNCATED_MARK) {
|
||||
stack.getLast().setTruncated(true);
|
||||
}
|
||||
return stack.getLast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,6 +249,15 @@ class File_Printer:
|
||||
self.result_count += 1
|
||||
return self.result_count == 0 or self.proceedFrom < self.result_count <= self.limit + self.proceedFrom
|
||||
|
||||
def isTruncated(self):
|
||||
return self.result_count > self.limit + self.proceedFrom
|
||||
|
||||
def finish(self):
|
||||
if self.isTruncated():
|
||||
if self.transport:
|
||||
self.ui.write( "t")
|
||||
else:
|
||||
self.ui.write("truncated")
|
||||
|
||||
class File_Viewer:
|
||||
def __init__(self, revCtx, visitor):
|
||||
@@ -297,3 +306,4 @@ def fileview(ui, repo, **opts):
|
||||
viewer.recursive = opts["recursive"]
|
||||
viewer.sub_repositories = subrepos
|
||||
viewer.view(opts["path"])
|
||||
printer.finish()
|
||||
|
||||
@@ -191,6 +191,7 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase {
|
||||
Collection<FileObject> foList = root.getChildren();
|
||||
|
||||
assertThat(foList).extracting("name").containsExactlyInAnyOrder("a.txt", "b.txt");
|
||||
assertThat(root.isTruncated()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -205,6 +206,7 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase {
|
||||
Collection<FileObject> foList = root.getChildren();
|
||||
|
||||
assertThat(foList).extracting("name").containsExactlyInAnyOrder("c", "f.txt");
|
||||
assertThat(root.isTruncated()).isFalse();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user