10 * Open items / discussion points
13 * Prerequisites for a good wc implementation
15 * Implementation proposals for
16 - metadata storage/access abstraction
17 - BASE tree storage/access abstraction
18 - WORKING tree storage/access abstraction
19 - TARGET & MERGE-END tree storage/access abstraction
20 - transactional manipulation API proposal
21 - delta-application algorithm
22 (in light of metadata, tree and textual conflicts)
29 The working copy library has traditionally been a complex piece of
30 machinery and libsvn_wc-1.0 (wc-1.0 hereafter) was more a result of
31 evolution than it was a result of design. This can't be said to be
32 anybody's fault as much as it was unawareness of the developers at
33 the time with the problem(s) inherent to versioning trees instead of
34 files (as was the usual context within CVS). As a result, the WC
35 has been one of the most fragile areas of the Subversion versioning
38 The wc is where a large number of issues come together which can
39 be considered separate issues in the remainder of the system, or
40 don't have any effect on the rest of the system at all. The following
43 * Different behaviours required by different use-cases (users)
44 For example: some users want mtime's at checkout time
45 to be the checkout time, some want it to be the historical
46 value at check-in time (and others want different variants).
47 * Different filesystems behave differently, yet Subversion
48 is a cross platform tool and tries to behave the same on all
49 filesystems (timestamp resolution may be an example of this).
51 When considering the wc-1.0 design, one finds that there are a lot
52 of situations where the exact state of the versioned tree isn't
53 defined. When explicitly considering which trees relate to the
54 working copy at one time or another, the following trees can be
57 * BASE: The tree as it was in unmodified form
58 * WORKING: The tree as it is in modified form, based on the
59 administrative information recorded by the transforming
61 Note: This tree will -as far as text bases goes- generally
62 overlap with BASE, but isn't required to;
63 e.g. "add-with-history"
64 * ACTUAL: The tree as it is in modified form on the local disk.
65 This tree may differ from WORKING when having been modified
66 with non-Subversion transforming commands (such as plain 'rm').
68 In the context of the 'svn update' command:
70 * BASE-TARGET: The tree to which BASE is being updated and for
71 which the changes w.r.t. BASE are integrated into
73 * WORKING-TARGET, ACTUAL-TARGET: Trees in which the above mentioned
74 changes have been integrated, but which haven't "gone live" yet;
75 these trees generally represent "in transition" or "intermediary"
76 state with the intent to become the final tree.
78 Additionally, three more trees may be related to the working copy
79 when considering the 'svn merge' command:
81 * START: The tree used as the base state for the 'merge' command
82 * END: The tree used as the ending state for the 'merge' command
83 The difference between these trees will be merged into the
84 WORKING and ACTUAL trees.
86 In the following example 10 == START and 15 == END:
87 $ svn merge -r10:15 http://svn.example.com/svn/ .
89 Please note that the WORKING-TARGET and ACTUAL-TARGET trees also
90 apply to 'svn merge' as they can result in 'add with history' schedules,
91 which will place text bases in the WORKING-TARGET tree. Also note
92 that -since merge is by definition an 'edit' operation- the BASE and
93 BASE-TARGET trees are not concerned with a merge.
95 ###EHU: To which trees do BASE and TARGET refer when we're in a subdir
96 of a replaced tree? And which trees do they refer to in a subdir of
97 a replaced tree which itself is replaced? (Preliminary answer: the
98 base in a replaced subdir should probably be the base as defined by
99 the parent which got copied in, not the base as was deleted, because
100 otherwise it won't be possible to delete files from the replaced subdir:
101 there would be no way to express a deletion against the new dir.)
109 From this requirement, a number of additional ones follow:
110 - Very explicit tree state management; clear difference between
111 each of the 5 states we may be looking at
112 - It must be "fun" to code wc-ng enhancements
114 (Note: a trade off may be required for 'checkout' vs 'status' speed)
115 * Cross-node-type working copy changes
117 The model should make it easy to support
118 - central vs local metadata storage
119 - Last modified timestamp behaviours
120 - .svn-less working copy subtrees
121 - different file-changed detection schemes
122 (e.g. full tree scan as in wc-1.0 as well as 'p4 edit')
123 * Graceful (defined) fallback for non-supported operations
124 When a checkout tries to create a symlink on an OS which supports
125 them, on a filesystem which doesn't, we should cope without
126 canceling the complete checkout. Same for marking metadata read-only.
127 * Gracefully handle symlinks in relation to any special-handling of
128 files (don't special-handle symlinks!)
129 * Clear/reparable tree state
130 Other than our current loggy system, I mean here: "there is a command
131 by which the user can restart the command he/she last issued and
132 Subversion will help complete that command", which differs from our
133 loggy system in the way that it will return the working copy to a
134 defined (but to the user unknown) state.
135 * Transactional/ repairable tree state (with which I mean something
136 which achieves the same as our loggy system, but better).
137 * Case sensitive filesystem aware / resilient
138 * Working copy stability; a number of scenario's with switch and
139 update obstructions used to leave the working copy unrecoverable
140 * Client side 'true renames' support where one side can't be committed
141 without the other (relates to issue #876)
142 * Change detection should become entirely internal to libsvn_wc (referring
143 to the fact that libsvn_client currently calls svn_wait_for_timestamps()),
144 even though under 'use-commit-times=yes', this waiting is
146 * Last-modified recording as a preparation for solving issue #1256 and
147 as defined in this mail, also linked from the issue:
148 http://svn.haxx.se/dev/archive-2006-10/0193.shtml
149 * Representing "this node is part of a replaced-with-history tree and
150 I'm *not* in the replacement tree" as well as "... and I'm deleted
151 from the replacement tree" [issues #1962 and #2690]
154 Would-be-very-nice-to-have's
155 ============================
157 * Multiple users with a single working copy (aka shared working copy)
158 * Ending up with an implementation which can use current WCs
160 * Working copies/ metadata storages without local storage of text-bases
161 (other than a few cached ones)
170 Open items / discussion points
171 ==============================
173 * Files changed during the window "sent as part of commit" to
174 "post commit wc processing"; these are currently explicitly
175 supported. Do we want to keep this support (at the cost of speed)?
176 * Single working copy lock. Should we have one lock which locks the
177 entire working copy, disabling any parallel actions on disjoint
178 parts of the working copy?
179 * Meta data physical read-only marking (as in wc-1.0). Is it still
180 required, or should it become advisory (ie ignore errors on failure)?
181 * Is issue #1599 a real use-case we need to address?
182 (Loosing and regaining authz access with updates in between)
188 * There's no way to clear unused parts of the entries cache
189 * The code is littered with path calculations in order
190 to access different parts of the working copy (incl. admin areas)
191 * The code is littered with direct accesses to both wc files and
193 * It's not always clear at which time log files are being processed
194 (ie transactions are being committed), meaning it's not always
195 clear at which version of a tree one is looking at: the pre or post
196 transformation versions...
197 * There's no support for nested transactions (even though some
198 functions want to start a new transaction, regardless whether one
200 * It's very hard to determine when an action needs to be written
201 to a transaction or needs to be executed directly
202 * All code assumes local access to admin (meta)data
203 * The transaction system contains non-runnable commands
204 * It's possible to generate combinations of commands, each of which
205 is runnable, but the series isn't
206 * Long if() blocks to sort through all possible states of
207 WORKING, ACTUAL and BASE, without calling it that.
208 * Large if() blocks dealing with the difference between file and
210 * Many special-handling if()s for svn:special files
211 * Manipulation of paths, URLs and base-text paths in 1 function
212 * 'Switchedness' of subdirectories has to be derived from the
213 URLs of the parent and the child, but copied nodes also have
214 non-parent-child source URLs... (confusing)
215 * Duplication of data: a 'copied' boolean and a 'copy_source' URL field
216 * Checkouts fail when checking out files of different casing to a case
217 insensitive filesystem
218 * Checkouts fail when marking working copy admin data as read-only
219 is a non-supported FS operation (VFAT or Samba mounts on Linux have
221 * Obstructed updates leave operations half done; in case of a switch,
222 it's not always possible to switch back (because the switch itself
223 may have left now-unversioned items behind)
224 * Directories which have their own children merged into them (which happens
225 when merging a directory-add) won't correctly fold the children into
226 schedule==normal, but instead leave them as schedule==add, resulting in
227 a double commit (through HTTP, other RA layers fold the double add, but
228 that's not the point) [see issue #1962]
229 * transaction files (ie log files) are XML files, requiring correct
230 encoding of characters and other values; given the short expected
231 life-time of a log file and the fact that we're almost completely sure
232 the log file is going to be read by the WC library anyway (no interchange
233 problems), this is a waste of processing time
234 * No strict separation between public and internal APIs: many public
235 APIs also used internally, growing arguments which *should* only
236 matter for internal use
244 Strict separation between modules should help keep code focused at one
245 task. Probably some of the required user-specific behaviours can (and
246 should) be hidden behind vtables; for example: setting the file stamp
247 to the commit time, last recorded time or leaving it at the current time
248 should be abstracted from.
250 Access to 'text bases' is another one of these areas: most routines in
251 wc-1.0 don't actually need access to a file (a stream would be fine as
252 well), but since the files are there, availability is assumed.
253 When abstracting all access into streams, the actual administration of
254 the BASE tree can be abstracted from: for all we know the 'tree storage
255 module' may be reading the stream directly off the repository server.
256 [The only module in wc-1.0 which *requires* access to the files is
257 the diff/merge library, because it rewinds to the start of the file
258 during its processing; an operation not supported by streams... and even
259 then, if these routines are passed file handles, they'll be quite
260 happy, meaning they still don't need to know where the text base /
263 In order to keep developers sane, it should be extremely clear at any
264 one time - when operating on a tree - which tree is being operated upon.
266 One way to prevent the lengthy 'if()' blocks currently in wc-1.0, would be
267 to design a dispatch mechanism based on the path-state in WORKING/BASE and the
268 required transformation, dispatching to (small) functions which perform
269 solely that specific task.
274 wc-1.0 assumes the WORKING tree and the ACTUAL tree match, but then
275 goes out of its way to assure they actually do when deemed important.
276 The result is a library which calls stat() a lot more often than need be.
278 One of the possible improvements would be to make wc-ng read all of
279 the ACTUAL state (concentrated in one place, using apr_stat()), keeping
280 it around as long as required, matching it with the WORKING state before
281 operating on either (not only when deemed important!).
283 Working from the ACTUAL tree will also prove to be a step toward clarity
284 regarding the exact tree which is being operated upon.
286 [This suggestion from wc-improvements also applies to wc-ng:]
287 Most operations are I/O bound and have CPU to spare. Consider the virtue
288 of compressed text bases in order to reduce the amount of I/O required.
290 Another idea to reduce I/O is to eliminate atomic-rename-into-place for
291 the metadata part of the working copy: if a file is completely written,
292 store the name of the base-text/prop-text in the entries file, which gets
293 rewritten on most wc-transformations anyway.
296 Cross node type change representation
297 -------------------------------------
300 Flexibility of metadata storage
301 -------------------------------
302 There are 3 known models for storing metadata as requested by different
305 - in-subtree metadata storage (.svn subdir model, as in wc-1.0)
306 - in-'tree root' metadata storage (working copy central)
307 - detached metadata storage (user-central)
309 A solution to implementing each of these behaviours in order to satisfy
310 the wide range of use-cases they solve, would be to define a module
311 interface and implement this interface three times (possibly using vtables).
313 Note that using within-module vtables should be less problematic than our
314 post-1.0 experiences with public vtables (such as the ra-layer vtable):
315 implementation details are allowed to differ between releases (even patch
319 Transaction duration / memory management
320 ----------------------------------------
321 The current pool-based memory management system is very good at managing
322 memory in a transaction-based processing model. In the wc library, a
323 'transaction' often spans more than one call into the library. We either
324 need a sane way to handle this kind of situation using pools, or we may
325 need a different memory management strategy in wc-ng.
327 Working copy stability
328 ----------------------
329 In light of obstructed updates it may not always be desirable to be able
330 to resume the current operation (as currently is the case): in some cases
331 the user may want to abort the operation, in other cases the user may
332 want to resolve the obstruction before re-executing the operation.
334 The solution to this problem could be 'atomic updates': receiving the
335 full working copy transformation, verifying prerequisites, creating
336 replacement files and directories and when all that succeeds, update
339 Full workin' copy unit tests:
340 Exactly because the working copy is such an important part of the
341 Subversion experience *and* because of the 'reputation' of wc-1.0,
342 we need a way to ensure wc-ng completely performs according to our
343 expectations. *The* way to ensure we're able to test the most contrived
344 edge-cases is to develop a full unit testing test-suite while developing
345 wc-ng. This will both be a measure to ensure working copy stability
346 as well as developer sanity: in the early stages of the wc-ng develop-
347 ment process, we'll be able to assess how well the design holds up
348 under more difficult 'weather'.
350 Transactional updates
351 ---------------------
353 .. where 'update' is meant as 'user command', not 'svn update' per se.
355 When applied to files, this can be summarized as:
357 * Receive transformations (update, delete, add) from
361 Prerequisites for a good wc implementation
362 ==========================================
364 These prerequisites are to be addressed, either as definitions
365 in this document, or elsewhere in the subversion (source) tree:
366 * Well defined behaviour for cross-node type updates/merges/..
367 (tree conflicts in particular)
368 * Well defined behaviour for special file handling
369 * Well defined behaviour for operations on locally missing items
371 * Well defined change detection scheme for each of the different
372 last-modified handling strategies
373 * No special handling of symlinks: they are first class versioned objects
374 * Well defined behaviour for property changes on updates/merges/...
375 (this is a problem which may resemble tree conflicts!),
376 including 'svn:' special properties
377 * File name manipulation routines (availability)
378 * File name comparison routines (!) (availability; which compensate
379 for the different ways Unicode characters can be represented
380 [re: NFC/NFD Unicode issue])
381 * URL manipulation routines (availability)
382 * URL comparison routines (availability; which compensate for
383 different ways the same URL can be encoded; see issue #2490)
385 * Agree on a UI to pull in other parts of the same repository
386 (NOT svn:externals) [relates to issue #1167]
387 * Agree on behaviour for update on moved items (relates to issue #1736)
388 * Case-sensitivity detection code to probe working copy filesystem
394 Strict separation must be applied to a number of modules which can be
395 recognised. This will help prevent spaghetti code as in wc-1.0 where
396 one piece of code manipulates paths to a working copy file, its URL
397 *and* the path to the base file.
399 For now, these APIs can be separated:
401 - the public API (presumably not to be used by any internal
402 processing, but presents functionality to working copy users)
403 - tree administration API (required for BASE, TARGET and WORKING)
404 Admins which files are part of the tree, which ones map to
405 which repositories and which textbase / propbase files belong
406 to which local files. [should provide checkpointing functionality
407 for use with transactional tree modifications API]
408 - tree access API (required for BASE, WORKING, TARGET and ACTUAL)
409 Gives access to the content of the nodes in a tree
411 - text bases (for files)
412 - child nodes (for directories)
413 - transactional tree modifications API (applicable to all trees,
414 ###EHU do we provide the same interface to BASE/WORKING as for ACTUAL?)
415 - tree transformation (required for update/switch/merge updating
416 BASE, WORKING and ACTUAL), meaning all of tree changes, file
417 changes and metadata changes
418 - Working-copy changedness detection API
419 - Metadata access API (used by tree administration module(s))
420 - Event hooks (in order to be able to implement different
421 timestamp-setting strategies and possibly more)
423 These APIs will be implemented by these (currently known) modules:
425 - tree administration
429 - transactional tree modifications
431 - tree transformation
433 - working copy changedness detection
434 wc_detect vtable-based API implemented by these modules:
435 * tree crawler ('inspired' by wc-1.0)
436 * tree marker (inspired by 'p4 edit')
437 - metadata access API
438 wc_macc vtable-based API implemented by these modules:
439 * tree spread ('inspired' by wc-1.0)
440 * tree root (storing all metadata in the tree root (think darcs))
441 * central depot (storing 'somewhere' locally, possibly $HOME)
442 this central store would open up the possibility to share
443 text bases/prop bases across checkouts
444 * non-local (retrieving all text and prop-bases from the server,
445 except for a number of cached ones) ###EHU: maybe this is
446 orthogonal to the question where metadata is stored: in all
447 situations, you *could* choose not to keep local copies
448 - Event hooks for the union of all paths in (BASE, WORKING)
449 wc_hook event based single-callback API
450 for e.g. these events:
457 (+ lock can't be acquired [in order to 'unprotect'
458 svn:needs-lock protected files which have been removed
459 from the repository?])
460 to be implemented by these modules:
463 * versioned-execute-perm
464 * versioned-other-unix-perms
465 (* versioned-windows-perms?)
468 Justification for the large number of modules, with a modest number
469 of different APIs is that the problem is really quite complex as shown
470 earlier in this document.
472 Over the years, a large number of use cases have developed around
473 Subversion where different user groups have shown very valid use cases
474 for conflicting behaviours. Presumably, most of these we want to
475 retain. Some of the unimplemented ones have open issues indicating
476 there's at least an active interest. In order to prevent locking out
477 some of the current use cases adding support for the open issues, we
478 need a flexible modularized model. This model will also prevent that
479 we'll end up duplicating lots of code to support the different use cases.
481 Given the assumption of 'little code duplication', the choice for
482 having several modules which implement the same API (vtable) is
486 Implementation proposals
487 ========================
489 Classification of svn_wc_entry_t fields to BASE/WORKING
490 -------------------------------------------------------
492 [Note: This section is mainly to clarify the difference between the BASE
493 and WORKING trees, it's not here to mean that we actually need all these
496 Here are the mappings of all fields from svn_wc_entry_t to the BASE and
499 +-------------------------------+------+---------+
500 | svn_wc_entry_t | BASE | WORKING |
501 +-------------------------------+------+---------+
503 | revision | x | x (2)|
509 | copyfrom_url | | x |
510 | copyfrom_rev | | x |
511 | conflict_old | | x |
512 | conflict_new | | x |
513 | conflict_wrk | | x |
517 | checksum | x | x (2)|
518 | cmt_rev | x | x (2)|
519 | cmt_date | x | x (2)|
520 | cmt_author | x | x (2)|
521 | lock_token | x(6)| |
523 | lock_comment | x | |
524 | lock_creation_date | x | |
525 | has_props | x | x (4)|
526 | has_prop_mods | | = |
527 | cachable_props | x(5)| x (4)|
528 | present_props | x | x (4)|
530 | working_size | | = |
537 +-------------------------------+------+---------+
539 (1) if this one differs from BASE, it must point to the source of a rename
540 (2) for an add-with-history
541 (3) or can we assume single-repository working copies?
542 (4) can differ from BASE for add-with-history
543 (5) why is this a field at all; can't the WC code know?
544 (6) locks apply to in-repository paths, hence BASE
546 The fields marked with '=' are implementation details of internal detection
547 mechanisms, which means they don't belong in the public interface.
549 Fields with no check are to become obsolete. 'schedule', 'copied' and
550 'deleted' can be deducded from the difference between the BASE and WORKING
551 or WORKING and ACTUAL trees. 'incomplete' should become obsolete when the
552 goal of 'atomic updates' can be realised, in which case the tree can't be
553 in an incomplete yet locked state. This would also invalidate issue #1879.