Hi,
I'm currently working on some code which accesses a Subversion
repository as a client but without maintaining a local working copy.
I could not find a simple way, in the current client API, to ask for the
current HEAD revision number. I can get it by asking for the log message
associated with Revision.HEAD, but I thought a more obvious client
function would be better. This patch adds that ability. It allows any
non-numeric kind of revision to be resolved to a revision number.
Mostly this is just a wrapper around the existing private function.
As I'm a relative newbie with Subversion development, it's probable that
I missed some obvious way to do this with the existing API. If so,
please just disregard the patch and enlighten me :)
Thanks - let me know what you think.
Conor
Index: src-trunk/subversion/include/svn_client.h
===================================================================
--- src-trunk/subversion/include/svn_client.h (revision 12234)
+++ src-trunk/subversion/include/svn_client.h (working copy)
@@ -1674,6 +1674,17 @@
svn_client_ctx_t *ctx,
apr_pool_t *pool);
+/** Return the revision number, @a revnum, corresponding to the given @a revision
+ * of a @a path, which may be given as a repository url. This is most useful
+ * for resolving the non-numeric revision kinds to a revision number.
+ */
+svn_error_t*
+svn_client_get_revision_number(svn_revnum_t* revnum,
+ const char* path,
+ const svn_opt_revision_t* revision,
+ apr_pool_t* pool,
+ svn_client_ctx_t* ctx);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Index: src-trunk/subversion/libsvn_client/revisions.c
===================================================================
--- src-trunk/subversion/libsvn_client/revisions.c (revision 12207)
+++ src-trunk/subversion/libsvn_client/revisions.c (working copy)
@@ -137,3 +137,68 @@
else
return TRUE;
}
+
+svn_error_t*
+svn_client_get_revision_number(svn_revnum_t* revnum, const char* target,
+ const svn_opt_revision_t* revision,
+ apr_pool_t* pool, svn_client_ctx_t* ctx)
+{
+ const char* url = NULL;
+
+ if (!svn_path_is_url(target))
+ {
+ // we may need to ask the working copy or remote, depending on the
+ // type of revision info
+ svn_wc_adm_access_t *adm_access;
+ const svn_wc_entry_t *node;
+
+ SVN_ERR (svn_wc_adm_probe_open2(&adm_access, NULL, target,
+ FALSE, 0, pool));
+ SVN_ERR (svn_wc_entry(&node, target, adm_access, FALSE, pool));
+ if (!node)
+ {
+ return svn_error_createf
+ (SVN_ERR_UNVERSIONED_RESOURCE, NULL,
+ _("'%s' is not under version control"),
+ svn_path_local_style (target, pool));
+ }
+
+ if ((revision->kind != svn_opt_revision_unspecified)
+ || (revision->kind != svn_opt_revision_base)
+ || (revision->kind != svn_opt_revision_working)
+ || (revision->kind != svn_opt_revision_committed))
+ {
+ // need the url associated with the working copy
+ url = node->url;
+ }
+ }
+ else
+ {
+ url = target;
+ }
+
+ if (url != NULL)
+ {
+ // need to talk to the server
+ void *session;
+ svn_ra_plugin_t *ra_lib;
+ const char* url;
+
+ /* Get an RA plugin for this filesystem object. */
+ SVN_ERR (svn_client__ra_lib_from_path (&ra_lib, &session, revnum,
+ &url, target, revision,
+ revision, ctx, pool));
+ SVN_ERR (svn_client__get_revision_number(revnum, ra_lib, session,
+ revision, target, pool));
+ }
+ else
+ {
+ // all of these can be found locally
+ SVN_ERR (svn_client__get_revision_number(revnum, NULL, NULL,
+ revision, target, pool));
+ }
+
+ return SVN_NO_ERROR;
+}
+
+
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Dec 10 14:56:49 2004