58
59
last-commit-time. Either way, set entry-timestamp to match that of
59
60
the working file when all is finished.
61
If REMOVE_TEXT_CONFLICT is TRUE, remove an existing text conflict
62
If MARK_RESOLVED_TEXT_CONFLICT is TRUE, mark as resolved any existing
63
text conflict on LOCAL_ABSPATH.
64
65
Not that a valid access baton with a write lock to the directory of
65
66
LOCAL_ABSPATH must be available in DB.*/
67
68
restore_file(svn_wc__db_t *db,
68
69
const char *local_abspath,
69
70
svn_boolean_t use_commit_times,
70
svn_boolean_t remove_text_conflicts,
71
svn_boolean_t mark_resolved_text_conflict,
71
72
apr_pool_t *scratch_pool)
73
74
svn_skel_t *work_item;
91
92
/* Remove any text conflict */
92
if (remove_text_conflicts)
93
SVN_ERR(svn_wc__resolve_text_conflict(db, local_abspath, scratch_pool));
93
if (mark_resolved_text_conflict)
94
SVN_ERR(svn_wc__mark_resolved_text_conflict(db, local_abspath, scratch_pool));
95
96
return SVN_NO_ERROR;
113
115
svn_dirent_local_style(local_abspath,
118
118
SVN_ERR(svn_wc__db_read_info(&status, &kind, NULL, NULL, NULL, NULL, NULL,
119
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
119
NULL, NULL, NULL, &checksum, NULL, NULL, NULL, NULL,
120
120
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
121
121
NULL, NULL, NULL, NULL,
122
122
wc_ctx->db, local_abspath,
123
123
scratch_pool, scratch_pool));
125
if (status == svn_wc__db_status_added)
126
SVN_ERR(svn_wc__db_scan_addition(&status, NULL, NULL, NULL, NULL, NULL,
128
wc_ctx->db, local_abspath,
129
scratch_pool, scratch_pool));
131
125
if (status != svn_wc__db_status_normal
132
&& status != svn_wc__db_status_copied
133
&& status != svn_wc__db_status_moved_here
134
&& !(kind == svn_wc__db_kind_dir
135
&& (status == svn_wc__db_status_added
136
|| status == svn_wc__db_status_incomplete)))
126
&& !((status == svn_wc__db_status_added
127
|| status == svn_wc__db_status_incomplete)
128
&& (kind == svn_node_dir
129
|| (kind == svn_node_file && checksum != NULL)
130
/* || (kind == svn_node_symlink && target)*/)))
138
132
return svn_error_createf(SVN_ERR_WC_PATH_UNEXPECTED_STATUS, NULL,
139
133
_("The node '%s' can not be restored."),
144
if (kind == svn_wc__db_kind_file || kind == svn_wc__db_kind_symlink)
145
SVN_ERR(restore_file(wc_ctx->db, local_abspath, use_commit_times, FALSE,
138
if (kind == svn_node_file || kind == svn_node_symlink)
139
SVN_ERR(restore_file(wc_ctx->db, local_abspath, use_commit_times,
140
FALSE /*mark_resolved_text_conflict*/,
148
143
SVN_ERR(svn_io_dir_make(local_abspath, APR_OS_DEFAULT, scratch_pool));
160
155
static svn_error_t *
161
156
restore_node(svn_wc__db_t *db,
162
157
const char *local_abspath,
163
svn_wc__db_kind_t kind,
158
svn_node_kind_t kind,
164
159
svn_boolean_t use_commit_times,
165
160
svn_wc_notify_func2_t notify_func,
166
161
void *notify_baton,
167
162
apr_pool_t *scratch_pool)
169
if (kind == svn_wc__db_kind_file || kind == svn_wc__db_kind_symlink)
164
if (kind == svn_node_file || kind == svn_node_symlink)
171
/* Recreate file from text-base */
172
SVN_ERR(restore_file(db, local_abspath, use_commit_times, TRUE,
166
/* Recreate file from text-base; mark any text conflict as resolved */
167
SVN_ERR(restore_file(db, local_abspath, use_commit_times,
168
TRUE /*mark_resolved_text_conflict*/,
175
else if (kind == svn_wc__db_kind_dir)
171
else if (kind == svn_node_dir)
177
173
/* Recreating a directory is just a mkdir */
178
174
SVN_ERR(svn_io_dir_make(local_abspath, APR_OS_DEFAULT, scratch_pool));
371
371
/* Is the entry NOT on the disk? We may be able to restore it. */
372
372
if (restore_files
373
&& apr_hash_get(dirents, child, APR_HASH_KEY_STRING) == NULL)
373
&& svn_hash_gets(dirents, child) == NULL)
375
375
svn_wc__db_status_t wrk_status;
376
svn_wc__db_kind_t wrk_kind;
376
svn_node_kind_t wrk_kind;
377
const svn_checksum_t *checksum;
378
379
SVN_ERR(svn_wc__db_read_info(&wrk_status, &wrk_kind, NULL, NULL,
379
380
NULL, NULL, NULL, NULL, NULL, NULL,
380
NULL, NULL, NULL, NULL, NULL, NULL,
381
&checksum, NULL, NULL, NULL, NULL, NULL,
381
382
NULL, NULL, NULL, NULL, NULL, NULL,
382
383
NULL, NULL, NULL, NULL, NULL,
383
384
db, this_abspath, iterpool, iterpool));
385
if (wrk_status == svn_wc__db_status_added)
386
SVN_ERR(svn_wc__db_scan_addition(&wrk_status, NULL, NULL, NULL,
387
NULL, NULL, NULL, NULL, NULL,
389
iterpool, iterpool));
391
if (wrk_status == svn_wc__db_status_normal
392
|| wrk_status == svn_wc__db_status_copied
393
|| wrk_status == svn_wc__db_status_moved_here
394
|| (wrk_kind == svn_wc__db_kind_dir
395
&& (wrk_status == svn_wc__db_status_added
396
|| wrk_status == svn_wc__db_status_incomplete)))
386
if ((wrk_status == svn_wc__db_status_normal
387
|| wrk_status == svn_wc__db_status_added
388
|| wrk_status == svn_wc__db_status_incomplete)
389
&& (wrk_kind == svn_node_dir || checksum))
398
391
svn_node_kind_t dirent_kind;
646
638
svn_revnum_t target_rev = SVN_INVALID_REVNUM;
647
639
svn_boolean_t start_empty;
648
640
svn_wc__db_status_t status;
649
svn_wc__db_kind_t target_kind;
641
svn_node_kind_t target_kind;
650
642
const char *repos_relpath, *repos_root_url;
651
643
svn_depth_t target_depth;
652
644
svn_wc__db_lock_t *target_lock;
660
652
&repos_relpath, &repos_root_url,
661
653
NULL, NULL, NULL, NULL, &target_depth,
662
654
NULL, NULL, &target_lock,
664
656
db, local_abspath, scratch_pool,
719
706
&& disk_kind == svn_node_none)
721
708
svn_wc__db_status_t wrk_status;
722
svn_wc__db_kind_t wrk_kind;
709
svn_node_kind_t wrk_kind;
710
const svn_checksum_t *checksum;
723
712
err = svn_wc__db_read_info(&wrk_status, &wrk_kind, NULL, NULL, NULL,
724
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
713
NULL, NULL, NULL, NULL, NULL, &checksum, NULL,
725
714
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
726
715
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
734
723
svn_error_clear(err);
735
724
wrk_status = svn_wc__db_status_not_present;
736
wrk_kind = svn_wc__db_kind_file;
725
wrk_kind = svn_node_file;
741
if (wrk_status == svn_wc__db_status_added)
742
SVN_ERR(svn_wc__db_scan_addition(&wrk_status, NULL, NULL, NULL, NULL,
743
NULL, NULL, NULL, NULL,
745
scratch_pool, scratch_pool));
747
if (wrk_status == svn_wc__db_status_normal
748
|| wrk_status == svn_wc__db_status_copied
749
|| wrk_status == svn_wc__db_status_moved_here
750
|| (wrk_kind == svn_wc__db_kind_dir
751
&& (wrk_status == svn_wc__db_status_added
752
|| wrk_status == svn_wc__db_status_incomplete)))
730
if ((wrk_status == svn_wc__db_status_normal
731
|| wrk_status == svn_wc__db_status_added
732
|| wrk_status == svn_wc__db_status_incomplete)
733
&& (wrk_kind == svn_node_dir || checksum))
754
735
SVN_ERR(restore_node(wc_ctx->db, local_abspath,
755
736
wrk_kind, use_commit_times,
772
753
SVN_ERR(reporter->set_path(report_baton, "", target_rev, report_depth,
773
754
start_empty, NULL, scratch_pool));
775
if (target_kind == svn_wc__db_kind_dir)
756
if (target_kind == svn_node_dir)
777
758
if (depth != svn_depth_empty)
814
794
err = svn_wc__db_base_get_info(&parent_status, NULL, NULL,
815
795
&parent_repos_relpath, NULL, NULL, NULL,
816
796
NULL, NULL, NULL, NULL, NULL, NULL,
818
798
db, parent_abspath,
819
799
scratch_pool, scratch_pool);
1211
1191
apr_pool_t *iterpool = svn_pool_create(scratch_pool);
1213
1193
apr_array_header_t *propmods;
1214
svn_wc__db_kind_t kind;
1216
SVN_ERR(svn_wc__db_read_kind(&kind, db, local_abspath, FALSE, iterpool));
1194
svn_node_kind_t kind;
1196
SVN_ERR(svn_wc__db_read_kind(&kind, db, local_abspath,
1197
FALSE /* allow_missing */,
1198
FALSE /* show_deleted */,
1199
FALSE /* show_hidden */,
1202
if (kind == svn_node_none)
1203
return svn_error_createf(SVN_ERR_WC_PATH_NOT_FOUND, NULL,
1204
_("The node '%s' was not found."),
1205
svn_dirent_local_style(local_abspath, iterpool));
1218
1207
/* Get an array of local changes by comparing the hashes. */
1219
1208
SVN_ERR(svn_wc__internal_propdiff(&propmods, NULL, db, local_abspath,