Show More
@@ -16,6 +16,12 b' import errno, os, shutil' | |||
|
16 | 16 | _pack = struct.pack |
|
17 | 17 | _unpack = struct.unpack |
|
18 | 18 | |
|
19 | def _droponode(data): | |
|
20 | # used for compatibility for v1 | |
|
21 | bits = data.split("\0") | |
|
22 | bits = bits[:-2] + bits[-1:] | |
|
23 | return "\0".join(bits) | |
|
24 | ||
|
19 | 25 | class mergestate(object): |
|
20 | 26 | '''track 3-way merge state of individual files |
|
21 | 27 | |
@@ -70,14 +76,28 b' class mergestate(object):' | |||
|
70 | 76 | def _readrecords(self): |
|
71 | 77 | v1records = self._readrecordsv1() |
|
72 | 78 | v2records = self._readrecordsv2() |
|
73 |
|
|
|
74 |
for re |
|
|
75 |
if re |
|
|
79 | oldv2 = set() # old format version of v2 record | |
|
80 | for rec in v2records: | |
|
81 | if rec[0] == 'L': | |
|
82 | oldv2.add(rec) | |
|
83 | elif rec[0] == 'F': | |
|
84 | # drop the onode data (not contained in v1) | |
|
85 | oldv2.add(('F', _droponode(rec[1]))) | |
|
86 | for rec in v1records: | |
|
87 | if rec not in oldv2: | |
|
76 | 88 | # v1 file is newer than v2 file, use it |
|
77 | 89 | # we have to infer the "other" changeset of the merge |
|
78 | 90 | # we cannot do better than that with v1 of the format |
|
79 | 91 | mctx = self._repo[None].parents()[-1] |
|
80 | 92 | v1records.append(('O', mctx.hex())) |
|
93 | # add place holder "other" file node information | |
|
94 | # nobody is using it yet so we do no need to fetch the data | |
|
95 | # if mctx was wrong `mctx[bits[-2]]` may fails. | |
|
96 | for idx, r in enumerate(v1records): | |
|
97 | if r[0] == 'F': | |
|
98 | bits = r[1].split("\0") | |
|
99 | bits.insert(-2, '') | |
|
100 | v1records[idx] = (r[0], "\0".join(bits)) | |
|
81 | 101 | return v1records |
|
82 | 102 | else: |
|
83 | 103 | return v2records |
@@ -135,7 +155,7 b' class mergestate(object):' | |||
|
135 | 155 | f.write(hex(self._local) + "\n") |
|
136 | 156 | for rtype, data in irecords: |
|
137 | 157 | if rtype == "F": |
|
138 | f.write("%s\n" % data) | |
|
158 | f.write("%s\n" % _droponode(data)) | |
|
139 | 159 | f.close() |
|
140 | 160 | def _writerecordsv2(self, records): |
|
141 | 161 | f = self._repo.opener(self.statepathv2, "w") |
@@ -147,8 +167,10 b' class mergestate(object):' | |||
|
147 | 167 | def add(self, fcl, fco, fca, fd): |
|
148 | 168 | hash = util.sha1(fcl.path()).hexdigest() |
|
149 | 169 | self._repo.opener.write("merge/" + hash, fcl.data()) |
|
150 |
self._state[fd] = ['u', hash, fcl.path(), |
|
|
151 |
hex(fca.filenode()), |
|
|
170 | self._state[fd] = ['u', hash, fcl.path(), | |
|
171 | fca.path(), hex(fca.filenode()), | |
|
172 | fco.path(), hex(fco.filenode()), | |
|
173 | fcl.flags()] | |
|
152 | 174 | self._dirty = True |
|
153 | 175 | def __contains__(self, dfile): |
|
154 | 176 | return dfile in self._state |
@@ -167,7 +189,8 b' class mergestate(object):' | |||
|
167 | 189 | def resolve(self, dfile, wctx, octx): |
|
168 | 190 | if self[dfile] == 'r': |
|
169 | 191 | return 0 |
|
170 |
state |
|
|
192 | stateentry = self._state[dfile] | |
|
193 | state, hash, lfile, afile, anode, ofile, onode, flags = stateentry | |
|
171 | 194 | fcd = wctx[dfile] |
|
172 | 195 | fco = octx[ofile] |
|
173 | 196 | fca = self._repo.filectx(afile, fileid=anode) |
General Comments 0
You need to be logged in to leave comments.
Login now