Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/CommitFacility.java @ 588:41218d84842a
Update dirstate after commit
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 29 Apr 2013 16:37:57 +0200 |
parents | 73c20c648c1f |
children |
comparison
equal
deleted
inserted
replaced
587:a52f4cc56f9c | 588:41218d84842a |
---|---|
27 import java.util.Set; | 27 import java.util.Set; |
28 import java.util.TreeMap; | 28 import java.util.TreeMap; |
29 import java.util.TreeSet; | 29 import java.util.TreeSet; |
30 | 30 |
31 import org.tmatesoft.hg.core.HgCommitCommand; | 31 import org.tmatesoft.hg.core.HgCommitCommand; |
32 import org.tmatesoft.hg.core.HgIOException; | |
32 import org.tmatesoft.hg.core.HgRepositoryLockException; | 33 import org.tmatesoft.hg.core.HgRepositoryLockException; |
33 import org.tmatesoft.hg.core.Nodeid; | 34 import org.tmatesoft.hg.core.Nodeid; |
34 import org.tmatesoft.hg.internal.ByteArrayChannel; | 35 import org.tmatesoft.hg.internal.ByteArrayChannel; |
35 import org.tmatesoft.hg.internal.ChangelogEntryBuilder; | 36 import org.tmatesoft.hg.internal.ChangelogEntryBuilder; |
37 import org.tmatesoft.hg.internal.DirstateBuilder; | |
38 import org.tmatesoft.hg.internal.DirstateReader; | |
36 import org.tmatesoft.hg.internal.Experimental; | 39 import org.tmatesoft.hg.internal.Experimental; |
37 import org.tmatesoft.hg.internal.FNCacheFile; | 40 import org.tmatesoft.hg.internal.FNCacheFile; |
41 import org.tmatesoft.hg.internal.Internals; | |
38 import org.tmatesoft.hg.internal.ManifestEntryBuilder; | 42 import org.tmatesoft.hg.internal.ManifestEntryBuilder; |
39 import org.tmatesoft.hg.internal.ManifestRevision; | 43 import org.tmatesoft.hg.internal.ManifestRevision; |
40 import org.tmatesoft.hg.internal.RevlogStream; | 44 import org.tmatesoft.hg.internal.RevlogStream; |
41 import org.tmatesoft.hg.internal.RevlogStreamWriter; | 45 import org.tmatesoft.hg.internal.RevlogStreamWriter; |
42 import org.tmatesoft.hg.util.Pair; | 46 import org.tmatesoft.hg.util.Pair; |
95 | 99 |
96 public void user(String userName) { | 100 public void user(String userName) { |
97 user = userName; | 101 user = userName; |
98 } | 102 } |
99 | 103 |
100 public Nodeid commit(String message) throws HgRepositoryLockException { | 104 public Nodeid commit(String message) throws HgIOException, HgRepositoryLockException { |
101 | 105 |
102 final HgChangelog clog = repo.getChangelog(); | 106 final HgChangelog clog = repo.getChangelog(); |
103 final int clogRevisionIndex = clog.getRevisionCount(); | 107 final int clogRevisionIndex = clog.getRevisionCount(); |
104 ManifestRevision c1Manifest = new ManifestRevision(null, null); | 108 ManifestRevision c1Manifest = new ManifestRevision(null, null); |
105 ManifestRevision c2Manifest = new ManifestRevision(null, null); | 109 ManifestRevision c2Manifest = new ManifestRevision(null, null); |
134 newManifestRevision.remove(p); | 138 newManifestRevision.remove(p); |
135 } | 139 } |
136 // | 140 // |
137 // Register new/changed | 141 // Register new/changed |
138 ArrayList<Path> newlyAddedFiles = new ArrayList<Path>(); | 142 ArrayList<Path> newlyAddedFiles = new ArrayList<Path>(); |
143 ArrayList<Path> touchInDirstate = new ArrayList<Path>(); | |
139 for (Pair<HgDataFile, ByteDataSupplier> e : files.values()) { | 144 for (Pair<HgDataFile, ByteDataSupplier> e : files.values()) { |
140 HgDataFile df = e.first(); | 145 HgDataFile df = e.first(); |
141 Pair<Integer, Integer> fp = fileParents.get(df.getPath()); | 146 Pair<Integer, Integer> fp = fileParents.get(df.getPath()); |
142 if (fp == null) { | 147 if (fp == null) { |
143 // NEW FILE | 148 // NEW FILE |
163 // (despite the fact the file is in there) | 168 // (despite the fact the file is in there) |
164 } | 169 } |
165 RevlogStreamWriter fileWriter = new RevlogStreamWriter(repo.getSessionContext(), contentStream); | 170 RevlogStreamWriter fileWriter = new RevlogStreamWriter(repo.getSessionContext(), contentStream); |
166 Nodeid fileRev = fileWriter.addRevision(bac.toArray(), clogRevisionIndex, fp.first(), fp.second()); | 171 Nodeid fileRev = fileWriter.addRevision(bac.toArray(), clogRevisionIndex, fp.first(), fp.second()); |
167 newManifestRevision.put(df.getPath(), fileRev); | 172 newManifestRevision.put(df.getPath(), fileRev); |
173 touchInDirstate.add(df.getPath()); | |
168 } | 174 } |
169 // | 175 // |
170 // Manifest | 176 // Manifest |
171 final ManifestEntryBuilder manifestBuilder = new ManifestEntryBuilder(); | 177 final ManifestEntryBuilder manifestBuilder = new ManifestEntryBuilder(); |
172 for (Map.Entry<Path, Nodeid> me : newManifestRevision.entrySet()) { | 178 for (Map.Entry<Path, Nodeid> me : newManifestRevision.entrySet()) { |
194 } catch (IOException ex) { | 200 } catch (IOException ex) { |
195 // see comment above for fnchache.read() | 201 // see comment above for fnchache.read() |
196 repo.getSessionContext().getLog().dump(getClass(), Severity.Error, ex, "Failed to write fncache, error ignored"); | 202 repo.getSessionContext().getLog().dump(getClass(), Severity.Error, ex, "Failed to write fncache, error ignored"); |
197 } | 203 } |
198 } | 204 } |
205 // bring dirstate up to commit state | |
206 Internals implRepo = Internals.getInstance(repo); | |
207 final DirstateBuilder dirstateBuilder = new DirstateBuilder(implRepo); | |
208 dirstateBuilder.fillFrom(new DirstateReader(implRepo, new Path.SimpleSource())); | |
209 for (Path p : removals) { | |
210 dirstateBuilder.recordRemoved(p); | |
211 } | |
212 for (Path p : touchInDirstate) { | |
213 dirstateBuilder.recordUncertain(p); | |
214 } | |
215 dirstateBuilder.parents(changesetRev, Nodeid.NULL); | |
216 dirstateBuilder.serialize(); | |
199 return changesetRev; | 217 return changesetRev; |
200 } | 218 } |
201 /* | 219 /* |
202 private Pair<Integer, Integer> getManifestParents() { | 220 private Pair<Integer, Integer> getManifestParents() { |
203 return new Pair<Integer, Integer>(extractManifestRevisionIndex(p1Commit), extractManifestRevisionIndex(p2Commit)); | 221 return new Pair<Integer, Integer>(extractManifestRevisionIndex(p1Commit), extractManifestRevisionIndex(p2Commit)); |