Show More
@@ -26,27 +26,49 b' class mergestate(object):' | |||
|
26 | 26 | self._dirty = False |
|
27 | 27 | def _read(self): |
|
28 | 28 | self._state = {} |
|
29 | records = self._readrecords() | |
|
30 | for rtype, record in records: | |
|
31 | if rtype == 'L': | |
|
32 | self._local = bin(record) | |
|
33 | elif rtype == "F": | |
|
34 | bits = record.split("\0") | |
|
35 | self._state[bits[0]] = bits[1:] | |
|
36 | elif not rtype.islower(): | |
|
37 | raise util.Abort(_('unsupported merge state record:' | |
|
38 | % rtype)) | |
|
39 | self._dirty = False | |
|
40 | def _readrecords(self): | |
|
41 | records = [] | |
|
29 | 42 | try: |
|
30 | 43 | f = self._repo.opener(self.statepath) |
|
31 | 44 | for i, l in enumerate(f): |
|
32 | 45 | if i == 0: |
|
33 |
s |
|
|
46 | records.append(('L', l[:-1])) | |
|
34 | 47 | else: |
|
35 |
|
|
|
36 | self._state[bits[0]] = bits[1:] | |
|
48 | records.append(('F', l[:-1])) | |
|
37 | 49 | f.close() |
|
38 | 50 | except IOError, err: |
|
39 | 51 | if err.errno != errno.ENOENT: |
|
40 | 52 | raise |
|
41 | self._dirty = False | |
|
53 | return records | |
|
42 | 54 | def commit(self): |
|
43 | 55 | if self._dirty: |
|
44 | f = self._repo.opener(self.statepath, "w") | |
|
45 |
|
|
|
56 | records = [] | |
|
57 | records.append(("L", hex(self._local))) | |
|
46 | 58 | for d, v in self._state.iteritems(): |
|
47 |
|
|
|
48 |
f.c |
|
|
59 | records.append(("F", "\0".join([d] + v))) | |
|
60 | self._writerecords(records) | |
|
49 | 61 | self._dirty = False |
|
62 | def _writerecords(self, records): | |
|
63 | f = self._repo.opener(self.statepath, "w") | |
|
64 | irecords = iter(records) | |
|
65 | lrecords = irecords.next() | |
|
66 | assert lrecords[0] == 'L' | |
|
67 | f.write(hex(self._local) + "\n") | |
|
68 | for rtype, data in irecords: | |
|
69 | if rtype == "F": | |
|
70 | f.write("%s\n" % data) | |
|
71 | f.close() | |
|
50 | 72 | def add(self, fcl, fco, fca, fd): |
|
51 | 73 | hash = util.sha1(fcl.path()).hexdigest() |
|
52 | 74 | self._repo.opener.write("merge/" + hash, fcl.data()) |
General Comments 0
You need to be logged in to leave comments.
Login now