Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgBookmarks.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 | ae4d6604debd |
children | d2f6ab541330 |
comparison
equal
deleted
inserted
replaced
489:9c0138cda59a | 490:b3c16d1aede0 |
---|---|
22 import java.util.Collections; | 22 import java.util.Collections; |
23 import java.util.LinkedHashMap; | 23 import java.util.LinkedHashMap; |
24 import java.util.Map; | 24 import java.util.Map; |
25 | 25 |
26 import org.tmatesoft.hg.core.Nodeid; | 26 import org.tmatesoft.hg.core.Nodeid; |
27 import org.tmatesoft.hg.internal.Internals; | |
27 import org.tmatesoft.hg.internal.LineReader; | 28 import org.tmatesoft.hg.internal.LineReader; |
28 import org.tmatesoft.hg.util.LogFacility; | 29 import org.tmatesoft.hg.util.LogFacility; |
29 | 30 |
30 /** | 31 /** |
31 * | 32 * |
32 * @author Artem Tikhomirov | 33 * @author Artem Tikhomirov |
33 * @author TMate Software Ltd. | 34 * @author TMate Software Ltd. |
34 */ | 35 */ |
35 public final class HgBookmarks { | 36 public final class HgBookmarks { |
36 private final HgRepository repo; | 37 private final Internals internalRepo; |
37 private Map<String, Nodeid> bookmarks = Collections.emptyMap(); | 38 private Map<String, Nodeid> bookmarks = Collections.emptyMap(); |
38 private String activeBookmark; | 39 private String activeBookmark; |
39 | 40 |
40 HgBookmarks(HgRepository hgRepo) { | 41 HgBookmarks(Internals internals) { |
41 repo = hgRepo; | 42 internalRepo = internals; |
42 } | 43 } |
43 | 44 |
44 /*package-local*/ void read() throws HgInvalidControlFileException { | 45 /*package-local*/ void read() throws HgInvalidControlFileException { |
45 final LogFacility log = repo.getContext().getLog(); | 46 final LogFacility log = internalRepo.getContext().getLog(); |
46 File all = new File (repo.getRepositoryRoot(), HgRepositoryFiles.Bookmarks.getName()); | 47 final HgRepository repo = internalRepo.getRepo(); |
48 File all = internalRepo.getFileFromRepoDir(HgRepositoryFiles.Bookmarks.getName()); | |
47 LinkedHashMap<String, Nodeid> bm = new LinkedHashMap<String, Nodeid>(); | 49 LinkedHashMap<String, Nodeid> bm = new LinkedHashMap<String, Nodeid>(); |
48 if (all.canRead()) { | 50 if (all.canRead()) { |
49 LineReader lr1 = new LineReader(all, log); | 51 LineReader lr1 = new LineReader(all, log); |
50 ArrayList<String> c = new ArrayList<String>(); | 52 ArrayList<String> c = new ArrayList<String>(); |
51 lr1.read(new LineReader.SimpleLineCollector(), c); | 53 lr1.read(new LineReader.SimpleLineCollector(), c); |
72 } else { | 74 } else { |
73 bookmarks = Collections.emptyMap(); | 75 bookmarks = Collections.emptyMap(); |
74 } | 76 } |
75 | 77 |
76 activeBookmark = null; | 78 activeBookmark = null; |
77 File active = new File(repo.getRepositoryRoot(), HgRepositoryFiles.BookmarksCurrent.getName()); | 79 File active = internalRepo.getFileFromRepoDir(HgRepositoryFiles.BookmarksCurrent.getName()); |
78 if (active.canRead()) { | 80 if (active.canRead()) { |
79 LineReader lr2 = new LineReader(active, repo.getContext().getLog()); | 81 LineReader lr2 = new LineReader(active, log); |
80 ArrayList<String> c = new ArrayList<String>(2); | 82 ArrayList<String> c = new ArrayList<String>(2); |
81 lr2.read(new LineReader.SimpleLineCollector(), c); | 83 lr2.read(new LineReader.SimpleLineCollector(), c); |
82 if (c.size() > 0) { | 84 if (c.size() > 0) { |
83 activeBookmark = c.get(0); | 85 activeBookmark = c.get(0); |
84 } | 86 } |