Add truncated flag for hg

This commit is contained in:
Rene Pfeuffer
2020-02-18 15:35:49 +01:00
parent 3652a33fa0
commit 6eca277d65
3 changed files with 17 additions and 1 deletions

View File

@@ -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();
}
}

View File

@@ -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()

View File

@@ -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 ----------------------------------------------------------