Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/CommitFacility.java @ 616:5e0313485eef
encode directories as demanded by fncache format
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Tue, 14 May 2013 17:31:35 +0200 |
| parents | f41dd9a3b8af |
| children | 65c01508f002 |
comparison
equal
deleted
inserted
replaced
| 615:84104448a0bf | 616:5e0313485eef |
|---|---|
| 131 for (Path p : removals) { | 131 for (Path p : removals) { |
| 132 newManifestRevision.remove(p); | 132 newManifestRevision.remove(p); |
| 133 } | 133 } |
| 134 // | 134 // |
| 135 // Register new/changed | 135 // Register new/changed |
| 136 ArrayList<Path> newlyAddedFiles = new ArrayList<Path>(); | 136 LinkedHashMap<Path, RevlogStream> newlyAddedFiles = new LinkedHashMap<Path, RevlogStream>(); |
| 137 ArrayList<Path> touchInDirstate = new ArrayList<Path>(); | 137 ArrayList<Path> touchInDirstate = new ArrayList<Path>(); |
| 138 for (Pair<HgDataFile, ByteDataSupplier> e : files.values()) { | 138 for (Pair<HgDataFile, ByteDataSupplier> e : files.values()) { |
| 139 HgDataFile df = e.first(); | 139 HgDataFile df = e.first(); |
| 140 Pair<Integer, Integer> fp = fileParents.get(df.getPath()); | 140 Pair<Integer, Integer> fp = fileParents.get(df.getPath()); |
| 141 if (fp == null) { | 141 if (fp == null) { |
| 154 RevlogStream contentStream; | 154 RevlogStream contentStream; |
| 155 if (df.exists()) { | 155 if (df.exists()) { |
| 156 contentStream = repo.getImplAccess().getStream(df); | 156 contentStream = repo.getImplAccess().getStream(df); |
| 157 } else { | 157 } else { |
| 158 contentStream = repo.createStoreFile(df.getPath()); | 158 contentStream = repo.createStoreFile(df.getPath()); |
| 159 newlyAddedFiles.add(df.getPath()); | 159 newlyAddedFiles.put(df.getPath(), contentStream); |
| 160 // FIXME df doesn't get df.content updated, and clients | 160 // FIXME df doesn't get df.content updated, and clients |
| 161 // that would attempt to access newly added file after commit would fail | 161 // that would attempt to access newly added file after commit would fail |
| 162 // (despite the fact the file is in there) | 162 // (despite the fact the file is in there) |
| 163 } | 163 } |
| 164 RevlogStreamWriter fileWriter = new RevlogStreamWriter(repo, contentStream); | 164 RevlogStreamWriter fileWriter = new RevlogStreamWriter(repo, contentStream); |
| 181 changelogBuilder.branch(branch == null ? DEFAULT_BRANCH_NAME : branch); | 181 changelogBuilder.branch(branch == null ? DEFAULT_BRANCH_NAME : branch); |
| 182 changelogBuilder.user(String.valueOf(user)); | 182 changelogBuilder.user(String.valueOf(user)); |
| 183 byte[] clogContent = changelogBuilder.build(manifestRev, message); | 183 byte[] clogContent = changelogBuilder.build(manifestRev, message); |
| 184 RevlogStreamWriter changelogWriter = new RevlogStreamWriter(repo, repo.getImplAccess().getChangelogStream()); | 184 RevlogStreamWriter changelogWriter = new RevlogStreamWriter(repo, repo.getImplAccess().getChangelogStream()); |
| 185 Nodeid changesetRev = changelogWriter.addRevision(clogContent, clogRevisionIndex, p1Commit, p2Commit); | 185 Nodeid changesetRev = changelogWriter.addRevision(clogContent, clogRevisionIndex, p1Commit, p2Commit); |
| 186 // FIXME move fncache update to an external facility, along with dirstate and bookmark update | 186 // TODO move fncache update to an external facility, along with dirstate and bookmark update |
| 187 if (!newlyAddedFiles.isEmpty() && repo.fncacheInUse()) { | 187 if (!newlyAddedFiles.isEmpty() && repo.fncacheInUse()) { |
| 188 FNCacheFile fncache = new FNCacheFile(repo); | 188 FNCacheFile fncache = new FNCacheFile(repo); |
| 189 for (Path p : newlyAddedFiles) { | 189 for (Path p : newlyAddedFiles.keySet()) { |
| 190 fncache.add(p); | 190 fncache.addIndex(p); |
| 191 if (!newlyAddedFiles.get(p).isInlineData()) { | |
| 192 fncache.addData(p); | |
| 193 } | |
| 191 } | 194 } |
| 192 try { | 195 try { |
| 193 fncache.write(); | 196 fncache.write(); |
| 194 } catch (IOException ex) { | 197 } catch (IOException ex) { |
| 195 // see comment above for fnchache.read() | 198 // see comment above for fnchache.read() |
| 230 dirstateBuilder.serialize(); | 233 dirstateBuilder.serialize(); |
| 231 // update bookmarks | 234 // update bookmarks |
| 232 if (p1Commit != NO_REVISION || p2Commit != NO_REVISION) { | 235 if (p1Commit != NO_REVISION || p2Commit != NO_REVISION) { |
| 233 repo.getRepo().getBookmarks().updateActive(p1Cset, p2Cset, changesetRev); | 236 repo.getRepo().getBookmarks().updateActive(p1Cset, p2Cset, changesetRev); |
| 234 } | 237 } |
| 238 // TODO undo.dirstate and undo.branch as described in http://mercurial.selenic.com/wiki/FileFormats#undo..2A | |
| 235 // TODO Revisit: might be reasonable to send out a "Repo changed" notification, to clear | 239 // TODO Revisit: might be reasonable to send out a "Repo changed" notification, to clear |
| 236 // e.g. cached branch, tags and so on, not to rely on file change detection methods? | 240 // e.g. cached branch, tags and so on, not to rely on file change detection methods? |
| 237 // The same notificaion might come useful once Pull is implemented | 241 // The same notification might come useful once Pull is implemented |
| 238 return changesetRev; | 242 return changesetRev; |
| 239 } | 243 } |
| 240 /* | 244 /* |
| 241 private Pair<Integer, Integer> getManifestParents() { | 245 private Pair<Integer, Integer> getManifestParents() { |
| 242 return new Pair<Integer, Integer>(extractManifestRevisionIndex(p1Commit), extractManifestRevisionIndex(p2Commit)); | 246 return new Pair<Integer, Integer>(extractManifestRevisionIndex(p1Commit), extractManifestRevisionIndex(p2Commit)); |
