00001
00002
00003
00004
00005
00006
00007
00008
00017 #include <subversion-1/svn_delta.h>
00018 #include <subversion-1/svn_ra.h>
00019 #include <subversion-1/svn_error.h>
00020
00021 #include "export.h"
00022 #include "helper.h"
00023 #include "url.h"
00024 #include "racallback.h"
00025
00026
00054
00055
00057 svn_error_t *exp__invalid(const char *name)
00058 {
00059 int status;
00060
00061 STOPIF_CODE_ERR(1, EINVAL,
00062 "The function %s got called "
00063 "during an export operation;\n"
00064 "this call is unexpected and won't be handled.\n"
00065 "This should not happen.\n",
00066 name);
00067 ex:
00068 RETURN_SVNERR(status);
00069 }
00070
00071
00073 svn_error_t *exp__delete(const char *path UNUSED,
00074 svn_revnum_t revision UNUSED,
00075 void *parent_baton UNUSED,
00076 apr_pool_t *pool UNUSED)
00077 {
00078 return exp__invalid(__PRETTY_FUNCTION__);
00079 }
00080
00081
00083 svn_error_t *exp__open_dir(const char *path UNUSED,
00084 void *parent_baton UNUSED,
00085 svn_revnum_t base_revision UNUSED,
00086 apr_pool_t *dir_pool UNUSED,
00087 void **child_baton UNUSED)
00088 {
00089 return exp__invalid(__PRETTY_FUNCTION__);
00090 }
00091
00092
00094 svn_error_t *exp__open_file(const char *path UNUSED,
00095 void *parent_baton UNUSED,
00096 svn_revnum_t base_revision UNUSED,
00097 apr_pool_t *file_pool UNUSED,
00098 void **file_baton UNUSED)
00099 {
00100 return exp__invalid(__PRETTY_FUNCTION__);
00101 }
00109 const svn_delta_editor_t export_editor =
00110 {
00111 .set_target_revision = up__set_target_revision,
00112
00113 .open_root = up__open_root,
00114
00115 .delete_entry = exp__delete,
00116 .add_directory = up__add_directory,
00117 .open_directory = exp__open_dir,
00118 .change_dir_prop = up__change_dir_prop,
00119 .close_directory = up__close_directory,
00120 .absent_directory = up__absent_directory,
00121
00122 .add_file = up__add_file,
00123 .open_file = exp__open_file,
00124 .apply_textdelta = up__apply_textdelta,
00125 .change_file_prop = up__change_file_prop,
00126 .close_file = up__close_file,
00127 .absent_file = up__absent_file,
00128
00129 .close_edit = up__close_edit,
00130 .abort_edit = up__abort_edit,
00131 };
00132
00133
00140 int exp__do(struct estat *root, struct url_t *url)
00141 {
00142 int status;
00143 svn_revnum_t rev;
00144 svn_error_t *status_svn;
00145 void *report_baton;
00146 const svn_ra_reporter2_t *reporter;
00147
00148
00149 status_svn=NULL;
00150 current_url=url;
00151
00152 STOPIF( url__open_session(NULL, NULL), NULL);
00153
00154 rev=url->target_rev;
00155
00156 STOPIF( url__canonical_rev(current_url, &rev), NULL);
00157
00158
00159 STOPIF_SVNERR( svn_ra_do_update,
00160 (current_url->session,
00161 &reporter,
00162 &report_baton,
00163 opt_target_revision,
00164 "",
00165 TRUE,
00166 &export_editor,
00167 root,
00168 current_url->pool) );
00169
00170
00171 STOPIF_SVNERR( reporter->set_path,
00172 (report_baton,
00173 "", rev, TRUE,
00174 NULL, current_url->pool));
00175
00176 STOPIF_SVNERR( reporter->finish_report,
00177 (report_baton, current_url->pool));
00178
00179
00180 ex:
00181 STOP_HANDLE_SVNERR(status_svn);
00182 ex2:
00183 return status;
00184 }
00185
00186
00192 int exp__work(struct estat *root, int argc, char *argv[])
00193 {
00194 int status;
00195 struct url_t url;
00196
00197
00198 status=0;
00199
00200 STOPIF_CODE_ERR(argc!=1, EINVAL,
00201 "1 parameter (URL) expected");
00202
00203 STOPIF( url__parse(argv[0], &url, NULL), NULL);
00204
00205
00206 STOPIF( hlp__lstat(".", &root->st),
00207 "Cannot retrieve information about '.'");
00208
00209 STOPIF( exp__do(root, &url), NULL);
00210 printf("Exported revision\t%ld.\n", target_revision);
00211
00212
00213
00214 STOPIF( url__close_session(&url), NULL);
00215
00216 ex:
00217 return status;
00218 }
00219