Mercurial > hg4j
diff 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 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/CommitFacility.java Fri Apr 26 20:04:17 2013 +0200 +++ b/src/org/tmatesoft/hg/repo/CommitFacility.java Mon Apr 29 16:37:57 2013 +0200 @@ -29,12 +29,16 @@ import java.util.TreeSet; import org.tmatesoft.hg.core.HgCommitCommand; +import org.tmatesoft.hg.core.HgIOException; import org.tmatesoft.hg.core.HgRepositoryLockException; import org.tmatesoft.hg.core.Nodeid; import org.tmatesoft.hg.internal.ByteArrayChannel; import org.tmatesoft.hg.internal.ChangelogEntryBuilder; +import org.tmatesoft.hg.internal.DirstateBuilder; +import org.tmatesoft.hg.internal.DirstateReader; import org.tmatesoft.hg.internal.Experimental; import org.tmatesoft.hg.internal.FNCacheFile; +import org.tmatesoft.hg.internal.Internals; import org.tmatesoft.hg.internal.ManifestEntryBuilder; import org.tmatesoft.hg.internal.ManifestRevision; import org.tmatesoft.hg.internal.RevlogStream; @@ -97,7 +101,7 @@ user = userName; } - public Nodeid commit(String message) throws HgRepositoryLockException { + public Nodeid commit(String message) throws HgIOException, HgRepositoryLockException { final HgChangelog clog = repo.getChangelog(); final int clogRevisionIndex = clog.getRevisionCount(); @@ -136,6 +140,7 @@ // // Register new/changed ArrayList<Path> newlyAddedFiles = new ArrayList<Path>(); + ArrayList<Path> touchInDirstate = new ArrayList<Path>(); for (Pair<HgDataFile, ByteDataSupplier> e : files.values()) { HgDataFile df = e.first(); Pair<Integer, Integer> fp = fileParents.get(df.getPath()); @@ -165,6 +170,7 @@ RevlogStreamWriter fileWriter = new RevlogStreamWriter(repo.getSessionContext(), contentStream); Nodeid fileRev = fileWriter.addRevision(bac.toArray(), clogRevisionIndex, fp.first(), fp.second()); newManifestRevision.put(df.getPath(), fileRev); + touchInDirstate.add(df.getPath()); } // // Manifest @@ -196,6 +202,18 @@ repo.getSessionContext().getLog().dump(getClass(), Severity.Error, ex, "Failed to write fncache, error ignored"); } } + // bring dirstate up to commit state + Internals implRepo = Internals.getInstance(repo); + final DirstateBuilder dirstateBuilder = new DirstateBuilder(implRepo); + dirstateBuilder.fillFrom(new DirstateReader(implRepo, new Path.SimpleSource())); + for (Path p : removals) { + dirstateBuilder.recordRemoved(p); + } + for (Path p : touchInDirstate) { + dirstateBuilder.recordUncertain(p); + } + dirstateBuilder.parents(changesetRev, Nodeid.NULL); + dirstateBuilder.serialize(); return changesetRev; } /*