Repository navigation
Expand file tree
/
Copy pathwc_db.h
More file actions
3660 lines (3016 loc) · 150 KB
/
Copy pathwc_db.h
File metadata and controls
3660 lines (3016 loc) · 150 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @copyright
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
* @endcopyright
*
* @file wc_db.h
* @brief The Subversion Working Copy Library - Metadata/Base-Text Support
*
* Requires:
* - A working copy
*
* Provides:
* - Ability to manipulate working copy's administrative files.
*
* Used By:
* - The main working copy library
*/
#ifndef SVN_WC_DB_H
#define SVN_WC_DB_H
#include "svn_wc.h"
#include "svn_types.h"
#include "svn_error.h"
#include "svn_config.h"
#include "svn_io.h"
#include "private/svn_skel.h"
#include "private/svn_sqlite.h"
#include "private/svn_wc_private.h"
#include "svn_private_config.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* INTERFACE CONVENTIONS
"OUT" PARAMETERS
There are numerous functions within this API which take a (large) number
of "out" parameters. These are listed individually, rather than combined
into a struct, so that a caller can be fine-grained about the which
pieces of information are being requested. In many cases, only a subset
is required, so the implementation can perform various optimizations
to fulfill the limited request for information.
POOLS
wc_db uses the dual-pool paradigm for all of its functions. Any OUT
parameter will be allocated within the result pool, and all temporary
allocations will be performed within the scratch pool.
The pool that DB is allocated within (the "state" pool) is only used
for a few, limited allocations to track each of the working copy roots
that the DB is asked to operate upon. The memory usage on this pool
is O(# wcroots), which should normally be one or a few. Custom clients
which hold open structures over a significant period of time should
pay particular attention to the number of roots touched, and the
resulting impact on memory consumption (which should still be minimal).
PARAMETER CONVENTIONS
* Parameter Order
- any output arguments
- DB
- LOCAL_ABSPATH
- any other input arguments
- RESULT_POOL
- SCRATCH_POOL
* DB
This parameter is the primary context for all operations on the
metadata for working copies. This parameter is passed to almost every
function, and maintains information and state about every working
copy "touched" by any of the APIs in this interface.
* *_ABSPATH
All *_ABSPATH parameters in this API are absolute paths in the local
filesystem, represented in Subversion internal canonical form.
* LOCAL_ABSPATH
This parameter specifies a particular *versioned* node in the local
filesystem. From this node, a working copy root is implied, and will
be used for the given API operation.
* LOCAL_DIR_ABSPATH
This parameter is similar to LOCAL_ABSPATH, but the semantics of the
parameter and operation require the node to be a directory within
the working copy.
* WRI_ABSPATH
This is a "Working copy Root Indicator" path. This refers to a location
in the local filesystem that is anywhere inside a working copy. The given
operation will be performed within the context of the root of that
working copy. This does not necessarily need to refer to a specific
versioned node or the root of a working copy (although it can) -- any
location, existing or not, is sufficient, as long as it is inside a
working copy.
### TODO: Define behaviour for switches and externals.
### Preference has been stated that WRI_ABSPATH should imply the root
### of the parent WC of all switches and externals, but that may
### not play out well, especially with multiple repositories involved.
*/
/* Context data structure for interacting with the administrative data. */
typedef struct svn_wc__db_t svn_wc__db_t;
/* Enumerated values describing the state of a node. */
typedef enum svn_wc__db_status_t {
/* The node is present and has no known modifications applied to it. */
svn_wc__db_status_normal,
/* The node has been added (potentially obscuring a delete or move of
the BASE node; see HAVE_BASE param [### What param? This is an enum
not a function.] ). The text will be marked as
modified, and if properties exist, they will be marked as modified.
In many cases svn_wc__db_status_added means any of added, moved-here
or copied-here. See individual functions for clarification and
svn_wc__db_scan_addition() to get more details. */
svn_wc__db_status_added,
/* This node has been added with history, based on the move source.
Text and property modifications are based on whether changes have
been made against their pristine versions. */
svn_wc__db_status_moved_here,
/* This node has been added with history, based on the copy source.
Text and property modifications are based on whether changes have
been made against their pristine versions. */
svn_wc__db_status_copied,
/* This node has been deleted. No text or property modifications
will be present. */
svn_wc__db_status_deleted,
/* This node was named by the server, but no information was provided. */
svn_wc__db_status_server_excluded,
/* This node has been administratively excluded. */
svn_wc__db_status_excluded,
/* This node is not present in this revision. This typically happens
when a node is deleted and committed without updating its parent.
The parent revision indicates it should be present, but this node's
revision states otherwise. */
svn_wc__db_status_not_present,
/* This node is known, but its information is incomplete. Generally,
it should be treated similar to the other missing status values
until some (later) process updates the node with its data.
When the incomplete status applies to a directory, the list of
children and the list of its base properties as recorded in the
working copy do not match their working copy versions.
The update editor can complete a directory by using a different
update algorithm. */
svn_wc__db_status_incomplete,
/* The BASE node has been marked as deleted. Only used as an internal
status in wc_db.c and entries.c. */
svn_wc__db_status_base_deleted
} svn_wc__db_status_t;
/* Lock information. We write/read it all as one, so let's use a struct
for convenience. */
typedef struct svn_wc__db_lock_t {
/* The lock token */
const char *token;
/* The owner of the lock, possibly NULL */
const char *owner;
/* A comment about the lock, possibly NULL */
const char *comment;
/* The date the lock was created */
apr_time_t date;
} svn_wc__db_lock_t;
/* Structure holding the size and timestamp values for a file. */
typedef struct svn_wc__db_fileinfo_t {
/* The time the file was last modified. */
apr_time_t mtime;
/* The size of this file. */
svn_filesize_t size;
} svn_wc__db_fileinfo_t;
/* ### NOTE: I have not provided docstrings for most of this file at this
### point in time. The shape and extent of this API is still in massive
### flux. I'm iterating in public, but do not want to doc until it feels
### like it is "Right".
*/
/* ### where/how to handle: text_time, locks, working_size */
/*
@defgroup svn_wc__db_admin General administrative functions
@{
*/
/* Open a working copy administrative database context.
This context is (initially) not associated with any particular working
copy directory or working copy root (wcroot). As operations are performed,
this context will load the appropriate wcroot information.
The context is returned in DB.
CONFIG should hold the various configuration options that may apply to
the administrative operation. It should live at least as long as the
RESULT_POOL parameter.
When OPEN_WITHOUT_UPGRADE is TRUE, then the working copy databases will
be opened even when an old database format is found/detected during
the operation of a wc_db API). If open_without_upgrade is FALSE and an
upgrade is required, then SVN_ERR_WC_UPGRADE_REQUIRED will be returned
from that API.
Passing TRUE will allow a bare minimum of APIs to function (most notably,
the temp_get_format() function will always return a value) since most of
these APIs expect a current-format database to be present.
If ENFORCE_EMPTY_WQ is TRUE, then any databases with stale work items in
their work queue will raise an error when they are opened. The operation
will raise SVN_ERR_WC_CLEANUP_REQUIRED. Passing FALSE for this routine
means that the work queue is being processed (via 'svn cleanup') and all
operations should be allowed.
The DB will be closed when RESULT_POOL is cleared. It may also be closed
manually using svn_wc__db_close(). In particular, this will close any
SQLite databases that have been opened and cached.
The context is allocated in RESULT_POOL. This pool is *retained* and used
for future allocations within the DB. Be forewarned about unbounded
memory growth if this DB is used across an unbounded number of wcroots
and versioned directories.
Temporary allocations will be made in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__db_open(svn_wc__db_t **db,
svn_config_t *config,
svn_boolean_t open_without_upgrade,
svn_boolean_t enforce_empty_wq,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Close DB. */
svn_error_t *
svn_wc__db_close(svn_wc__db_t *db);
/* Initialize the SDB with format TARGET_FORMAT for LOCAL_ABSPATH, which should
be a working copy path.
A REPOSITORY row will be constructed for the repository identified by
REPOS_ROOT_URL and REPOS_UUID. Neither of these may be NULL.
A BASE_NODE row will be created for the directory at REPOS_RELPATH at
revision INITIAL_REV.
If INITIAL_REV is greater than zero, then the node will be marked as
"incomplete" because we don't know its children. Contrary, if the
INITIAL_REV is zero, then this directory should represent the root and
we know it has no children, so the node is complete.
### Is there any benefit to marking it 'complete' if rev==0? Seems like
### an unnecessary special case.
DEPTH is the initial depth of the working copy; it must be a definite
depth, not svn_depth_unknown.
Create the working copy with the given TARGET_FORMAT.
Use SCRATCH_POOL for temporary allocations.
*/
svn_error_t *
svn_wc__db_init(svn_wc__db_t *db,
int target_format,
const char *local_abspath,
const char *repos_relpath,
const char *repos_root_url,
const char *repos_uuid,
svn_revnum_t initial_rev,
svn_depth_t depth,
svn_boolean_t store_pristine,
apr_pool_t *scratch_pool);
/* Return the working copy settings *FORMAT_P and *STORE_PRISTINE_P for
LOCAL_ABSPATH in DB.
Use SCRATCH_POOL for temporary allocations.
*/
svn_error_t *
svn_wc__db_get_settings(int *format_p,
svn_boolean_t *store_pristine_p,
svn_wc__db_t *db,
const char *local_abspath,
apr_pool_t *scratch_pool);
/* Compute the LOCAL_RELPATH for the given LOCAL_ABSPATH, relative
from wri_abspath.
The LOCAL_RELPATH is a relative path to the working copy's root. That
root will be located by this function, and the path will be relative to
that location. If LOCAL_ABSPATH is the wcroot directory, then "" will
be returned.
The LOCAL_RELPATH should ONLY be used for persisting paths to disk.
Those paths should not be abspaths, otherwise the working copy cannot
be moved. The working copy library should not make these paths visible
in its API (which should all be abspaths), and it should not be using
relpaths for other processing.
LOCAL_RELPATH will be allocated in RESULT_POOL. All other (temporary)
allocations will be made in SCRATCH_POOL.
This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
option.
*/
svn_error_t *
svn_wc__db_to_relpath(const char **local_relpath,
svn_wc__db_t *db,
const char *wri_abspath,
const char *local_abspath,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Compute the LOCAL_ABSPATH for a LOCAL_RELPATH located within the working
copy identified by WRI_ABSPATH.
This is the reverse of svn_wc__db_to_relpath. It should be used for
returning a persisted relpath back into an abspath.
LOCAL_ABSPATH will be allocated in RESULT_POOL. All other (temporary)
allocations will be made in SCRATCH_POOL.
This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
option.
*/
svn_error_t *
svn_wc__db_from_relpath(const char **local_abspath,
svn_wc__db_t *db,
const char *wri_abspath,
const char *local_relpath,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Compute the working copy root WCROOT_ABSPATH for WRI_ABSPATH using DB.
This function is available when DB is opened with the OPEN_WITHOUT_UPGRADE
option.
*/
svn_error_t *
svn_wc__db_get_wcroot(const char **wcroot_abspath,
svn_wc__db_t *db,
const char *wri_abspath,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* @} */
/* Different kinds of trees
The design doc mentions three different kinds of trees, BASE, WORKING and
ACTUAL: http://svn.apache.org/repos/asf/subversion/trunk/notes/wc-ng-design
We have different APIs to handle each tree, enumerated below, along with
a blurb to explain what that tree represents.
*/
/* @defgroup svn_wc__db_base BASE tree management
BASE is what we get from the server. It is the *absolute* pristine copy.
You need to use checkout, update, switch, or commit to alter your view of
the repository.
In the BASE tree, each node corresponds to a particular node-rev in the
repository. It can be a mixed-revision tree. Each node holds either a
copy of the node-rev as it exists in the repository (if presence =
'normal'), or a place-holder (if presence = 'server-excluded' or 'excluded' or
'not-present').
@{
*/
/* Add or replace a directory in the BASE tree.
The directory is located at LOCAL_ABSPATH on the local filesystem, and
corresponds to <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID> in the
repository, at revision REVISION.
The directory properties are given by the PROPS hash (which is
const char *name => const svn_string_t *).
The last-change information is given by <CHANGED_REV, CHANGED_DATE,
CHANGED_AUTHOR>.
The directory's children are listed in CHILDREN, as an array of
const char *. The child nodes do NOT have to exist when this API
is called. For each child node which does not exists, an "incomplete"
node will be added. These child nodes will be added regardless of
the DEPTH value. The caller must sort out which must be recorded,
and which must be omitted.
This subsystem does not use DEPTH, but it can be recorded here in
the BASE tree for higher-level code to use.
If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
data.
If UPDATE_ACTUAL_PROPS is TRUE, set the properties store NEW_ACTUAL_PROPS
as the new set of properties in ACTUAL. If NEW_ACTUAL_PROPS is NULL or
when the value of NEW_ACTUAL_PROPS matches NEW_PROPS, store NULL in
ACTUAL, to mark the properties unmodified.
If NEW_IPROPS is not NULL, then it is a depth-first ordered array of
svn_prop_inherited_item_t * structures that is set as the base node's
inherited_properties.
If CONFLICT is not NULL, then it describes a conflict for this node. The
node will be record as conflicted (in ACTUAL).
Any work items that are necessary as part of this node construction may
be passed in WORK_ITEMS.
All temporary allocations will be made in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__db_base_add_directory(svn_wc__db_t *db,
const char *local_abspath,
const char *wri_abspath,
const char *repos_relpath,
const char *repos_root_url,
const char *repos_uuid,
svn_revnum_t revision,
const apr_hash_t *props,
svn_revnum_t changed_rev,
apr_time_t changed_date,
const char *changed_author,
const apr_array_header_t *children,
svn_depth_t depth,
apr_hash_t *dav_cache,
svn_boolean_t update_actual_props,
apr_hash_t *new_actual_props,
apr_array_header_t *new_iprops,
const svn_skel_t *conflict,
const svn_skel_t *work_items,
apr_pool_t *scratch_pool);
/* Add a new directory in BASE, whether WORKING nodes exist or not. Mark it
as incomplete and with revision REVISION. If REPOS_RELPATH is not NULL,
apply REPOS_RELPATH, REPOS_ROOT_URL and REPOS_UUID.
Perform all temporary allocations in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__db_base_add_incomplete_directory(svn_wc__db_t *db,
const char *local_abspath,
const char *repos_relpath,
const char *repos_root_url,
const char *repos_uuid,
svn_revnum_t revision,
svn_depth_t depth,
svn_boolean_t insert_base_deleted,
svn_boolean_t delete_working,
svn_skel_t *conflict,
svn_skel_t *work_items,
apr_pool_t *scratch_pool);
/* Add or replace a file in the BASE tree.
The file is located at LOCAL_ABSPATH on the local filesystem, and
corresponds to <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID> in the
repository, at revision REVISION.
The file properties are given by the PROPS hash (which is
const char *name => const svn_string_t *).
The last-change information is given by <CHANGED_REV, CHANGED_DATE,
CHANGED_AUTHOR>.
The checksum of the file contents is given in CHECKSUM. An entry in
the pristine text base is NOT required when this API is called.
If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
data.
If CONFLICT is not NULL, then it describes a conflict for this node. The
node will be record as conflicted (in ACTUAL).
If UPDATE_ACTUAL_PROPS is TRUE, set the properties store NEW_ACTUAL_PROPS
as the new set of properties in ACTUAL. If NEW_ACTUAL_PROPS is NULL or
when the value of NEW_ACTUAL_PROPS matches NEW_PROPS, store NULL in
ACTUAL, to mark the properties unmodified.
Any work items that are necessary as part of this node construction may
be passed in WORK_ITEMS.
Unless KEEP_RECORDED_INFO is set to TRUE, recorded size and timestamp values
will be cleared.
If FILE_WRITER is not NULL, atomically complete installation of the file to
LOCAL_ABSPATH together with updating the DB. If RECORD_FILEINFO is non-zero,
also record the size and timestamp values of the installed file.
All temporary allocations will be made in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__db_base_add_file(svn_wc__db_t *db,
const char *local_abspath,
const char *wri_abspath,
const char *repos_relpath,
const char *repos_root_url,
const char *repos_uuid,
svn_revnum_t revision,
const apr_hash_t *props,
svn_revnum_t changed_rev,
apr_time_t changed_date,
const char *changed_author,
const svn_checksum_t *checksum,
apr_hash_t *dav_cache,
svn_boolean_t delete_working,
svn_boolean_t update_actual_props,
apr_hash_t *new_actual_props,
apr_array_header_t *new_iprops,
svn_boolean_t keep_recorded_info,
svn_boolean_t insert_base_deleted,
const svn_skel_t *conflict,
svn_wc__working_file_writer_t *file_writer,
svn_boolean_t record_fileinfo,
const svn_skel_t *work_items,
apr_pool_t *scratch_pool);
/* Add or replace a symlink in the BASE tree.
The symlink is located at LOCAL_ABSPATH on the local filesystem, and
corresponds to <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID> in the
repository, at revision REVISION.
The symlink's properties are given by the PROPS hash (which is
const char *name => const svn_string_t *).
The last-change information is given by <CHANGED_REV, CHANGED_DATE,
CHANGED_AUTHOR>.
The target of the symlink is specified by TARGET.
If DAV_CACHE is not NULL, sets LOCAL_ABSPATH's dav cache to the specified
data.
If CONFLICT is not NULL, then it describes a conflict for this node. The
node will be record as conflicted (in ACTUAL).
If UPDATE_ACTUAL_PROPS is TRUE, set the properties store NEW_ACTUAL_PROPS
as the new set of properties in ACTUAL. If NEW_ACTUAL_PROPS is NULL or
when the value of NEW_ACTUAL_PROPS matches NEW_PROPS, store NULL in
ACTUAL, to mark the properties unmodified.
Any work items that are necessary as part of this node construction may
be passed in WORK_ITEMS.
All temporary allocations will be made in SCRATCH_POOL.
*/
/* ### KFF: This is an interesting question, because currently
### symlinks are versioned as regular files with the svn:special
### property; then the file's text contents indicate that it is a
### symlink and where that symlink points. That's for portability:
### you can check 'em out onto a platform that doesn't support
### symlinks, and even modify the link and check it back in. It's
### a great solution; but then the question for wc-ng is:
###
### Suppose you check out a symlink on platform X and platform Y.
### X supports symlinks; Y does not. Should the wc-ng storage for
### those two be the same? I mean, on platform Y, the file is just
### going to look and behave like a regular file. It would be sort
### of odd for the wc-ng storage for that file to be of a different
### type from all the other files. (On the other hand, maybe it's
### weird today that the wc-1 storage for a working symlink is to
### be like a regular file (i.e., regular text-base and whatnot).
###
### I'm still feeling my way around this problem; just pointing out
### the issues.
### gjs: symlinks are stored in the database as first-class objects,
### rather than in the filesystem as "special" regular files. thus,
### all portability concerns are moot. higher-levels can figure out
### how to represent the link in ACTUAL. higher-levels can also
### deal with translating to/from the svn:special property and
### the plain-text file contents.
### dlr: What about hard links? At minimum, mention in doc string.
*/
svn_error_t *
svn_wc__db_base_add_symlink(svn_wc__db_t *db,
const char *local_abspath,
const char *wri_abspath,
const char *repos_relpath,
const char *repos_root_url,
const char *repos_uuid,
svn_revnum_t revision,
const apr_hash_t *props,
svn_revnum_t changed_rev,
apr_time_t changed_date,
const char *changed_author,
const char *target,
apr_hash_t *dav_cache,
svn_boolean_t delete_working,
svn_boolean_t update_actual_props,
apr_hash_t *new_actual_props,
apr_array_header_t *new_iprops,
svn_boolean_t keep_recorded_info,
svn_boolean_t insert_base_deleted,
const svn_skel_t *conflict,
const svn_skel_t *work_items,
apr_pool_t *scratch_pool);
/* Create a node in the BASE tree that is present in name only.
The new node will be located at LOCAL_ABSPATH, and correspond to the
repository node described by <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID>
at revision REVISION.
The node's kind is described by KIND, and the reason for its absence
is specified by STATUS. Only these values are allowed for STATUS:
svn_wc__db_status_server_excluded
svn_wc__db_status_excluded
If CONFLICT is not NULL, then it describes a conflict for this node. The
node will be record as conflicted (in ACTUAL).
Any work items that are necessary as part of this node construction may
be passed in WORK_ITEMS.
All temporary allocations will be made in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__db_base_add_excluded_node(svn_wc__db_t *db,
const char *local_abspath,
const char *repos_relpath,
const char *repos_root_url,
const char *repos_uuid,
svn_revnum_t revision,
svn_node_kind_t kind,
svn_wc__db_status_t status,
const svn_skel_t *conflict,
const svn_skel_t *work_items,
apr_pool_t *scratch_pool);
/* Create a node in the BASE tree that is present in name only.
The new node will be located at LOCAL_ABSPATH, and correspond to the
repository node described by <REPOS_RELPATH, REPOS_ROOT_URL, REPOS_UUID>
at revision REVISION.
The node's kind is described by KIND, and the reason for its absence
is 'svn_wc__db_status_not_present'.
If CONFLICT is not NULL, then it describes a conflict for this node. The
node will be record as conflicted (in ACTUAL).
Any work items that are necessary as part of this node construction may
be passed in WORK_ITEMS.
All temporary allocations will be made in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__db_base_add_not_present_node(svn_wc__db_t *db,
const char *local_abspath,
const char *repos_relpath,
const char *repos_root_url,
const char *repos_uuid,
svn_revnum_t revision,
svn_node_kind_t kind,
const svn_skel_t *conflict,
const svn_skel_t *work_items,
apr_pool_t *scratch_pool);
/* Remove a node and all its descendants from the BASE tree. This can
be done in two modes:
* Remove everything, scheduling wq operations to clean up
the working copy. (KEEP_WORKING = FALSE)
* Bump things to WORKING, so the BASE layer is free, but the working
copy unmodified, except that everything that was visible from
BASE is now a copy of what it used to be. (KEEP_WORKING = TRUE)
This operation *installs* workqueue operations to update the local
filesystem after the database operation.
To maintain a consistent database this function will also remove
any working node that marks LOCAL_ABSPATH as base-deleted. If this
results in there being no working node for LOCAL_ABSPATH then any
actual node will be removed if the actual node does not mark a
conflict.
If MARK_NOT_PRESENT or MARK_EXCLUDED is TRUE, install a marker
of the specified type at the root of the now removed tree, with
either the specified revision (or in case of SVN_INVALID_REVNUM)
the original revision.
If CONFLICT and/or WORK_ITEMS are passed they are installed as part
of the operation, after the work items inserted by the operation
itself.
*/
svn_error_t *
svn_wc__db_base_remove(svn_wc__db_t *db,
const char *local_abspath,
svn_boolean_t keep_working,
svn_boolean_t mark_not_present,
svn_boolean_t mark_excluded,
svn_revnum_t marker_revision,
svn_skel_t *conflict,
svn_skel_t *work_items,
apr_pool_t *scratch_pool);
/* Retrieve information about a node in the BASE tree.
For the BASE node implied by LOCAL_ABSPATH from the local filesystem,
return information in the provided OUT parameters. Each OUT parameter
may be NULL, indicating that specific item is not requested.
If there is no information about this node, then SVN_ERR_WC_PATH_NOT_FOUND
will be returned.
The OUT parameters, and their "not available" values are:
STATUS n/a (always available)
KIND n/a (always available)
REVISION SVN_INVALID_REVNUM
REPOS_RELPATH NULL (caller should scan up)
REPOS_ROOT_URL NULL (caller should scan up)
REPOS_UUID NULL (caller should scan up)
CHANGED_REV SVN_INVALID_REVNUM
CHANGED_DATE 0
CHANGED_AUTHOR NULL
DEPTH svn_depth_unknown
CHECKSUM NULL
TARGET NULL
LOCK NULL
HAD_PROPS FALSE
PROPS NULL
UPDATE_ROOT FALSE
If the STATUS is normal, the REPOS_* values will be non-NULL.
If DEPTH is requested, and the node is NOT a directory, then the
value will be set to svn_depth_unknown. If LOCAL_ABSPATH is a link,
it's up to the caller to resolve depth for the link's target.
If CHECKSUM is requested, and the node is NOT a file, then it will
be set to NULL.
If TARGET is requested, and the node is NOT a symlink, then it will
be set to NULL.
*PROPS maps "const char *" names to "const svn_string_t *" values. If
the base node is capable of having properties but has none, set
*PROPS to an empty hash. If its status is such that it cannot have
properties, set *PROPS to NULL.
If UPDATE_ROOT is requested, set it to TRUE if the node should only
be updated when it is the root of an update (e.g. file externals).
All returned data will be allocated in RESULT_POOL. All temporary
allocations will be made in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__db_base_get_info(svn_wc__db_status_t *status,
svn_node_kind_t *kind,
svn_revnum_t *revision,
const char **repos_relpath,
const char **repos_root_url,
const char **repos_uuid,
svn_revnum_t *changed_rev,
apr_time_t *changed_date,
const char **changed_author,
svn_depth_t *depth,
const svn_checksum_t **checksum,
const char **target,
svn_wc__db_lock_t **lock,
svn_boolean_t *had_props,
apr_hash_t **props,
svn_boolean_t *update_root,
svn_wc__db_t *db,
const char *local_abspath,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Structure returned by svn_wc__db_base_get_children_info. Only has the
fields needed by the adm crawler. */
struct svn_wc__db_base_info_t {
svn_wc__db_status_t status;
svn_node_kind_t kind;
svn_revnum_t revnum;
const char *repos_relpath;
const char *repos_root_url;
svn_depth_t depth;
svn_boolean_t update_root;
svn_wc__db_lock_t *lock;
};
/* Return in *NODES a hash mapping name->struct svn_wc__db_base_info_t for
the children of DIR_ABSPATH at op_depth 0.
*/
svn_error_t *
svn_wc__db_base_get_children_info(apr_hash_t **nodes,
svn_wc__db_t *db,
const char *dir_abspath,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Set *PROPS to the properties of the node LOCAL_ABSPATH in the BASE tree.
*PROPS maps "const char *" names to "const svn_string_t *" values.
If the node has no properties, set *PROPS to an empty hash.
*PROPS will never be set to NULL.
If the node is not present in the BASE tree (with presence 'normal'
or 'incomplete'), return an error.
Allocate *PROPS and its keys and values in RESULT_POOL.
*/
svn_error_t *
svn_wc__db_base_get_props(apr_hash_t **props,
svn_wc__db_t *db,
const char *local_abspath,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Return a list of the BASE tree node's children's names.
For the node indicated by LOCAL_ABSPATH, this function will return
the names of all of its children in the array CHILDREN. The array
elements are const char * values.
If the node is not a directory, then SVN_ERR_WC_NOT_WORKING_COPY will
be returned.
All returned data will be allocated in RESULT_POOL. All temporary
allocations will be made in SCRATCH_POOL.
*/
svn_error_t *
svn_wc__db_base_get_children(const apr_array_header_t **children,
svn_wc__db_t *db,
const char *local_abspath,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Set the dav cache for LOCAL_ABSPATH to PROPS. Use SCRATCH_POOL for
temporary allocations. */
svn_error_t *
svn_wc__db_base_set_dav_cache(svn_wc__db_t *db,
const char *local_abspath,
const apr_hash_t *props,
apr_pool_t *scratch_pool);
/* Retrieve the dav cache for LOCAL_ABSPATH into *PROPS, allocated in
RESULT_POOL. Use SCRATCH_POOL for temporary allocations. Return
SVN_ERR_WC_PATH_NOT_FOUND if no dav cache can be located for
LOCAL_ABSPATH in DB. */
svn_error_t *
svn_wc__db_base_get_dav_cache(apr_hash_t **props,
svn_wc__db_t *db,
const char *local_abspath,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Recursively clear the dav cache for LOCAL_ABSPATH. Use
SCRATCH_POOL for temporary allocations. */
svn_error_t *
svn_wc__db_base_clear_dav_cache_recursive(svn_wc__db_t *db,
const char *local_abspath,
apr_pool_t *scratch_pool);
/* Set LOCK_TOKENS to a hash mapping const char * full URLs to const char *
* lock tokens for every base node at or under LOCAL_ABSPATH in DB which has
* such a lock token set on it.
* Allocate the hash and all items therein from RESULT_POOL. */
svn_error_t *
svn_wc__db_base_get_lock_tokens_recursive(apr_hash_t **lock_tokens,
svn_wc__db_t *db,
const char *local_abspath,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* ### anything else needed for maintaining the BASE tree? */
/* @} */
/* @defgroup svn_wc__db_pristine Pristine ("text base") management
@{
*/
/* Set *PRISTINE_ABSPATH to the path under WCROOT_ABSPATH that will be
used by the pristine text identified by SHA1_CHECKSUM. The file
need not exist.
*/
svn_error_t *
svn_wc__db_pristine_get_future_path(const char **pristine_abspath,
const char *wcroot_abspath,
const svn_checksum_t *sha1_checksum,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* If requested set *CONTENTS to a readable stream that will yield the pristine
text identified by SHA1_CHECKSUM (must be a SHA-1 checksum) within the WC
identified by WRI_ABSPATH in DB. If the pristine is present in the store,
but dehydrated, set *CONTENTS to NULL.
If requested set *SIZE to the size of the pristine stream in bytes,
Even if the pristine text is removed from the store while it is being
read, the stream will remain valid and readable until it is closed.
Allocate the stream in RESULT_POOL. */
svn_error_t *
svn_wc__db_pristine_read(svn_stream_t **contents,
svn_filesize_t *size,
svn_wc__db_t *db,
const char *wri_abspath,
const svn_checksum_t *sha1_checksum,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Baton for svn_wc__db_pristine_install */
typedef struct svn_wc__db_install_data_t
svn_wc__db_install_data_t;
/* Open a writable stream to a temporary text base, ready for installing
into the pristine store. Set *STREAM to the opened stream. The temporary
file will have an arbitrary unique name. Return as *INSTALL_DATA a baton
for either installing or removing the file
Arrange that, on stream closure, *MD5_CHECKSUM and *SHA1_CHECKSUM will be
set to the MD-5 and SHA-1 checksums respectively of that file.
MD5_CHECKSUM and/or SHA1_CHECKSUM may be NULL if not wanted.
The contents of the pristine will be saved to disk if HYDRATED is true or
if the WC version or configuration doesn't allow dehydrated pristines.
Allocate the new stream, path and checksums in RESULT_POOL.
*/
svn_error_t *
svn_wc__db_pristine_prepare_install(svn_stream_t **stream,
svn_wc__db_install_data_t **install_data,
svn_checksum_t **sha1_checksum,
svn_checksum_t **md5_checksum,
svn_wc__db_t *db,
const char *wri_abspath,
svn_boolean_t hydrated,
apr_pool_t *result_pool,
apr_pool_t *scratch_pool);
/* Install the file created via svn_wc__db_pristine_prepare_install() into
the pristine data store, to be identified by the SHA-1 checksum of its
contents, SHA1_CHECKSUM, and whose MD-5 checksum is MD5_CHECKSUM. */
svn_error_t *
svn_wc__db_pristine_install(svn_wc__db_install_data_t *install_data,
const svn_checksum_t *sha1_checksum,
const svn_checksum_t *md5_checksum,