~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/libsvn_client/revisions.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * revisions.c:  discovering revisions
 
3
 *
 
4
 * ====================================================================
 
5
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 
6
 *
 
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.
 
12
 *
 
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
 * ====================================================================
 
17
 */
 
18
 
 
19
 
 
20
 
 
21
#include <apr_pools.h>
 
22
 
 
23
#include "svn_error.h"
 
24
#include "svn_ra.h"
 
25
#include "svn_wc.h"
 
26
#include "svn_path.h"
 
27
#include "client.h"
 
28
 
 
29
#include "svn_private_config.h"
 
30
 
 
31
 
 
32
 
 
33
 
 
34
svn_error_t *
 
35
svn_client__get_revision_number (svn_revnum_t *revnum,
 
36
                                 svn_ra_session_t *ra_session,
 
37
                                 const svn_opt_revision_t *revision,
 
38
                                 const char *path,
 
39
                                 apr_pool_t *pool)
 
40
{
 
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 */
 
49
 
 
50
  /* Sanity check. */
 
51
  if (ra_session == NULL
 
52
      && ((revision->kind == svn_opt_revision_date)
 
53
          || (revision->kind == svn_opt_revision_head)))
 
54
    {
 
55
      return svn_error_create
 
56
        (SVN_ERR_CLIENT_RA_ACCESS_REQUIRED, NULL, NULL);
 
57
    }
 
58
 
 
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))
 
72
    {
 
73
      svn_wc_adm_access_t *adm_access; /* ### FIXME local */
 
74
      const svn_wc_entry_t *ent;
 
75
 
 
76
      /* Sanity check. */
 
77
      if (path == NULL)
 
78
        return svn_error_create
 
79
          (SVN_ERR_CLIENT_VERSIONED_PATH_REQUIRED, NULL, NULL);
 
80
 
 
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));
 
85
 
 
86
      if (! ent)
 
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));
 
91
      
 
92
      if ((revision->kind == svn_opt_revision_base)
 
93
          || (revision->kind == svn_opt_revision_working))
 
94
        *revnum = ent->revision;
 
95
      else
 
96
        {
 
97
          *revnum = ent->cmt_rev;
 
98
          if (revision->kind == svn_opt_revision_previous)
 
99
            (*revnum)--;
 
100
        }
 
101
    }
 
102
  else
 
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));
 
107
  
 
108
  return SVN_NO_ERROR;
 
109
}
 
110
 
 
111
 
 
112
svn_boolean_t
 
113
svn_client__compare_revisions (svn_opt_revision_t *revision1,
 
114
                               svn_opt_revision_t *revision2)
 
115
{
 
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)))
 
121
    return FALSE;
 
122
 
 
123
  /* Else. */
 
124
  return TRUE;
 
125
}
 
126
 
 
127
 
 
128
svn_boolean_t
 
129
svn_client__revision_is_local (const svn_opt_revision_t *revision)
 
130
{
 
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))
 
135
    return FALSE;
 
136
  else
 
137
    return TRUE;
 
138
}