1 A Functional Specification for "Locking"
3 This document describes the features of a new locking system for
4 Subversion. It attempts to avoid specific design and implementation
5 choices wherever possible.
7 A separate document will outline a proposed implementation for this
14 1. Provide a mechanism to ensure that a user has exclusive
15 rights to commit changes to a file from a particular working
18 2. Provide a communication mechanism to decrease the chances of
19 a user wasting time working on a file locked by someone else.
23 We recommend implementing a lightweight locking mechanism.
24 Teach the server to track and enforce exclusive write locks.
25 Provide means for repository administrators to manipulate locks
26 and enforce locking policies. Provide a series of client
27 commands for creating, removing, breaking, and stealing locks.
28 Lastly, create a new property to communicate that a path must be
29 locked before committing.
31 Note that Subversion is still an inherently concurrent system.
32 The ability to lock paths is optional, and can even be prevented
33 by the repository administrator.
36 II. New Client Behaviors
40 1. Definition of "lock"
42 A lock grants one user the exclusive right to change a
43 certain file from a specific working copy.
47 If a file is locked, the owner of the lock has the exclusive
48 right to change the file's text and properties, to delete the
49 file, and to move the file.
51 The restriction on moving or deleting a locked file is a
52 restriction on changing its full path name in any way,
53 including by moving or renaming or deleting any of its
56 (A locked file can still be read and copied, and any copy of it
57 will not automatically be locked.)
59 B. Client requirements for locking
63 It must be possible to declare that certain files absolutely
64 require locks before committing.
66 2. Communication system
68 There must be a system in place that tells users when locking
69 is necessary; ideally, it would prevent a user from
70 beginning work in the first place. If a lock already exists,
71 a user should be able to see who created it, when, and why.
73 C. Lock manipulation via client
75 1. Lock Representations in the Working Copy
77 In order to associate a lock with a particular working copy,
78 the working copy must store some representation of the lock,
79 and occasionally synchronize this with the repository's
82 Because locks can be broken or stolen, it is possible for a
83 working copy's lock representation to become "defunct". A
84 defunct lock cannot be used or released--it is useless and is
85 cleaned up when the client next synchronizes with the server.
89 This section defines specific terminology to describe the
90 kind of lock-related actions that a Subversion client can
97 - A user must be authenticated to the server
98 - The file must not already be locked.
100 Upon successfully locking a file, the working copy retains
101 a representation of the lock.
105 To make use of a lock, two forms of authentication must be
106 provided to the server:
108 - The authenticated username that owns the lock
109 - A non-defunct lock representation
111 If either of these forms of authentication are missing or
112 incorrect, the lock cannot be used.
114 1. Using a lock to Commit
116 Upon successful commit, a locked file is released by
117 default. The Subversion client provides an option to
118 retain the lock after commit.
122 After successful release, the representation of the lock
123 is removed from both the working copy and the server.
127 "Breaking" a lock is a means of releasing a lock when:
129 - The authenticated username is not the same as the
131 - The working-copy lock representation is unavailable.
133 (e.g. Harry locks file foo and is suddenly laid off.
134 Sally decides to clean up his mess and breaks the lock on
135 foo, without using Harry's username or lock
140 "Stealing" a lock is a means of creating a lock when:
142 - The file is locked by you, but you don't have a
143 representation of the lock in your current working
145 - The file is locked by someone else.
147 In order to steal a lock, a user must be authenticated to
150 (e.g. Harry locks file foo and goes on vacation. Sally
151 needs to make changes to foo and obtains a lock on foo by
152 stealing Harry's lock, without using Harry's username or
153 lock representation.)
155 e. Discovering/examining locks
157 The Subversion client provides interfaces to answer the
160 - Ask working copy to display all lock representations
162 - Examine a particular lock representation
164 - Ask server to list all locks underneath a given path,
165 optionally displaying all attributes of the locks
166 (Possibly able to restrict this query to a single user)
168 - Ask server whether a given file is locked
171 III. New Server Behaviors
175 1. Definition of a lock
177 As noted in section II.A.1, a lock grants one user the
178 exclusive right to change a certain file from a specific
181 2. Attributes of a lock
183 A lock is an immutable data object. It must contain: a
184 unique identifier, the path being locked, the username that
185 owns the lock, and a creation timestamp. A lock comment is
190 See II.A.2 for details. The server will enforce these
195 The Subversion server holds the master list of all locks for a
196 repository. It responds to client requests to create, release,
197 break and steal locks.
199 When a client asks about a lock, the server reports whether the
200 lock is valid or is defunct (i.e. the server no longer has a
201 lock corresponding to the lock representation in question).
202 When a client creates or steals a lock, the server returns a
207 During a commit, the server checks for locks the same way that
208 it checks for out-of-dateness.
210 As each changed path arrives, the server checks to see if the
211 path is locked. If the path is locked, the server makes certain
212 that the correct username and lock representation have been
213 presented by the client. If not, the entire commit is rejected
216 In addition, the server re-checks and enforces locks during
219 D. Configurable Mechanisms
221 The server provides mechanisms to enable diverse administrative
222 locking policies, including:
224 1. Allow or disallow creating, breaking, and stealing of locks
225 based on specific criteria (e.g. username, path, etc.)
227 2. Perform tasks after creating, breaking, and stealing a lock
228 (e.g. sending email, collecting stats, etc.)
230 E. Lock manipulation with svnadmin
234 svnadmin provides interfaces to answer the following
237 - List all locks in a repository underneath a given path
238 (Possibly able to restrict this query to a single user)
240 - Ask whether a given repository file is locked
242 2. Unconditional release of locks
244 svnadmin provides an interface to unconditionally release a