From ab85fb9bf6ef412c9e915ae5810e25fdcaf29dad Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Sat, 19 Jan 2013 13:09:36 +0100 Subject: [PATCH] added recursive option to browse command --- .../repository/api/BrowseCommandBuilder.java | 22 +++++++++-- .../repository/spi/BrowseCommandRequest.java | 38 +++++++++++++++++-- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java index f624dbdbf0..0cc2c3dc86 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java @@ -221,15 +221,15 @@ public final class BrowseCommandBuilder /** * Disabling the last commit means that every call to - * {@link FileObject#getDescription()} and - * {@link FileObject#getLastModified()) will return {@code null}, but this + * {@link FileObject#getDescription()} and + * {@link FileObject#getLastModified()) will return {@code null}, but this * will also reduce the execution time. * * * @param disableLastCommit true to disable the last commit message * * @return {@code this} - * + * * @since 1.26 */ public BrowseCommandBuilder setDisableLastCommit(boolean disableLastCommit) @@ -270,6 +270,22 @@ public final class BrowseCommandBuilder return this; } + /** + * Enable or disable recursive file object browsing. Default is disabled. + * + * @param recursive true to enable recursive browsing + * + * @return {@code this} + * + * @since 1.26 + */ + public BrowseCommandBuilder setRecursive(boolean recursive) + { + this.request.setRecursive(recursive); + + return this; + } + /** * Retrieve only files of the given revision. * diff --git a/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommandRequest.java b/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommandRequest.java index 1c0fcbf61f..5852f39714 100644 --- a/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommandRequest.java +++ b/scm-core/src/main/java/sonia/scm/repository/spi/BrowseCommandRequest.java @@ -98,7 +98,7 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest final BrowseCommandRequest other = (BrowseCommandRequest) obj; - return super.equals(obj) + return super.equals(obj) && Objects.equal(recursive, other.recursive) && Objects.equal(disableLastCommit, other.disableLastCommit); } @@ -111,7 +111,7 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), disableLastCommit); + return Objects.hashCode(super.hashCode(), recursive, disableLastCommit); } /** @@ -127,6 +127,7 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest return Objects.toStringHelper(this) .add("path", getPath()) .add("revision", getRevision()) + .add("recursive", recursive) .add("disableLastCommit", disableLastCommit) .toString(); //J+ @@ -139,7 +140,7 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest * * * @param disableLastCommit true to disable the last commit - * + * * @since 1.26 */ public void setDisableLastCommit(boolean disableLastCommit) @@ -147,6 +148,19 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest this.disableLastCommit = disableLastCommit; } + /** + * True to enable recursive file object browsing. + * + * + * @param recursive true to enable recursive browsing + * + * @since 1.26 + */ + public void setRecursive(boolean recursive) + { + this.recursive = recursive; + } + //~--- get methods ---------------------------------------------------------- /** @@ -154,7 +168,7 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest * * * @return true if the last commit is disabled - * + * * @since 1.26 */ boolean isDisableLastCommit() @@ -162,8 +176,24 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest return disableLastCommit; } + /** + * Returns true if recursive file object browsing is enabled. + * + * + * @return true recursive is enabled + * + * @since 1.26 + */ + boolean isRecursive() + { + return recursive; + } + //~--- fields --------------------------------------------------------------- /** disable last commit */ private boolean disableLastCommit = false; + + /** browse file objects recursive */ + private boolean recursive = false; }