diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/spi/javahg/HgLogChangesetCommand.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/spi/javahg/HgLogChangesetCommand.java index 65da251402..d1f4691ebd 100644 --- a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/spi/javahg/HgLogChangesetCommand.java +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/spi/javahg/HgLogChangesetCommand.java @@ -71,6 +71,11 @@ public class HgLogChangesetCommand extends AbstractCommand */ private static final byte[] CHANGESET_PATTERN = Utils.randomBytes(); + /** Field description */ + private static final String CHANGESET_LAZY_STYLE_PATH = + Utils.resourceAsFile("/sonia/scm/styles/changesets-lazy.style", + ImmutableMap.of("pattern", CHANGESET_PATTERN)).getPath(); + /** Field description */ private static final String CHANGESET_EAGER_STYLE_PATH = Utils.resourceAsFile("/sonia/scm/styles/changesets-eager.style", @@ -141,6 +146,23 @@ public class HgLogChangesetCommand extends AbstractCommand return this; } + /** + * Method description + * + * + * @param files + * + * @return + */ + public List loadRevisions(String... files) + { + cmdAppend("--style", CHANGESET_LAZY_STYLE_PATH); + + HgInputStream stream = launchStream(files); + + return loadRevisionsFromStream(stream); + } + /** * Method description * @@ -203,9 +225,6 @@ public class HgLogChangesetCommand extends AbstractCommand changeset.setId(nodeString); - // revision - in.revisionUpTo('\n'); - String user = in.textUpTo('\n'); changeset.setAuthor(Person.toPerson(user)); @@ -275,6 +294,39 @@ public class HgLogChangesetCommand extends AbstractCommand return changeset; } + /** + * Method description + * + * + * @param stream + * + * @return + */ + private List loadRevisionsFromStream(HgInputStream stream) + { + List revisions = Lists.newArrayList(); + + try + { + while (stream.peek() != -1) + { + int rev = stream.revisionUpTo(' '); + + if (rev >= 0) + { + revisions.add(rev); + } + } + + } + catch (IOException ex) + { + throw new RuntimeIOException(ex); + } + + return revisions; + } + /** * Method description * diff --git a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/styles/changesets-eager.style b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/styles/changesets-eager.style index 01f6df9821..b87d9ee379 100644 --- a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/styles/changesets-eager.style +++ b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/styles/changesets-eager.style @@ -1,5 +1,5 @@ header = "%{pattern}" -changeset = "{node}{rev}\n{author}\n{date|hgdate}\n{branch}\n{parents}{tags}{file_adds}{file_mods}{file_dels}\n{desc}\0" +changeset = "{node}{author}\n{date|hgdate}\n{branch}\n{parents}{tags}{file_adds}{file_mods}{file_dels}\n{desc}\0" tag = "t {tag}\n" file_add = "a {file_add}\n" file_mod = "m {file_mod}\n" diff --git a/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/styles/changesets-lazy.style b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/styles/changesets-lazy.style new file mode 100644 index 0000000000..dd5f41f65e --- /dev/null +++ b/scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/styles/changesets-lazy.style @@ -0,0 +1 @@ +changeset = "{rev} " \ No newline at end of file