Is a new datatype really needed? You've got two members, and one of those already has pretty sketchy multi-variant semantics. On Nov 1, 2011 8:12 AM, <julianf...@apache.org> wrote:
> Author: julianfoad > Date: Tue Nov 1 12:11:53 2011 > New Revision: 1195948 > > URL: http://svn.apache.org/viewvc?rev=1195948&view=rev > Log: > On the 'showing-merge-info' branch: Introduce a 'pegged location' data type > in the libsvn_client API. > > * subversion/include/svn_client.h > (svn_client_peg_t): New structure type. > (svn_client_peg_dup, svn_client_peg_create): New functions. > > * subversion/include/private/svn_client_private.h > (svn_client__peg_resolve): New function. > > * subversion/libsvn_client/url.c > (svn_client_peg_dup, svn_client_peg_create, svn_client__peg_resolve): New > functions. > > Modified: > > > subversion/branches/showing-merge-info/subversion/include/private/svn_client_private.h > subversion/branches/showing-merge-info/subversion/include/svn_client.h > subversion/branches/showing-merge-info/subversion/libsvn_client/url.c > > Modified: > subversion/branches/showing-merge-info/subversion/include/private/svn_client_private.h > URL: > http://svn.apache.org/viewvc/subversion/branches/showing-merge-info/subversion/include/private/svn_client_private.h?rev=1195948&r1=1195947&r2=1195948&view=diff > > ============================================================================== > --- > subversion/branches/showing-merge-info/subversion/include/private/svn_client_private.h > (original) > +++ > subversion/branches/showing-merge-info/subversion/include/private/svn_client_private.h > Tue Nov 1 12:11:53 2011 > @@ -59,6 +59,25 @@ svn_client__create_status(svn_client_sta > apr_pool_t *result_pool, > apr_pool_t *scratch_pool); > > + > +/** Resolve @a peg to a repository location and open an RA session to > there. > + * Set @a *target_p to the location and @a *session_p to the new session, > + * both allocated in @a result_pool. > + * > + * If @a peg->path_or_url is a URL then a peg revision kind of > 'unspecified' > + * means 'head', otherwise it means 'base'. > + * > + * @since New in 1.8. > + */ > +svn_error_t * > +svn_client__peg_resolve(svn_client_target_t **target_p, > + svn_ra_session_t **session_p, > + const svn_client_peg_t *peg, > + svn_client_ctx_t *ctx, > + apr_pool_t *result_pool, > + apr_pool_t *scratch_pool); > + > + > /* This property marks a branch root. Branches with the same value of this > * property are mergeable. */ > #define SVN_PROP_BRANCH_ROOT "svn:ignore" /* ### should be > "svn:branch-root" */ > > Modified: > subversion/branches/showing-merge-info/subversion/include/svn_client.h > URL: > http://svn.apache.org/viewvc/subversion/branches/showing-merge-info/subversion/include/svn_client.h?rev=1195948&r1=1195947&r2=1195948&view=diff > > ============================================================================== > --- subversion/branches/showing-merge-info/subversion/include/svn_client.h > (original) > +++ subversion/branches/showing-merge-info/subversion/include/svn_client.h > Tue Nov 1 12:11:53 2011 > @@ -68,6 +68,57 @@ svn_client_version(void); > * @{ > */ > > +/** A "peg" is the location of a versioned node in a repository or in a > + * working copy, as specified by the client to libsvn_client. > + * > + * If @a path_or_url is a URL then @a peg_revision specifies the > + * revision at which the URL is to be looked up, and the peg revision > + * kinds 'base', 'committed' and 'prev' are invalid. > + * > + * Otherwise, @a path_or_url is a working copy path. > + * > + * @note About the meaning of a "peg revision" with a working copy path. > + * A working-copy path by itself implicitly identifies one line or > + * sometimes two lines of history. > + * The line through its base version is not always the same as the line > + * through its working version. These differ if the working version is > + * copied or moved (so its line of history is through its copy-from > source) > + * or added (so it has no line of history in the repository, only locally) > + * or deleted (so it no longer refers to a versioned object). In any > + * case there are only two lines of history to distinguish, and these > could > + * be distinguished by specifying 'base' or 'working'. Historically, > + * the libsvn_client API and the 'svn' command-line client accept any peg > + * revision specifier with a working copy path, and ### ?... (when it is > + * not 'BASE'?) it acts not as a peg revision but as an operative > revision, > + * with the peg implicitly being ... ### BASE?). > + * > + * @since New in 1.8. > + */ > +typedef struct svn_client_peg_t > +{ > + const char *path_or_url; > + svn_opt_revision_t peg_revision; > +} svn_client_peg_t; > + > +/** Return a deep copy of @a peg, allocated in @a pool. > + * > + * @since New in 1.8. > + */ > +svn_client_peg_t * > +svn_client_peg_dup(const svn_client_peg_t *peg, > + apr_pool_t *pool); > + > +/** Return a peg created from the given @a path_or_url and @a > peg_revision, > + * allocated in @a pool. > + * @a peg_revision may be NULL, meaning 'unspecified'. > + * > + * @since New in 1.8. > + */ > +svn_client_peg_t * > +svn_client_peg_create(const char *path_or_url, > + const svn_opt_revision_t *peg_revision, > + apr_pool_t *pool); > + > > /*** Authentication stuff ***/ > > > Modified: > subversion/branches/showing-merge-info/subversion/libsvn_client/url.c > URL: > http://svn.apache.org/viewvc/subversion/branches/showing-merge-info/subversion/libsvn_client/url.c?rev=1195948&r1=1195947&r2=1195948&view=diff > > ============================================================================== > --- subversion/branches/showing-merge-info/subversion/libsvn_client/url.c > (original) > +++ subversion/branches/showing-merge-info/subversion/libsvn_client/url.c > Tue Nov 1 12:11:53 2011 > @@ -64,6 +64,45 @@ svn_client_url_from_path2(const char **u > } > > > +svn_client_peg_t * > +svn_client_peg_dup(const svn_client_peg_t *peg, > + apr_pool_t *pool) > +{ > + svn_client_peg_t *peg2 = apr_pmemdup(pool, peg, sizeof(*peg2)); > + > + peg2->path_or_url = apr_pstrdup(pool, peg->path_or_url); > + return peg2; > +} > + > +svn_client_peg_t * > +svn_client_peg_create(const char *path_or_url, > + const svn_opt_revision_t *peg_revision, > + apr_pool_t *pool) > +{ > + svn_client_peg_t *peg = apr_palloc(pool, sizeof(*peg)); > + > + peg->path_or_url = apr_pstrdup(pool, path_or_url); > + peg->peg_revision = *peg_revision; > + return SVN_NO_ERROR; > +} > + > +svn_error_t * > +svn_client__peg_resolve(svn_client_target_t **target_p, > + svn_ra_session_t **session_p, > + const svn_client_peg_t *peg, > + svn_client_ctx_t *ctx, > + apr_pool_t *result_pool, > + apr_pool_t *scratch_pool) > +{ > + SVN_ERR(svn_client__target(target_p, peg->path_or_url, > &peg->peg_revision, > + result_pool)); > + *session_p = NULL; > + SVN_ERR(svn_client__resolve_target_location(*target_p, session_p, > + ctx, result_pool)); > + return SVN_NO_ERROR; > +} > + > + > svn_error_t * > svn_client__target(svn_client_target_t **target_p, > const char *path_or_url, > > >