| 67 | | // Diff 開始 |
|---|
| 68 | | expoter.doDiff(SVNURL.parseURIEncoded(urlFrom), |
|---|
| 69 | | DiffExporter.convertRevision(revisionFrom), |
|---|
| 70 | | SVNURL.parseURIEncoded(urlTo), |
|---|
| 71 | | DiffExporter.convertRevision(revisionTo), |
|---|
| 72 | | recursive, |
|---|
| 73 | | diffFile); |
|---|
| 74 | | |
|---|
| 75 | | // Export開始(Diffファイルに則って) |
|---|
| 76 | | expoter.doExportBasedOnDiff(SVNURL.parseURIEncoded(urlTo), |
|---|
| 77 | | DiffExporter.convertRevision(revisionTo), |
|---|
| 78 | | destDir, |
|---|
| 79 | | diffFile); |
|---|
| 80 | | |
|---|
| 81 | | // 指定されたDiffファイルを元に、ファイルパス、および、作成者をファイルに出力 |
|---|
| 82 | | expoter.extractFilePathAndAuthorBasedOnDiff( |
|---|
| 83 | | SVNURL.parseURIEncoded(urlTo), |
|---|
| 84 | | DiffExporter.convertRevision(revisionTo), |
|---|
| 85 | | diffFile, |
|---|
| 86 | | resultFile); |
|---|
| | 76 | // // Export 開始 |
|---|
| | 77 | // expoter.doExport(SVNRepositoryFactory.create(SVNURL.parseURIEncoded(urlTo)), |
|---|
| | 78 | // "", |
|---|
| | 79 | // DiffExporter.convertRevision(revisionTo), |
|---|
| | 80 | // destDir); |
|---|
| | 81 | // |
|---|
| | 82 | // // Diff 開始 |
|---|
| | 83 | // expoter.doDiff(SVNURL.parseURIEncoded(urlFrom), |
|---|
| | 84 | // DiffExporter.convertRevision(revisionFrom), |
|---|
| | 85 | // SVNURL.parseURIEncoded(urlTo), |
|---|
| | 86 | // DiffExporter.convertRevision(revisionTo), |
|---|
| | 87 | // recursive, |
|---|
| | 88 | // diffFile); |
|---|
| | 89 | // |
|---|
| | 90 | // // Export開始(Diffファイルに則って) |
|---|
| | 91 | // expoter.doExportBasedOnDiff(SVNURL.parseURIEncoded(urlTo), |
|---|
| | 92 | // DiffExporter.convertRevision(revisionTo), |
|---|
| | 93 | // destDir, |
|---|
| | 94 | // diffFile); |
|---|
| | 95 | // |
|---|
| | 96 | // // 指定されたDiffファイルを元に、ファイルパス、および、作成者をファイルに出力 |
|---|
| | 97 | // expoter.extractFilePathAndAuthorBasedOnDiff( |
|---|
| | 98 | // SVNURL.parseURIEncoded(urlTo), |
|---|
| | 99 | // DiffExporter.convertRevision(revisionTo), |
|---|
| | 100 | // diffFile, |
|---|
| | 101 | // resultFile); |
|---|
| | 102 | |
|---|
| 116 | | |
|---|
| | 135 | /** |
|---|
| | 136 | * @param url |
|---|
| | 137 | * @param filePath |
|---|
| | 138 | * @param revision |
|---|
| | 139 | * @param destDir |
|---|
| | 140 | * @throws SVNException |
|---|
| | 141 | * @throws IOException |
|---|
| | 142 | */ |
|---|
| | 143 | public void doExport(SVNRepository repository, |
|---|
| | 144 | String filePath, |
|---|
| | 145 | SVNRevision revision, |
|---|
| | 146 | String destDir) |
|---|
| | 147 | throws SVNException, IOException { |
|---|
| | 148 | |
|---|
| | 149 | if(this.authManager == null){ |
|---|
| | 150 | throw new IllegalStateException("Not yet initialized"); |
|---|
| | 151 | } |
|---|
| | 152 | |
|---|
| | 153 | repository.setAuthenticationManager(authManager); |
|---|
| | 154 | |
|---|
| | 155 | long revisionNumber = revision.getNumber(); |
|---|
| | 156 | |
|---|
| | 157 | // ノードタイプ取得 |
|---|
| | 158 | SVNNodeKind nodeKind = repository.checkPath(filePath, revisionNumber); |
|---|
| | 159 | |
|---|
| | 160 | // ファイルの場合 |
|---|
| | 161 | if (nodeKind == SVNNodeKind.FILE) { |
|---|
| | 162 | SVNDirEntry entry = repository.info(filePath, revisionNumber); |
|---|
| | 163 | |
|---|
| | 164 | File targetFile = null; |
|---|
| | 165 | if(filePath != null && filePath.length() != 0){ |
|---|
| | 166 | targetFile = new File(destDir, filePath); |
|---|
| | 167 | System.out.println(destDir + "/" + filePath); |
|---|
| | 168 | } |
|---|
| | 169 | else{ |
|---|
| | 170 | targetFile = new File(destDir, entry.getRelativePath()); |
|---|
| | 171 | System.out.println(destDir + "/" + entry.getRelativePath()); |
|---|
| | 172 | } |
|---|
| | 173 | |
|---|
| | 174 | targetFile.getParentFile().mkdirs(); |
|---|
| | 175 | |
|---|
| | 176 | FileOutputStream fos = new FileOutputStream(targetFile); |
|---|
| | 177 | BufferedOutputStream exportStream = new BufferedOutputStream(fos); |
|---|
| | 178 | |
|---|
| | 179 | repository.getFile(filePath, revisionNumber, null, exportStream); |
|---|
| | 180 | |
|---|
| | 181 | exportStream.close(); |
|---|
| | 182 | } |
|---|
| | 183 | // ディレクトリの場合 |
|---|
| | 184 | else if (nodeKind == SVNNodeKind.DIR){ |
|---|
| | 185 | |
|---|
| | 186 | Collection entries = repository.getDir(filePath, revisionNumber, null, (Collection) null); |
|---|
| | 187 | Iterator iterator = entries.iterator(); |
|---|
| | 188 | while (iterator.hasNext()) { |
|---|
| | 189 | SVNDirEntry entry = (SVNDirEntry) iterator.next(); |
|---|
| | 190 | |
|---|
| | 191 | String childPath = (filePath != null && filePath.length() != 0) ? |
|---|
| | 192 | filePath + "/" + entry.getRelativePath() : |
|---|
| | 193 | entry.getRelativePath(); |
|---|
| | 194 | |
|---|
| | 195 | // 再帰 |
|---|
| | 196 | this.doExport(repository, |
|---|
| | 197 | childPath, |
|---|
| | 198 | revision, |
|---|
| | 199 | destDir); |
|---|
| | 200 | } |
|---|
| | 201 | } |
|---|
| | 202 | // そのほかは、エラー扱い |
|---|
| | 203 | else{ |
|---|
| | 204 | String url = repository.getLocation().getURIEncodedPath() + filePath; |
|---|
| | 205 | SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "No entry at URL ''{0}''", url); |
|---|
| | 206 | throw new SVNException(err); |
|---|
| | 207 | } |
|---|
| | 208 | |
|---|
| | 209 | } |
|---|
| | 210 | |
|---|