I don't see any way to do that without appending to a list of some sort.
 Based on the way this library is written, that's true of Java or Clojure,
since SVNLogClient doesn't appear to have any methods to return a
Collection, just these doList methods, which forces you into a side effect
style of programming.
So inside the get-dir-contents function, you would have to let a ref to a
list, then commute is as you go, then return it.  Something like this:

(defn get-dir-contents [url-path]
  (let [lst (ref [])]
    (dosync
     (.doList (.getLogClient client-mgr) (.getURL (SVNPath. url-path)) HEAD
HEAD false
      (proxy [ISVNDirEntryHandler] []
(handleDirEntry [dir-entry]
(commute lst conj (.getName dir-entry)))))
     @lst)))

On Tue, Jan 6, 2009 at 10:31 AM, Justin Johnson <[email protected]>wrote:

> In the code below (which uses the SVNKit Java library) I define the
> function get-dir-contents, which takes a Subversion repository URL and, via
> the proxy ISVNDirEntryHandler, prints each entry to the screen in the call
> to handleDirEntry.  I would like it to collect and return the entries
> instead, but I'm not sure how to do so without having handleDirEntry append
> them to a list.  Is there a more appropriate way to handle this in Clojure?
>
> Thanks,
> Justin
>
> (import '(org.tmatesoft.svn.core SVNException ISVNDirEntryHandler))
> (import '(org.tmatesoft.svn.core.internal.wc SVNPath))
> (import '(org.tmatesoft.svn.core.wc SVNWCUtil SVNClientManager
> SVNRevision))
> (import '(org.tmatesoft.svn.core.internal.io.dav DAVRepositoryFactory))
>
> (def username "user")
> (def password "password")
> (def HEAD SVNRevision/HEAD)
>
> (DAVRepositoryFactory/setup)
>
> (def client-mgr
>   (SVNClientManager/newInstance
>     (SVNWCUtil/createDefaultOptions true)
>     (SVNWCUtil/createDefaultAuthenticationManager username password)))
>
> (defn get-dir-contents [url-path]
>   (.doList (.getLogClient client-mgr) (.getURL (SVNPath. url-path)) HEAD
> HEAD false
>            (proxy [ISVNDirEntryHandler] []
>              (handleDirEntry [dir-entry]
>                (println (.getName dir-entry))))))
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to