Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/CommitFacility.java @ 612:dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Fri, 10 May 2013 14:29:35 +0200 |
| parents | 5c68567b3645 |
| children | f41dd9a3b8af |
comparison
equal
deleted
inserted
replaced
| 611:7fc7fba4df30 | 612:dca70c0b1f74 |
|---|---|
| 14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
| 15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
| 16 */ | 16 */ |
| 17 package org.tmatesoft.hg.internal; | 17 package org.tmatesoft.hg.internal; |
| 18 | 18 |
| 19 import static org.tmatesoft.hg.repo.HgRepository.DEFAULT_BRANCH_NAME; | |
| 19 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; | 20 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; |
| 20 | 21 import static org.tmatesoft.hg.repo.HgRepositoryFiles.Branch; |
| 22 import static org.tmatesoft.hg.util.LogFacility.Severity.Error; | |
| 23 | |
| 24 import java.io.File; | |
| 25 import java.io.FileOutputStream; | |
| 21 import java.io.IOException; | 26 import java.io.IOException; |
| 22 import java.nio.ByteBuffer; | 27 import java.nio.ByteBuffer; |
| 23 import java.util.ArrayList; | 28 import java.util.ArrayList; |
| 24 import java.util.HashMap; | 29 import java.util.HashMap; |
| 25 import java.util.LinkedHashMap; | 30 import java.util.LinkedHashMap; |
| 32 import org.tmatesoft.hg.core.HgIOException; | 37 import org.tmatesoft.hg.core.HgIOException; |
| 33 import org.tmatesoft.hg.core.HgRepositoryLockException; | 38 import org.tmatesoft.hg.core.HgRepositoryLockException; |
| 34 import org.tmatesoft.hg.core.Nodeid; | 39 import org.tmatesoft.hg.core.Nodeid; |
| 35 import org.tmatesoft.hg.repo.HgChangelog; | 40 import org.tmatesoft.hg.repo.HgChangelog; |
| 36 import org.tmatesoft.hg.repo.HgDataFile; | 41 import org.tmatesoft.hg.repo.HgDataFile; |
| 37 import org.tmatesoft.hg.repo.HgRepository; | |
| 38 import org.tmatesoft.hg.util.Pair; | 42 import org.tmatesoft.hg.util.Pair; |
| 39 import org.tmatesoft.hg.util.Path; | 43 import org.tmatesoft.hg.util.Path; |
| 40 import org.tmatesoft.hg.util.LogFacility.Severity; | |
| 41 | 44 |
| 42 /** | 45 /** |
| 43 * WORK IN PROGRESS | 46 * WORK IN PROGRESS |
| 44 * Name: CommitObject, FutureCommit or PendingCommit | 47 * Name: CommitObject, FutureCommit or PendingCommit |
| 45 * Only public API now: {@link HgCommitCommand}. | 48 * Only public API now: {@link HgCommitCommand}. |
| 175 Nodeid manifestRev = manifestWriter.addRevision(manifestBuilder.build(), clogRevisionIndex, manifestParents.first(), manifestParents.second()); | 178 Nodeid manifestRev = manifestWriter.addRevision(manifestBuilder.build(), clogRevisionIndex, manifestParents.first(), manifestParents.second()); |
| 176 // | 179 // |
| 177 // Changelog | 180 // Changelog |
| 178 final ChangelogEntryBuilder changelogBuilder = new ChangelogEntryBuilder(); | 181 final ChangelogEntryBuilder changelogBuilder = new ChangelogEntryBuilder(); |
| 179 changelogBuilder.setModified(files.keySet()); | 182 changelogBuilder.setModified(files.keySet()); |
| 180 changelogBuilder.branch(branch == null ? HgRepository.DEFAULT_BRANCH_NAME : branch); | 183 changelogBuilder.branch(branch == null ? DEFAULT_BRANCH_NAME : branch); |
| 181 changelogBuilder.user(String.valueOf(user)); | 184 changelogBuilder.user(String.valueOf(user)); |
| 182 byte[] clogContent = changelogBuilder.build(manifestRev, message); | 185 byte[] clogContent = changelogBuilder.build(manifestRev, message); |
| 183 RevlogStreamWriter changelogWriter = new RevlogStreamWriter(repo, repo.getImplAccess().getChangelogStream()); | 186 RevlogStreamWriter changelogWriter = new RevlogStreamWriter(repo, repo.getImplAccess().getChangelogStream()); |
| 184 Nodeid changesetRev = changelogWriter.addRevision(clogContent, clogRevisionIndex, p1Commit, p2Commit); | 187 Nodeid changesetRev = changelogWriter.addRevision(clogContent, clogRevisionIndex, p1Commit, p2Commit); |
| 185 // FIXME move fncache update to an external facility, along with dirstate and bookmark update | 188 // FIXME move fncache update to an external facility, along with dirstate and bookmark update |
| 190 } | 193 } |
| 191 try { | 194 try { |
| 192 fncache.write(); | 195 fncache.write(); |
| 193 } catch (IOException ex) { | 196 } catch (IOException ex) { |
| 194 // see comment above for fnchache.read() | 197 // see comment above for fnchache.read() |
| 195 repo.getLog().dump(getClass(), Severity.Error, ex, "Failed to write fncache, error ignored"); | 198 repo.getLog().dump(getClass(), Error, ex, "Failed to write fncache, error ignored"); |
| 199 } | |
| 200 } | |
| 201 String oldBranchValue = DirstateReader.readBranch(repo); | |
| 202 String newBranchValue = branch == null ? DEFAULT_BRANCH_NAME : branch; | |
| 203 if (!oldBranchValue.equals(newBranchValue)) { | |
| 204 File branchFile = repo.getRepositoryFile(Branch); | |
| 205 FileOutputStream fos = null; | |
| 206 try { | |
| 207 fos = new FileOutputStream(branchFile); | |
| 208 fos.write(newBranchValue.getBytes(EncodingHelper.getUTF8())); | |
| 209 fos.flush(); | |
| 210 } catch (IOException ex) { | |
| 211 repo.getLog().dump(getClass(), Error, ex, "Failed to write branch information, error ignored"); | |
| 212 } finally { | |
| 213 try { | |
| 214 if (fos != null) { | |
| 215 fos.close(); | |
| 216 } | |
| 217 } catch (IOException ex) { | |
| 218 repo.getLog().dump(getClass(), Error, ex, null); | |
| 219 } | |
| 196 } | 220 } |
| 197 } | 221 } |
| 198 // bring dirstate up to commit state | 222 // bring dirstate up to commit state |
| 199 final DirstateBuilder dirstateBuilder = new DirstateBuilder(repo); | 223 final DirstateBuilder dirstateBuilder = new DirstateBuilder(repo); |
| 200 dirstateBuilder.fillFrom(new DirstateReader(repo, new Path.SimpleSource())); | 224 dirstateBuilder.fillFrom(new DirstateReader(repo, new Path.SimpleSource())); |
