SVNKit relies on correct editor calls sequence, any sequence rule violation can lead to unexpected consequencies.
addDir call implies entering into the directory, you shouldn't call openDir after it like in this example: http://wiki.svnkit.com/Committing_To_A_Repository#Example_On_Using_ISVNEditor_In_A_Commit_Operation There're other often mistakes: 1. For every openDir, addDir and even openRoot call there should be one closeDir call. 2. For directory changeDirProperty should be called before other changes (before deleteEntry, addFile, openDir and so on) 3. For file changeFileProperty should be called before applyTextDelta and other delta calls. 4. The sequence should end with either closeEdit (should be called at top-level, after closeDir corresponding to openRoot) or abortEdit (can be called everywhere). Note: this is true even if your own exception is thrown somewhere in the middle, but if it is an exception that is thrown from editor calls (they throw SVNException), abortEdit() is not necessary. I'm not sure that "2" and "3" are strict, but in the practice I meet this order. -- Dmitry Pavlenko, TMate Software, http://subgit.com/ - git-svn bridge В сообщении от 19 September 2012 16:35:27 автор Don Payette написал: > Thanks, Dmitri. I've moved down to my next problem, now. :-) > > I'm doing this sequence: > > editor.addDir 'COBOL74' > Do checkPath on file 'COBOL74/FD_D000AUD1.c74_m' > editor.openDir 'COBOL74' > editor.addFile 'COBOL74/FD_D000AUD1.c74_m' > editor.applyTextDelta 'COBOL74/FD_D000AUD1.c74_m' > deltaGenerator.sendDelta 'COBOL74/FD_D000AUD1.c74_m' > editor.closeFile 'COBOL74/FD_D000AUD1.c74_m' > > And I get the following exception. It looks like it is putting my > directory node on twice "COBOL74/COBOL74" instead of just "COBOL74". > > org.tmatesoft.svn.core.SVNException: svn: E160013: File not found: > transaction '11-g',path/COBOL74/COBOL74/FD_D000AUD1.c74_m' > svn: E160013: '/FSS19test/!svn/wrk/eef0ddde-3901-0010-8918-b15082b6a7fd/ > COBOL74/COBOL74/FD_D000AUD1.c74_m' path not found: 404 Not Found ( > http://myserver.com) > > at > org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.ja > va:64) > > at > org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.ja > va:51) > > at > org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConn > ection.java:657) > > at > org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConn > ection.java:290) > > at > org.tmatesoft.svn.core.internal.io.dav.DAVConnection.performHttpRequest(DAV > Connection.java:716) > > at > org.tmatesoft.svn.core.internal.io.dav.DAVConnection.doPutDiff(DAVConnectio > n.java:505) > > at > org.tmatesoft.svn.core.internal.io.dav.DAVCommitEditor.closeFile(DAVCommitE > ditor.java:335) > > Don Payette > FSS19 Production Management > Contractor for the GSA FAME Program > 2345 Crystal Dr. Suite 250, Rm 208A. > (w) 703-236-3523 > (c) 571-305-0105 > (h) 479-437-3084 - telework Monday and Wednesday > Internal only extension 7706 > > On Wed, Sep 19, 2012 at 9:40 AM, Dmitry Pavlenko > <pavle...@tmatesoft.com>wrote: > > Hello, > > > > Construction of a second repository object for checkPath() calls is the > > best thing you can do for > > your case. > > > > repository.getCommitEditor(msg, null) call starts a transaction and this > > repository object can't be > > used until the transaction is finished (repository.closeEdit()) or rolled > > back > > (repository.abortEdit()). > > > > The same is true about other SVNRepository methods. even read only. For > > example you can't use the > > same 'repository' object in editors or callbacks that you pass to > > repository.update(), > > repository.log() or any other SVNRepository methods. > > > > -- > > Dmitry Pavlenko, > > TMate Software, > > http://subgit.com/ - git-svn bridge > > > > > Well, so I'm getting this error: > > > > > > Exception in thread "main" java.lang.Error: SVNRepository methods are > > > not reenterable > > > > > > at > > > > > > org.tmatesoft.svn.core.io.SVNRepository.lock(SVNRepository.java:2820) > > > > > > at > > > > > > org.tmatesoft.svn.core.io.SVNRepository.lock(SVNRepository.java:2811) > > > > > > at > > > > org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRe > > po > > > > > sitory.java:1011) at > > > > org.tmatesoft.svn.core.internal.io.dav.DAVRepository.checkPath(DAVReposit > > or > > > > > y.java:219) > > > > > > What I'm trying to do is implement something similar to and import. I > > > > have > > > > > a file that contains a list of files that need to be > > > put in the repository. I would like to do them all with one revision. > > > > So, > > > > > I have the following code: > > > > > > repository = SVNRepositoryFactory.create (url); > > > latestRevision = repository.getLatestRevision(); > > > ISVNEditor editor = repository.getCommitEditor(msg, null); > > > editor.openRoot(-1); > > > while ((rec = buffReader.readLine()) != null) { > > > > > > // Pull the filename out of rec. > > > // Construct the following variables > > > // dirPath = "Folder" > > > // filePath = "Folder/Filename.txt" > > > // modifiedContents = <a byte array containing contents of file> > > > nodeKind = repository.checkPath (dirPath, -1); // "Folder" <== This > > > > dies > > > > > immediately > > > > > > if (nodeKind == SVNNodeKind.NONE) { > > > > > > editor.addDir (dirPath, null, -1); > > > > > > nodeKind = repository.checkPath(filePath, -1); > > > boolean fileIsInRepository = (nodeKind==SVNNodeKind.FILE); > > > if (fileIsInRepository) { > > > > > > SVNProperties props = new SVNProperties(); > > > repository.getFile(filePath > > > > > > ,-1 > > > ,props > > > ,existingStream > > > ); > > > > > > contents = existingStream.toByteArray(); > > > // contents now has the data from the repository > > > } > > > > > > } > > > editor.openDir (dirPath, -1); > > > editor.addFile (filePath, null, -1); > > > editor.applyTextDelta (filePath, null); > > > SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator > > > > > > (diffWindowSize); > > > > > > String checksum = null; > > > if (fileIsInRepository) { > > > > > > checksum = deltaGenerator.sendDelta(filePath > > > > > > ,new ByteArrayInputStream (contents) > > > ,0 > > > ,new ByteArrayInputStream (modifiedContents) > > > ,editor > > > ,true // generateChecksum > > > ); > > > > > > } else { > > > > > > checksum = deltaGenerator.sendDelta (filePath > > > > > > ,new ByteArrayInputStream (modifiedContents) > > > ,editor > > > ,true // generateChecksum > > > ); > > > > > > } > > > // Multiple editor.changeFileProperty calls > > > editor.closeFile (filePath, checksum); > > > editor.closeDir(); > > > > > > } // while > > > > > > editor.closeDir(); > > > editor.closeEdit(); > > > latestRevision = repository.getLatestRevision(); > > > > > > > > > One idea I had was to construct a second repository object > > > (inquiryRepository) that is > > > just used for my "checkPath" calls. > > > > > > But I thought I would check with the group first. Is there any info > > > written up somewhere > > > that talks about re-entrance and its implications? > > > > > > Don Payette > > > FSS19 Production Management > > > Contractor for the GSA FAME Program > > > 2345 Crystal Dr. Suite 250, Rm 208A. > > > (w) 703-236-3523 > > > (c) 571-305-0105 > > > (h) 479-437-3084 - telework Monday and Wednesday > > > Internal only extension 7706