comparison src/org/tmatesoft/hg/internal/Internals.java @ 608:e1b29756f901

Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 07 May 2013 21:27:51 +0200
parents e447384f3771
children 5c68567b3645
comparison
equal deleted inserted replaced
607:66f1cc23b906 608:e1b29756f901
123 private final int requiresFlags; 123 private final int requiresFlags;
124 124
125 private final PathRewrite dataPathHelper; // access to file storage area (usually under .hg/store/data/), with filenames mangled 125 private final PathRewrite dataPathHelper; // access to file storage area (usually under .hg/store/data/), with filenames mangled
126 private final PathRewrite repoPathHelper; // access to system files (under .hg/store if requires has 'store' flag) 126 private final PathRewrite repoPathHelper; // access to system files (under .hg/store if requires has 'store' flag)
127 127
128 private final boolean shallMergePatches;
128 private final RevlogStreamFactory streamProvider; 129 private final RevlogStreamFactory streamProvider;
129 130
130 public Internals(HgRepository hgRepo, File hgDir, ImplAccess implementationAccess) throws HgRuntimeException { 131 public Internals(HgRepository hgRepo, File hgDir, ImplAccess implementationAccess) throws HgRuntimeException {
131 repo = hgRepo; 132 repo = hgRepo;
132 repoDir = hgDir; 133 repoDir = hgDir;
136 dataAccess = new DataAccessProvider(ctx); 137 dataAccess = new DataAccessProvider(ctx);
137 RepoInitializer repoInit = new RepoInitializer().initRequiresFromFile(repoDir); 138 RepoInitializer repoInit = new RepoInitializer().initRequiresFromFile(repoDir);
138 requiresFlags = repoInit.getRequires(); 139 requiresFlags = repoInit.getRequires();
139 dataPathHelper = repoInit.buildDataFilesHelper(getSessionContext()); 140 dataPathHelper = repoInit.buildDataFilesHelper(getSessionContext());
140 repoPathHelper = repoInit.buildStoreFilesHelper(); 141 repoPathHelper = repoInit.buildStoreFilesHelper();
141 boolean shallCacheRevlogsInRepo = new PropertyMarshal(ctx).getBoolean(CFG_PROPERTY_REVLOG_STREAM_CACHE, true); 142 final PropertyMarshal pm = new PropertyMarshal(ctx);
143 boolean shallCacheRevlogsInRepo = pm.getBoolean(CFG_PROPERTY_REVLOG_STREAM_CACHE, true);
142 streamProvider = new RevlogStreamFactory(this, shallCacheRevlogsInRepo); 144 streamProvider = new RevlogStreamFactory(this, shallCacheRevlogsInRepo);
145 shallMergePatches = pm.getBoolean(Internals.CFG_PROPERTY_PATCH_MERGE, false);
143 } 146 }
144 147
145 public boolean isInvalid() { 148 public boolean isInvalid() {
146 return !repoDir.exists() || !repoDir.isDirectory(); 149 return !repoDir.exists() || !repoDir.isDirectory();
147 } 150 }
264 267
265 public int getRequiresFlags() { 268 public int getRequiresFlags() {
266 return requiresFlags; 269 return requiresFlags;
267 } 270 }
268 271
272 boolean shallMergePatches() {
273 return shallMergePatches;
274 }
275
276 RevlogChangeMonitor getRevlogTracker(File f) {
277 // TODO decide whether to use one monitor per multiple files or
278 // an instance per file; and let SessionContext pass alternative implementation)
279 return new RevlogChangeMonitor(f);
280 }
281
269 public static boolean runningOnWindows() { 282 public static boolean runningOnWindows() {
270 return System.getProperty("os.name").indexOf("Windows") != -1; 283 return System.getProperty("os.name").indexOf("Windows") != -1;
271 } 284 }
272 285
273 /** 286 /**
388 } 401 }
389 f = new File(hgInstallDir, "hgrc.d/"); 402 f = new File(hgInstallDir, "hgrc.d/");
390 if (f.canRead() && f.isDirectory()) { 403 if (f.canRead() && f.isDirectory()) {
391 return listConfigFiles(f); 404 return listConfigFiles(f);
392 } 405 }
393 // TODO post-1.0 query registry, e.g. with 406 // TODO [post-1.1] query registry, e.g. with
394 // Runtime.exec("reg query HKLM\Software\Mercurial") 407 // Runtime.exec("reg query HKLM\Software\Mercurial")
395 // 408 //
396 f = new File("C:\\Mercurial\\Mercurial.ini"); 409 f = new File("C:\\Mercurial\\Mercurial.ini");
397 if (f.exists()) { 410 if (f.exists()) {
398 return Collections.singletonList(f); 411 return Collections.singletonList(f);