Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgCloneCommand.java @ 664:ae2d439fbed3
Utilize transaction when writing fncache. Better HgIOException
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 10 Jul 2013 19:33:51 +0200 |
parents | 4a0bab2c6da1 |
children | 545b1d4cc11d |
comparison
equal
deleted
inserted
replaced
663:46b56864b483 | 664:ae2d439fbed3 |
---|---|
36 import org.tmatesoft.hg.internal.Internals; | 36 import org.tmatesoft.hg.internal.Internals; |
37 import org.tmatesoft.hg.internal.Lifecycle; | 37 import org.tmatesoft.hg.internal.Lifecycle; |
38 import org.tmatesoft.hg.internal.RepoInitializer; | 38 import org.tmatesoft.hg.internal.RepoInitializer; |
39 import org.tmatesoft.hg.internal.RevlogCompressor; | 39 import org.tmatesoft.hg.internal.RevlogCompressor; |
40 import org.tmatesoft.hg.internal.RevlogStreamWriter; | 40 import org.tmatesoft.hg.internal.RevlogStreamWriter; |
41 import org.tmatesoft.hg.internal.Transaction; | |
41 import org.tmatesoft.hg.repo.HgBundle; | 42 import org.tmatesoft.hg.repo.HgBundle; |
42 import org.tmatesoft.hg.repo.HgBundle.GroupElement; | 43 import org.tmatesoft.hg.repo.HgBundle.GroupElement; |
43 import org.tmatesoft.hg.repo.HgInvalidControlFileException; | 44 import org.tmatesoft.hg.repo.HgInvalidControlFileException; |
44 import org.tmatesoft.hg.repo.HgInvalidFileException; | |
45 import org.tmatesoft.hg.repo.HgInvalidStateException; | 45 import org.tmatesoft.hg.repo.HgInvalidStateException; |
46 import org.tmatesoft.hg.repo.HgLookup; | 46 import org.tmatesoft.hg.repo.HgLookup; |
47 import org.tmatesoft.hg.repo.HgRemoteRepository; | 47 import org.tmatesoft.hg.repo.HgRemoteRepository; |
48 import org.tmatesoft.hg.repo.HgRepository; | 48 import org.tmatesoft.hg.repo.HgRepository; |
49 import org.tmatesoft.hg.repo.HgRuntimeException; | 49 import org.tmatesoft.hg.repo.HgRuntimeException; |
124 mate.initEmptyRepository(); | 124 mate.initEmptyRepository(); |
125 // pull changes | 125 // pull changes |
126 completeChanges.inspectAll(mate); | 126 completeChanges.inspectAll(mate); |
127 mate.checkFailure(); | 127 mate.checkFailure(); |
128 mate.complete(); | 128 mate.complete(); |
129 } catch (IOException ex) { | |
130 throw new HgInvalidFileException(getClass().getName(), ex); | |
131 } finally { | 129 } finally { |
132 completeChanges.unlink(); | 130 completeChanges.unlink(); |
133 progress.done(); | 131 progress.done(); |
134 } | 132 } |
135 } catch (HgRuntimeException ex) { | 133 } catch (HgRuntimeException ex) { |
187 // XXX perhaps, with WriteDownMate moving to a more appropriate location, | 185 // XXX perhaps, with WriteDownMate moving to a more appropriate location, |
188 // we could instantiate HgRepository (or Internals) by other means, without exception? | 186 // we could instantiate HgRepository (or Internals) by other means, without exception? |
189 fncacheFile = new FNCacheFile(Internals.getInstance(new HgLookup(ctx).detect(hgDir))); | 187 fncacheFile = new FNCacheFile(Internals.getInstance(new HgLookup(ctx).detect(hgDir))); |
190 } | 188 } |
191 | 189 |
192 public void complete() throws IOException { | 190 public void complete() throws HgIOException { |
193 fncacheFile.write(); | 191 fncacheFile.write(new Transaction.NoRollback()); |
194 } | 192 } |
195 | 193 |
196 public void changelogStart() throws HgInvalidControlFileException { | 194 public void changelogStart() throws HgInvalidControlFileException { |
197 try { | 195 try { |
198 revlogHeader.offset(0).baseRevision(-1); | 196 revlogHeader.offset(0).baseRevision(-1); |