Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgCloneCommand.java @ 490:b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 16 Aug 2012 17:08:34 +0200 |
parents | 12f668401613 |
children | 10ca3ede8367 |
comparison
equal
deleted
inserted
replaced
489:9c0138cda59a | 490:b3c16d1aede0 |
---|---|
28 import java.util.Collections; | 28 import java.util.Collections; |
29 import java.util.LinkedList; | 29 import java.util.LinkedList; |
30 import java.util.TreeMap; | 30 import java.util.TreeMap; |
31 import java.util.zip.DeflaterOutputStream; | 31 import java.util.zip.DeflaterOutputStream; |
32 | 32 |
33 import org.tmatesoft.hg.internal.BasicSessionContext; | |
34 import org.tmatesoft.hg.internal.ByteArrayDataAccess; | 33 import org.tmatesoft.hg.internal.ByteArrayDataAccess; |
35 import org.tmatesoft.hg.internal.DataAccess; | 34 import org.tmatesoft.hg.internal.DataAccess; |
36 import org.tmatesoft.hg.internal.DigestHelper; | 35 import org.tmatesoft.hg.internal.DigestHelper; |
37 import org.tmatesoft.hg.internal.Internals; | 36 import org.tmatesoft.hg.internal.RepoInitializer; |
38 import org.tmatesoft.hg.repo.HgBundle; | 37 import org.tmatesoft.hg.repo.HgBundle; |
39 import org.tmatesoft.hg.repo.HgBundle.GroupElement; | 38 import org.tmatesoft.hg.repo.HgBundle.GroupElement; |
40 import org.tmatesoft.hg.repo.HgInvalidControlFileException; | 39 import org.tmatesoft.hg.repo.HgInvalidControlFileException; |
41 import org.tmatesoft.hg.repo.HgInvalidFileException; | 40 import org.tmatesoft.hg.repo.HgInvalidFileException; |
42 import org.tmatesoft.hg.repo.HgInvalidStateException; | 41 import org.tmatesoft.hg.repo.HgInvalidStateException; |
106 // can use 'stream_out' wireproto | 105 // can use 'stream_out' wireproto |
107 // | 106 // |
108 // pull all changes from the very beginning | 107 // pull all changes from the very beginning |
109 // XXX consult getContext() if by any chance has a bundle ready, if not, then read and register | 108 // XXX consult getContext() if by any chance has a bundle ready, if not, then read and register |
110 HgBundle completeChanges = srcRepo.getChanges(Collections.singletonList(NULL)); | 109 HgBundle completeChanges = srcRepo.getChanges(Collections.singletonList(NULL)); |
111 WriteDownMate mate = new WriteDownMate(destination); | 110 WriteDownMate mate = new WriteDownMate(srcRepo.getSessionContext(), destination); |
112 try { | 111 try { |
113 // instantiate new repo in the destdir | 112 // instantiate new repo in the destdir |
114 mate.initEmptyRepository(); | 113 mate.initEmptyRepository(); |
115 // pull changes | 114 // pull changes |
116 completeChanges.inspectAll(mate); | 115 completeChanges.inspectAll(mate); |
141 private DataAccess prevRevContent; | 140 private DataAccess prevRevContent; |
142 private final DigestHelper dh = new DigestHelper(); | 141 private final DigestHelper dh = new DigestHelper(); |
143 private final ArrayList<Nodeid> revisionSequence = new ArrayList<Nodeid>(); // last visited nodes first | 142 private final ArrayList<Nodeid> revisionSequence = new ArrayList<Nodeid>(); // last visited nodes first |
144 | 143 |
145 private final LinkedList<String> fncacheFiles = new LinkedList<String>(); | 144 private final LinkedList<String> fncacheFiles = new LinkedList<String>(); |
146 private Internals implHelper; | 145 private RepoInitializer repoInit; |
147 | 146 |
148 public WriteDownMate(File destDir) { | 147 public WriteDownMate(SessionContext ctx, File destDir) { |
149 hgDir = new File(destDir, ".hg"); | 148 hgDir = new File(destDir, ".hg"); |
150 implHelper = new Internals(new BasicSessionContext(null)); | 149 repoInit = new RepoInitializer(); |
151 implHelper.setStorageConfig(1, STORE | FNCACHE | DOTENCODE); | 150 repoInit.setRequires(STORE | FNCACHE | DOTENCODE); |
152 storagePathHelper = implHelper.buildDataFilesHelper(); | 151 storagePathHelper = repoInit.buildDataFilesHelper(ctx); |
153 } | 152 } |
154 | 153 |
155 public void initEmptyRepository() throws IOException { | 154 public void initEmptyRepository() throws IOException { |
156 implHelper.initEmptyRepository(hgDir); | 155 repoInit.initEmptyRepository(hgDir); |
157 } | 156 } |
158 | 157 |
159 public void complete() throws IOException { | 158 public void complete() throws IOException { |
160 FileOutputStream fncacheFile = new FileOutputStream(new File(hgDir, "store/fncache")); | 159 FileOutputStream fncacheFile = new FileOutputStream(new File(hgDir, "store/fncache")); |
161 for (String s : fncacheFiles) { | 160 for (String s : fncacheFiles) { |