Mercurial > hg4j
diff src/org/tmatesoft/hg/internal/AddRevInspector.java @ 663:46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 10 Jul 2013 16:41:49 +0200 |
parents | 4fd317a2fecf |
children | ae2d439fbed3 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/AddRevInspector.java Wed Jul 10 11:53:19 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/AddRevInspector.java Wed Jul 10 16:41:49 2013 +0200 @@ -16,6 +16,7 @@ */ package org.tmatesoft.hg.internal; +import java.io.IOException; import java.util.HashMap; import java.util.Set; @@ -30,24 +31,29 @@ import org.tmatesoft.hg.util.Pair; /** + * FIXME pretty much alike HgCloneCommand.WriteDownMate, shall converge + * * @author Artem Tikhomirov * @author TMate Software Ltd. */ public final class AddRevInspector implements HgBundle.Inspector { private final Internals repo; private final Transaction tr; + private final FNCacheFile.Mediator fncache; private Set<Nodeid> added; private RevlogStreamWriter revlog; private RevMap clogRevs; private RevMap revlogRevs; + private HgDataFile fileNode; + private boolean newFile = false; public AddRevInspector(Internals implRepo, Transaction transaction) { repo = implRepo; tr = transaction; + fncache = new FNCacheFile.Mediator(implRepo); } public void changelogStart() throws HgRuntimeException { - // TODO Auto-generated method stub RevlogStream rs = repo.getImplAccess().getChangelogStream(); revlog = new RevlogStreamWriter(repo, rs, tr); revlogRevs = clogRevs = new RevMap(rs); @@ -71,14 +77,17 @@ } public void fileStart(String name) throws HgRuntimeException { - HgDataFile df = repo.getRepo().getFileNode(name); - RevlogStream rs = repo.getImplAccess().getStream(df); + fileNode = repo.getRepo().getFileNode(name); + newFile = !fileNode.exists(); + RevlogStream rs = repo.getImplAccess().getStream(fileNode); revlog = new RevlogStreamWriter(repo, rs, tr); revlogRevs = new RevMap(rs); - // FIXME collect new files and update fncache } public void fileEnd(String name) throws HgRuntimeException { + if (newFile) { + fncache.registerNew(fileNode.getPath(), revlog.getRevlogStream()); + } revlog = null; revlogRevs = null; } @@ -86,6 +95,12 @@ public boolean element(GroupElement ge) throws HgRuntimeException { assert clogRevs != null; assert revlogRevs != null; + if (revlog.getRevlogStream().findRevisionIndex(ge.node()) != HgRepository.BAD_REVISION) { + // HgRemoteRepository.getChanges(common) builds a bundle that includes these common + // revisions. Hence, shall not add these common (i.e. known locally) revisions + // once again + return true; + } try { Pair<Integer, Nodeid> newRev = revlog.addPatchRevision(ge, clogRevs, revlogRevs); revlogRevs.update(newRev.first(), newRev.second()); @@ -98,6 +113,10 @@ public RevisionSet addedChangesets() { return new RevisionSet(added); } + + public void done() throws IOException { + fncache.complete(); + } private static class RevMap implements RevlogStreamWriter.RevisionToIndexMap {