[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Proposal for $ReposRoot$ keyword

From: John Peacock <jpeacock_at_rowman.com>
Date: 2005-09-28 13:34:50 CEST

I've had a little time to work on add $ReposRoot$ as a new keyword and it's gone
very smoothly except for the export case, which is a problem. Why, oh why,
doesn't export use exactly the same library calls as checkout except for writing
the admin files? There is no RA session available from within
export.c:add_file, so I have to set one up just so I can call
svn_ra_get_repos_root. It's a pain.

Does anyone care enough about having a keyword for $ReposRoot$ added that I
should struggle trying to get this to work? I've attached my patch in progress,
mostly as a demonstration of how simple it is to add keywords now. The code in
export.c is too simplistic and will only work when exporting the repository from
the root.

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747

=== subversion/include/svn_subst.h
==================================================================
--- subversion/include/svn_subst.h (revision 15781)
+++ subversion/include/svn_subst.h (local)
@@ -115,6 +115,7 @@
 svn_subst_build_keywords2 (apr_hash_t **kw,
                            const char *keywords_string,
                            const char *rev,
+ const char *repos,
                            const char *url,
                            apr_time_t date,
                            const char *author,
=== subversion/include/svn_types.h
==================================================================
--- subversion/include/svn_types.h (revision 15781)
+++ subversion/include/svn_types.h (local)
@@ -291,6 +291,9 @@
 /** Short version of HeadURL */
 #define SVN_KEYWORD_URL_SHORT "URL"
 
+/** The Repository Root path */
+#define SVN_KEYWORD_REPOS_ROOT "ReposRoot"
+
 /** A compressed combination of the other four keywords. */
 #define SVN_KEYWORD_ID "Id"
 
=== subversion/libsvn_client/cat.c
==================================================================
--- subversion/libsvn_client/cat.c (revision 15781)
+++ subversion/libsvn_client/cat.c (local)
@@ -139,7 +139,7 @@
       SVN_ERR (svn_subst_build_keywords2
                (&kw, keywords->data,
                 apr_psprintf (pool, fmt, entry->cmt_rev),
- entry->url, tm, author, pool));
+ entry->repos, entry->url, tm, author, pool));
     }
 
   SVN_ERR (svn_io_file_open (&input_file, base,
@@ -255,6 +255,7 @@
         {
           svn_string_t *cmt_rev, *cmt_date, *cmt_author;
           apr_time_t when = 0;
+ const char *repos;
 
           cmt_rev = apr_hash_get (props, SVN_PROP_ENTRY_COMMITTED_REV,
                                   APR_HASH_KEY_STRING);
@@ -265,9 +266,12 @@
           if (cmt_date)
             SVN_ERR (svn_time_from_cstring (&when, cmt_date->data, pool));
 
+ SVN_ERR (svn_ra_get_repos_root (ra_session, &repos, pool));
+
           SVN_ERR (svn_subst_build_keywords2
                    (&kw, keywords->data,
                     cmt_rev->data,
+ repos,
                     url,
                     when,
                     cmt_author ? cmt_author->data : NULL,
=== subversion/libsvn_client/commit.c
==================================================================
--- subversion/libsvn_client/commit.c (revision 15781)
+++ subversion/libsvn_client/commit.c (local)
@@ -126,7 +126,7 @@
       if (keywords_val)
         SVN_ERR (svn_subst_build_keywords2 (&keywords, keywords_val->data,
                                             APR_STRINGIFY(SVN_INVALID_REVNUM),
- "", 0, "", pool));
+ "", "", 0, "", pool));
       
       if ((err = svn_subst_copy_and_translate3 (path, tmpfile_path,
                                                 eol_style_val ? "\n" : NULL,
=== subversion/libsvn_client/export.c
==================================================================
--- subversion/libsvn_client/export.c (revision 15781)
+++ subversion/libsvn_client/export.c (local)
@@ -191,7 +191,7 @@
       SVN_ERR (svn_subst_build_keywords2
                (&kw, keywords->data,
                 apr_psprintf (pool, fmt, entry->cmt_rev),
- entry->url, tm, author, pool));
+ entry->repos, entry->url, tm, author, pool));
     }
 
   SVN_ERR (svn_subst_copy_and_translate3 (base, to, eol, FALSE,
@@ -435,6 +435,7 @@
 
   /* Any keyword vals to be substituted */
   const char *revision;
+ const char *repos;
   const char *url;
   const char *author;
   apr_time_t date;
@@ -551,6 +552,7 @@
 
   fb->edit_baton = eb;
   fb->path = full_path;
+ fb->repos = eb->root_url;
   fb->url = full_url;
   fb->pool = pool;
 
@@ -705,8 +707,8 @@
 
       if (fb->keywords_val)
         SVN_ERR (svn_subst_build_keywords2 (&final_kw, fb->keywords_val->data,
- fb->revision, fb->url, fb->date,
- fb->author, pool));
+ fb->revision, fb->repos, fb->url,
+ fb->date, fb->author, pool));
 
       SVN_ERR (svn_subst_copy_and_translate3
                (fb->tmppath, fb->path,
@@ -790,14 +792,18 @@
         {
           apr_hash_t *props;
           apr_hash_index_t *hi;
+ const char *repos;
           struct file_baton *fb = apr_pcalloc (pool, sizeof(*fb));
 
           /* Since you cannot actually root an editor at a file, we
            * manually drive a few functions of our editor. */
 
+ SVN_ERR (svn_ra_get_repos_root (ra_session, &repos, pool));
+
           /* This is the equivalent of a parentless add_file(). */
           fb->edit_baton = eb;
           fb->path = eb->root_path;
+ fb->repos = repos;
           fb->url = eb->root_url;
           fb->pool = pool;
           
=== subversion/libsvn_subr/subst.c
==================================================================
--- subversion/libsvn_subr/subst.c (revision 15781)
+++ subversion/libsvn_subr/subst.c (local)
@@ -117,6 +117,7 @@
 static svn_string_t *
 keyword_printf (const char *fmt,
                 const char *rev,
+ const char *repos,
                 const char *url,
                 apr_time_t date,
                 const char *author,
@@ -181,6 +182,10 @@
           if (rev)
             svn_stringbuf_appendcstr (value, rev);
           break;
+ case 'R': /* repository root */
+ if (repos)
+ svn_stringbuf_appendcstr (value, repos);
+ break;
         case 'u': /* URL of this file */
           if (url)
             svn_stringbuf_appendcstr (value, url);
@@ -274,7 +279,7 @@
   apr_hash_t *kwhash;
   const svn_string_t *val;
 
- SVN_ERR (svn_subst_build_keywords2 (&kwhash, keywords_val, rev,
+ SVN_ERR (svn_subst_build_keywords2 (&kwhash, keywords_val, rev, NULL,
                                       url, date, author, pool));
 
   /* The behaviour of pre-1.3 svn_subst_build_keywords, which we are
@@ -309,6 +314,7 @@
 svn_subst_build_keywords2 (apr_hash_t **kw,
                            const char *keywords_val,
                            const char *rev,
+ const char *repos,
                            const char *url,
                            apr_time_t date,
                            const char *author,
@@ -331,7 +337,8 @@
         {
           svn_string_t *revision_val;
 
- revision_val = keyword_printf ("%r", rev, url, date, author, pool);
+ revision_val = keyword_printf ("%r", rev, repos, url,
+ date, author, pool);
           apr_hash_set (*kw, SVN_KEYWORD_REVISION_LONG,
                         APR_HASH_KEY_STRING, revision_val);
           apr_hash_set (*kw, SVN_KEYWORD_REVISION_MEDIUM,
@@ -344,7 +351,8 @@
         {
           svn_string_t *date_val;
 
- date_val = keyword_printf ("%D", rev, url, date, author, pool);
+ date_val = keyword_printf ("%D", rev, repos, url,
+ date, author, pool);
           apr_hash_set (*kw, SVN_KEYWORD_DATE_LONG,
                         APR_HASH_KEY_STRING, date_val);
           apr_hash_set (*kw, SVN_KEYWORD_DATE_SHORT,
@@ -355,18 +363,29 @@
         {
           svn_string_t *author_val;
 
- author_val = keyword_printf ("%a", rev, url, date, author, pool);
+ author_val = keyword_printf ("%a", rev, repos, url,
+ date, author, pool);
           apr_hash_set (*kw, SVN_KEYWORD_AUTHOR_LONG,
                         APR_HASH_KEY_STRING, author_val);
           apr_hash_set (*kw, SVN_KEYWORD_AUTHOR_SHORT,
                         APR_HASH_KEY_STRING, author_val);
         }
+ else if (! strcmp (keyword, SVN_KEYWORD_REPOS_ROOT))
+ {
+ svn_string_t *repos_val;
+
+ repos_val = keyword_printf ("%R", rev, repos, url,
+ date, author, pool);
+ apr_hash_set (*kw, SVN_KEYWORD_REPOS_ROOT,
+ APR_HASH_KEY_STRING, repos_val);
+ }
       else if ((! strcmp (keyword, SVN_KEYWORD_URL_LONG))
                || (! strcasecmp (keyword, SVN_KEYWORD_URL_SHORT)))
         {
           svn_string_t *url_val;
 
- url_val = keyword_printf ("%u", rev, url, date, author, pool);
+ url_val = keyword_printf ("%u", rev, repos, url,
+ date, author, pool);
           apr_hash_set (*kw, SVN_KEYWORD_URL_LONG,
                         APR_HASH_KEY_STRING, url_val);
           apr_hash_set (*kw, SVN_KEYWORD_URL_SHORT,
@@ -376,8 +395,8 @@
         {
           svn_string_t *id_val;
 
- id_val = keyword_printf ("%b %r %d %a", rev, url, date, author,
- pool);
+ id_val = keyword_printf ("%b %r %d %a", rev, repos, url,
+ date, author, pool);
           apr_hash_set (*kw, SVN_KEYWORD_ID,
                         APR_HASH_KEY_STRING, id_val);
         }
=== subversion/libsvn_wc/translate.c
==================================================================
--- subversion/libsvn_wc/translate.c (revision 15781)
+++ subversion/libsvn_wc/translate.c (local)
@@ -205,6 +205,7 @@
                                       list,
                                       apr_psprintf (pool, "%ld",
                                                     entry->cmt_rev),
+ entry->repos,
                                       entry->url,
                                       entry->cmt_date,
                                       entry->cmt_author,

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Sep 28 13:35:29 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.