2
* revisions.c: discovering revisions
4
* ====================================================================
5
* Copyright (c) 2000-2004 CollabNet. All rights reserved.
7
* This software is licensed as described in the file COPYING, which
8
* you should have received as part of this distribution. The terms
9
* are also available at http://subversion.tigris.org/license-1.html.
10
* If newer versions of this license are posted there, you may use a
11
* newer version instead, at your option.
13
* This software consists of voluntary contributions made by many
14
* individuals. For exact contribution history, see the revision
15
* history and logs, available at http://subversion.tigris.org/.
16
* ====================================================================
21
#include <apr_pools.h>
23
#include "svn_error.h"
29
#include "svn_private_config.h"
35
svn_client__get_revision_number (svn_revnum_t *revnum,
36
svn_ra_session_t *ra_session,
37
const svn_opt_revision_t *revision,
41
/* ### When revision->kind == svn_opt_revision_date, is there an
42
optimization such that we can compare revision->value->date with
43
the committed-date in the entries file (or rather, with some
44
range of which committed-date is one endpoint), and sometimes
45
avoid a trip over the RA layer? The only optimizations I can
46
think of involve examining other entries to build a timespan
47
across which committed-revision is known to be the head, but it
48
doesn't seem worth it. -kff */
51
if (ra_session == NULL
52
&& ((revision->kind == svn_opt_revision_date)
53
|| (revision->kind == svn_opt_revision_head)))
55
return svn_error_create
56
(SVN_ERR_CLIENT_RA_ACCESS_REQUIRED, NULL, NULL);
59
if (revision->kind == svn_opt_revision_number)
60
*revnum = revision->value.number;
61
else if (revision->kind == svn_opt_revision_date)
62
SVN_ERR (svn_ra_get_dated_revision (ra_session, revnum,
63
revision->value.date, pool));
64
else if (revision->kind == svn_opt_revision_head)
65
SVN_ERR (svn_ra_get_latest_revnum (ra_session, revnum, pool));
66
else if (revision->kind == svn_opt_revision_unspecified)
67
*revnum = SVN_INVALID_REVNUM;
68
else if ((revision->kind == svn_opt_revision_committed)
69
|| (revision->kind == svn_opt_revision_working)
70
|| (revision->kind == svn_opt_revision_base)
71
|| (revision->kind == svn_opt_revision_previous))
73
svn_wc_adm_access_t *adm_access; /* ### FIXME local */
74
const svn_wc_entry_t *ent;
78
return svn_error_create
79
(SVN_ERR_CLIENT_VERSIONED_PATH_REQUIRED, NULL, NULL);
81
SVN_ERR (svn_wc_adm_probe_open3 (&adm_access, NULL, path, FALSE,
82
0, NULL, NULL, pool));
83
SVN_ERR (svn_wc_entry (&ent, path, adm_access, FALSE, pool));
84
SVN_ERR (svn_wc_adm_close (adm_access));
87
return svn_error_createf
88
(SVN_ERR_UNVERSIONED_RESOURCE, NULL,
89
_("'%s' is not under version control"),
90
svn_path_local_style (path, pool));
92
if ((revision->kind == svn_opt_revision_base)
93
|| (revision->kind == svn_opt_revision_working))
94
*revnum = ent->revision;
97
*revnum = ent->cmt_rev;
98
if (revision->kind == svn_opt_revision_previous)
103
return svn_error_createf
104
(SVN_ERR_CLIENT_BAD_REVISION, NULL,
105
_("Unrecognized revision type requested for '%s'"),
106
svn_path_local_style (path, pool));
113
svn_client__compare_revisions (svn_opt_revision_t *revision1,
114
svn_opt_revision_t *revision2)
116
if ((revision1->kind != revision2->kind)
117
|| ((revision1->kind == svn_opt_revision_number)
118
&& (revision1->value.number != revision2->value.number))
119
|| ((revision1->kind == svn_opt_revision_date)
120
&& (revision1->value.date != revision2->value.date)))
129
svn_client__revision_is_local (const svn_opt_revision_t *revision)
131
if ((revision->kind == svn_opt_revision_unspecified)
132
|| (revision->kind == svn_opt_revision_head)
133
|| (revision->kind == svn_opt_revision_number)
134
|| (revision->kind == svn_opt_revision_date))