|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Commit transaction only if it creates a certain revisionHi!
I'm writing a tool to synchronize svn repositories. Before the tool commits a transaction to the repository, it gets the revision of the repository. Judging from that revision, it decides if it can commit or not. However, there is the problem that between a call to repos.getLatestRevision() and the call to editor.closeEdit(), a commit from somebody else slips in, and when the transaction is actually committed, the revision information is not true anymore. Is there a way to abort the commit if it would create a revision other than the expected one in the repository? Greetings |
|
|
Re: Commit transaction only if it creates a certain revisionHello Dan,
We thought on your question and my colleague Alex have suggested the following: 1. Client A lock certain dedicated file in repository (e.g. lock.txt) 2. Client A gets revision latest revision 3. If commit is not needed Client A unlocks file lock.txt. 4. If commit is needed client A modifes file lock.txt (it could put latest revision into it) and commits it along with other modifications with the flag "unlockOnCommit" set to 'true'. In case Client B will try to commit while transaction of A still in progress it will fail at point 1, because lock.txt file is locked. Of course, to make this work all clients should follow the same policy of locking same file. Same approach without locking will work, but will not guarantee that first committer (that who started transaction first) will always commit - it only will make sure that there are no concurrent transactions. We didn't try this approach, but it looks more or less sane. In case establishing common commit policy is not applicable, then you may just check latest revision just before calling "closeEdit" (make sure you use another instance of SVNRepository) - this will minimize chances of collision. Do not forget to call abortEdit in case you'd like to abort transaction. Alexander Kitaev, TMate Software, http://svnkit.com/ - Java [Sub]Versioning Library! http://sqljet.com/ - Java SQLite Library! dan0123 wrote: > Hi! > > I'm writing a tool to synchronize svn repositories. Before the tool commits > a > transaction to the repository, it gets the revision of the repository. > Judging > from that revision, it decides if it can commit or not. However, there is > the > problem that between a call to repos.getLatestRevision() and the call to > editor.closeEdit(), a commit from somebody else slips in, and when the > transaction is actually committed, the revision information is not true > anymore. > Is there a way to abort the commit if it would create a revision other than > the > expected one in the repository? > > Greetings --------------------------------------------------------------------- To unsubscribe, e-mail: svnkit-users-unsubscribe@... For additional commands, e-mail: svnkit-users-help@... |
|
|
Re: Commit transaction only if it creates a certain revisionUnfortunately, setting up a common commit policy is not applicable. I've already come up with an extremely complicated solution to my problem that circumvents the use of revision numbers, but I was looking for ways to avoid to implement it. Anyways, thanks for the answer, I guess I'll do it the complicated way now. |
| Free embeddable forum powered by Nabble | Forum Help |