2 * revision_status.c: report the revision range and status of a working copy
4 * ====================================================================
5 * Copyright (c) 2003-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 "svn_private_config.h"
24 /* A baton for analyze_status(). */
27 svn_wc_revision_status_t
*result
; /* where to put the result */
28 svn_boolean_t committed
; /* examine last committed revisions */
29 const char *wc_path
; /* path whose URL we're looking for */
30 const char *wc_url
; /* URL for the path whose URL we're looking for */
31 apr_pool_t
*pool
; /* pool in which to store alloc-needy things */
34 /* An svn_wc_status_func2_t callback function for analyzing status
37 analyze_status(void *baton
,
39 svn_wc_status2_t
*status
)
41 struct status_baton
*sb
= baton
;
46 /* Added files have a revision of no interest */
47 if (status
->text_status
!= svn_wc_status_added
)
49 svn_revnum_t item_rev
= (sb
->committed
50 ? status
->entry
->cmt_rev
51 : status
->entry
->revision
);
53 if (sb
->result
->min_rev
== SVN_INVALID_REVNUM
54 || item_rev
< sb
->result
->min_rev
)
55 sb
->result
->min_rev
= item_rev
;
57 if (sb
->result
->max_rev
== SVN_INVALID_REVNUM
58 || item_rev
> sb
->result
->max_rev
)
59 sb
->result
->max_rev
= item_rev
;
62 sb
->result
->switched
|= status
->switched
;
63 sb
->result
->modified
|= (status
->text_status
!= svn_wc_status_normal
);
64 sb
->result
->modified
|= (status
->prop_status
!= svn_wc_status_normal
65 && status
->prop_status
!= svn_wc_status_none
);
66 sb
->result
->sparse_checkout
|= (status
->entry
->depth
!= svn_depth_infinity
);
70 && (strcmp(path
, sb
->wc_path
) == 0)
72 sb
->wc_url
= apr_pstrdup(sb
->pool
, status
->entry
->url
);
76 svn_wc_revision_status(svn_wc_revision_status_t
**result_p
,
78 const char *trail_url
,
79 svn_boolean_t committed
,
80 svn_cancel_func_t cancel_func
,
84 struct status_baton sb
;
86 svn_wc_adm_access_t
*anchor_access
, *target_access
;
87 const svn_delta_editor_t
*editor
;
89 svn_revnum_t edit_revision
;
90 svn_wc_revision_status_t
*result
= apr_palloc(pool
, sizeof(**result_p
));
93 /* set result as nil */
94 result
->min_rev
= SVN_INVALID_REVNUM
;
95 result
->max_rev
= SVN_INVALID_REVNUM
;
96 result
->switched
= FALSE
;
97 result
->modified
= FALSE
;
98 result
->sparse_checkout
= FALSE
;
100 /* initialize walking baton */
102 sb
.committed
= committed
;
103 sb
.wc_path
= wc_path
;
107 SVN_ERR(svn_wc_adm_open_anchor(&anchor_access
, &target_access
, &target
,
109 cancel_func
, cancel_baton
,
112 SVN_ERR(svn_wc_get_status_editor3(&editor
, &edit_baton
, NULL
,
113 &edit_revision
, anchor_access
, target
,
116 FALSE
/* no_ignore */,
117 NULL
/* ignore_patterns */,
119 cancel_func
, cancel_baton
,
120 NULL
/* traversal_info */,
123 SVN_ERR(editor
->close_edit(edit_baton
, pool
));
125 SVN_ERR(svn_wc_adm_close(anchor_access
));
127 if ((! result
->switched
) && (trail_url
!= NULL
))
129 /* If the trailing part of the URL of the working copy directory
130 does not match the given trailing URL then the whole working
134 result
->switched
= TRUE
;
138 apr_size_t len1
= strlen(trail_url
);
139 apr_size_t len2
= strlen(sb
.wc_url
);
140 if ((len1
> len2
) || strcmp(sb
.wc_url
+ len2
- len1
, trail_url
))
141 result
->switched
= TRUE
;