comparison src/org/tmatesoft/hg/internal/RepoInitializer.java @ 622:4e6179bde4fc

Update to comply with Java 1.5 target
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 20 May 2013 16:56:40 +0200
parents ba36f66c32b4
children 4a0bab2c6da1
comparison
equal deleted inserted replaced
621:99ad1e3a4e4d 622:4e6179bde4fc
21 import java.io.File; 21 import java.io.File;
22 import java.io.FileOutputStream; 22 import java.io.FileOutputStream;
23 import java.io.IOException; 23 import java.io.IOException;
24 import java.nio.charset.Charset; 24 import java.nio.charset.Charset;
25 25
26 import org.tmatesoft.hg.core.HgIOException;
26 import org.tmatesoft.hg.core.SessionContext; 27 import org.tmatesoft.hg.core.SessionContext;
27 import org.tmatesoft.hg.repo.HgInvalidControlFileException; 28 import org.tmatesoft.hg.repo.HgInvalidControlFileException;
28 import org.tmatesoft.hg.util.PathRewrite; 29 import org.tmatesoft.hg.util.PathRewrite;
29 30
30 /** 31 /**
57 58
58 public int getRequires() { 59 public int getRequires() {
59 return requiresFlags; 60 return requiresFlags;
60 } 61 }
61 62
62 public void initEmptyRepository(File repoDir) throws IOException { 63 public void initEmptyRepository(File repoDir) throws HgIOException {
63 repoDir.mkdirs(); 64 repoDir.mkdirs();
64 FileOutputStream requiresFile = new FileOutputStream(new File(repoDir, "requires")); 65 final File requiresFile = new File(repoDir, "requires");
65 StringBuilder sb = new StringBuilder(40); 66 try {
66 sb.append("revlogv1\n"); 67 FileOutputStream requiresStream = new FileOutputStream(requiresFile);
67 if ((requiresFlags & STORE) != 0) { 68 StringBuilder sb = new StringBuilder(40);
68 sb.append("store\n"); 69 sb.append("revlogv1\n");
70 if ((requiresFlags & STORE) != 0) {
71 sb.append("store\n");
72 }
73 if ((requiresFlags & FNCACHE) != 0) {
74 sb.append("fncache\n");
75 }
76 if ((requiresFlags & DOTENCODE) != 0) {
77 sb.append("dotencode\n");
78 }
79 requiresStream.write(sb.toString().getBytes());
80 requiresStream.close();
81 } catch (IOException ex) {
82 throw new HgIOException("Failed to initialize empty repo", ex, requiresFile);
69 } 83 }
70 if ((requiresFlags & FNCACHE) != 0) {
71 sb.append("fncache\n");
72 }
73 if ((requiresFlags & DOTENCODE) != 0) {
74 sb.append("dotencode\n");
75 }
76 requiresFile.write(sb.toString().getBytes());
77 requiresFile.close();
78 new File(repoDir, "store").mkdir(); // with that, hg verify says ok. 84 new File(repoDir, "store").mkdir(); // with that, hg verify says ok.
79 } 85 }
80 86
81 public PathRewrite buildDataFilesHelper(SessionContext ctx) { 87 public PathRewrite buildDataFilesHelper(SessionContext ctx) {
82 Charset cs = Internals.getFileEncoding(ctx); 88 Charset cs = Internals.getFileEncoding(ctx);