Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgMergeState.java @ 707:42b88709e41d
Merge: support 'unresolved' resolution with MergeStateBuilder
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 16 Aug 2013 19:22:59 +0200 |
parents | b4242b7e7dfe |
children | 4ffc17c0b534 |
comparison
equal
deleted
inserted
replaced
706:cd5c87d96315 | 707:42b88709e41d |
---|---|
16 */ | 16 */ |
17 package org.tmatesoft.hg.repo; | 17 package org.tmatesoft.hg.repo; |
18 | 18 |
19 import static org.tmatesoft.hg.core.Nodeid.NULL; | 19 import static org.tmatesoft.hg.core.Nodeid.NULL; |
20 | 20 |
21 import java.io.BufferedReader; | |
22 import java.io.File; | 21 import java.io.File; |
23 import java.io.FileReader; | |
24 import java.io.IOException; | |
25 import java.util.ArrayList; | 22 import java.util.ArrayList; |
26 import java.util.Arrays; | 23 import java.util.Arrays; |
27 import java.util.Collections; | 24 import java.util.Collections; |
25 import java.util.Iterator; | |
28 import java.util.List; | 26 import java.util.List; |
29 | 27 |
30 import org.tmatesoft.hg.core.HgFileRevision; | 28 import org.tmatesoft.hg.core.HgFileRevision; |
29 import org.tmatesoft.hg.core.HgIOException; | |
31 import org.tmatesoft.hg.core.Nodeid; | 30 import org.tmatesoft.hg.core.Nodeid; |
32 import org.tmatesoft.hg.internal.Internals; | 31 import org.tmatesoft.hg.internal.Internals; |
32 import org.tmatesoft.hg.internal.LineReader; | |
33 import org.tmatesoft.hg.internal.ManifestRevision; | 33 import org.tmatesoft.hg.internal.ManifestRevision; |
34 import org.tmatesoft.hg.internal.Pool; | 34 import org.tmatesoft.hg.internal.Pool; |
35 import org.tmatesoft.hg.util.Pair; | 35 import org.tmatesoft.hg.util.Pair; |
36 import org.tmatesoft.hg.util.Path; | 36 import org.tmatesoft.hg.util.Path; |
37 import org.tmatesoft.hg.util.PathRewrite; | 37 import org.tmatesoft.hg.util.PathRewrite; |
103 stateParent = Nodeid.NULL; | 103 stateParent = Nodeid.NULL; |
104 Pool<Nodeid> nodeidPool = new Pool<Nodeid>(); | 104 Pool<Nodeid> nodeidPool = new Pool<Nodeid>(); |
105 Pool<Path> fnamePool = new Pool<Path>(); | 105 Pool<Path> fnamePool = new Pool<Path>(); |
106 Pair<Nodeid, Nodeid> wcParents = hgRepo.getWorkingCopyParents(); | 106 Pair<Nodeid, Nodeid> wcParents = hgRepo.getWorkingCopyParents(); |
107 wcp1 = nodeidPool.unify(wcParents.first()); wcp2 = nodeidPool.unify(wcParents.second()); | 107 wcp1 = nodeidPool.unify(wcParents.first()); wcp2 = nodeidPool.unify(wcParents.second()); |
108 final File f = repo.getFileFromRepoDir("merge/state"); | 108 final File f = repo.getRepositoryFile(HgRepositoryFiles.MergeState); |
109 if (!f.canRead()) { | 109 if (!f.canRead()) { |
110 // empty state | 110 // empty state |
111 return; | 111 return; |
112 } | 112 } |
113 try { | 113 try { |
118 final ManifestRevision m2 = new ManifestRevision(nodeidPool, fnamePool); | 118 final ManifestRevision m2 = new ManifestRevision(nodeidPool, fnamePool); |
119 if (!wcp2.isNull()) { | 119 if (!wcp2.isNull()) { |
120 final int rp2 = hgRepo.getChangelog().getRevisionIndex(wcp2); | 120 final int rp2 = hgRepo.getChangelog().getRevisionIndex(wcp2); |
121 hgRepo.getManifest().walk(rp2, rp2, m2); | 121 hgRepo.getManifest().walk(rp2, rp2, m2); |
122 } | 122 } |
123 BufferedReader br = new BufferedReader(new FileReader(f)); | 123 LineReader lr = new LineReader(f, repo.getLog()); |
124 String s = br.readLine(); | 124 Iterator<String> lines = lr.read(new LineReader.SimpleLineCollector(), new ArrayList<String>()).iterator(); |
125 String s = lines.next(); | |
125 stateParent = nodeidPool.unify(Nodeid.fromAscii(s)); | 126 stateParent = nodeidPool.unify(Nodeid.fromAscii(s)); |
126 final int rp1 = hgRepo.getChangelog().getRevisionIndex(stateParent); | 127 final int rp1 = hgRepo.getChangelog().getRevisionIndex(stateParent); |
127 hgRepo.getManifest().walk(rp1, rp1, m1); | 128 hgRepo.getManifest().walk(rp1, rp1, m1); |
128 while ((s = br.readLine()) != null) { | 129 while (lines.hasNext()) { |
129 String[] r = s.split("\\00"); | 130 String[] r = s.split("\\00"); |
130 Path p1fname = pathPool.path(r[3]); | 131 Path p1fname = pathPool.path(r[3]); |
131 Nodeid nidP1 = m1.nodeid(p1fname); | 132 Nodeid nidP1 = m1.nodeid(p1fname); |
132 Nodeid nidCA = nodeidPool.unify(Nodeid.fromAscii(r[5])); | 133 Nodeid nidCA = nodeidPool.unify(Nodeid.fromAscii(r[5])); |
133 HgFileRevision p1 = new HgFileRevision(hgRepo, nidP1, m1.flags(p1fname), p1fname); | 134 HgFileRevision p1 = new HgFileRevision(hgRepo, nidP1, m1.flags(p1fname), p1fname); |
160 } | 161 } |
161 Entry e = new Entry(k, pathPool.path(r[0]), p1, p2, ca); | 162 Entry e = new Entry(k, pathPool.path(r[0]), p1, p2, ca); |
162 result.add(e); | 163 result.add(e); |
163 } | 164 } |
164 entries = result.toArray(new Entry[result.size()]); | 165 entries = result.toArray(new Entry[result.size()]); |
165 br.close(); | 166 } catch (HgIOException ex) { |
166 } catch (IOException ex) { | |
167 throw new HgInvalidControlFileException("Merge state read failed", ex, f); | 167 throw new HgInvalidControlFileException("Merge state read failed", ex, f); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 /** | 171 /** |