|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Commit more files without workcopy under one revisionHello all,
I commit(update) a file in an repository like this: public class SVNUtils { public static SVNCommitInfo modifyFile(ISVNEditor editor, String dirPath, String filePath, InputStream is, long size) throws SVNException { try { SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator(); editor.openRoot(-1); editor.openDir(dirPath, -1); editor.openFile(filePath, -1); editor.applyTextDelta(filePath, null); String chksm = deltaGenerator.sendDelta(filePath, is, editor, true); editor.textDeltaEnd(filePath); editor.closeFile(filePath, chksm); /* * Closes the directory. */ editor.closeDir(); /* * Closes the root directory. */ editor.closeDir(); return editor.closeEdit(); } catch (SVNException e) { if (editor != null) { try { editor.abortEdit(); } catch (Exception ex) { } } throw e; } } } Now I read a directory (File[] entries = dir.listFiles) and iterate through the entries fileobject and commit the files like this: SVNCommitInfo commitInfo = SVNUtils.modifyFile(editor, dirUrl, urltmp, fileReader, size); The function is working correctly and all files in the readed directory were commited correctly. Now I have the problem, that each file is commited with its own revision. So, how can I commit all the files under only ONE revision? Thanks and best regards, Sandro |
|
|
Re: Commit more files without workcopy under one revisionHello Sandro,
> Now I have the problem, that each file is commited with its own revision. > So, how can I commit all the files under only ONE revision? Just commit all files in a single transaction: public static SVNCommitInfo modifyFiles(ISVNEditor editor, String dirPath, File[] files) throws SVNException { // ... editor.openRoot(-1); editor.openDir(dirPath, -1); for(int i = 0; i < files.length; i++) { String filePath = dirPath + "/" + files[i].getName(); editor.openFile(filePath, -1); editor.applyTextDelta(filePath, null); InputStream is = SVNFileUtil.openFileForReading(is); String chksm = deltaGenerator.sendDelta(filePath, is, editor, true); SVNFileUtil.closeFile(is); editor.textDeltaEnd(filePath); editor.closeFile(filePath, chksm); deltaGenerator.reset(); } editor.closeDir(); editor.closeDir(); return editor.closeEdit(); } In this example it is assumed that: SVNRepository url is "http://host/path/repository/project" - this is the root of the ISVNEditor and dirPath is "dir" (relative to "/project" for which editor was created). Alexander Kitaev, TMate Software, http://svnkit.com/ - Java [Sub]Versioning Library! http://sqljet.com/ - Java SQLite Library! Sandro F wrote: > Hello all, > > I commit(update) a file in an repository like this: > > public class SVNUtils { > > public static SVNCommitInfo modifyFile(ISVNEditor editor, String > dirPath, String filePath, InputStream is, long size) throws SVNException { > try { > SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator(); > > editor.openRoot(-1); > editor.openDir(dirPath, -1); > editor.openFile(filePath, -1); > editor.applyTextDelta(filePath, null); > > String chksm = deltaGenerator.sendDelta(filePath, is, editor, > true); > > editor.textDeltaEnd(filePath); > editor.closeFile(filePath, chksm); > > /* > * Closes the directory. > */ > editor.closeDir(); > /* > * Closes the root directory. > */ > editor.closeDir(); > return editor.closeEdit(); > } catch (SVNException e) { > if (editor != null) { > try { > editor.abortEdit(); > } catch (Exception ex) { > } > } > throw e; > } > } > } > > Now I read a directory (File[] entries = dir.listFiles) and iterate through > the entries fileobject and commit the files like this: > SVNCommitInfo commitInfo = SVNUtils.modifyFile(editor, dirUrl, urltmp, > fileReader, size); > > The function is working correctly and all files in the readed directory were > commited correctly. > > Now I have the problem, that each file is commited with its own revision. > So, how can I commit all the files under only ONE revision? > > > Thanks and best regards, > Sandro --------------------------------------------------------------------- To unsubscribe, e-mail: svnkit-users-unsubscribe@... For additional commands, e-mail: svnkit-users-help@... |
|
|
Re: Commit more files without workcopy under one revisionHello Alexander,
works very good. Thank you! But now I have the problem, that I cannot get a SVNCommitInfo from each file, because a SVNCommitInfo object is only returned, when "return editor.closeEdit();" was called. But I want to show all files, which were updated. How can I solve this? Thanks, Sandro
|
| Free embeddable forum powered by Nabble | Forum Help |