Show More
@@ -26,27 +26,49 b' class mergestate(object):' | |||||
26 | self._dirty = False |
|
26 | self._dirty = False | |
27 | def _read(self): |
|
27 | def _read(self): | |
28 | self._state = {} |
|
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 | try: |
|
42 | try: | |
30 | f = self._repo.opener(self.statepath) |
|
43 | f = self._repo.opener(self.statepath) | |
31 | for i, l in enumerate(f): |
|
44 | for i, l in enumerate(f): | |
32 | if i == 0: |
|
45 | if i == 0: | |
33 |
s |
|
46 | records.append(('L', l[:-1])) | |
34 | else: |
|
47 | else: | |
35 |
|
|
48 | records.append(('F', l[:-1])) | |
36 | self._state[bits[0]] = bits[1:] |
|
|||
37 | f.close() |
|
49 | f.close() | |
38 | except IOError, err: |
|
50 | except IOError, err: | |
39 | if err.errno != errno.ENOENT: |
|
51 | if err.errno != errno.ENOENT: | |
40 | raise |
|
52 | raise | |
41 | self._dirty = False |
|
53 | return records | |
42 | def commit(self): |
|
54 | def commit(self): | |
43 | if self._dirty: |
|
55 | if self._dirty: | |
44 | f = self._repo.opener(self.statepath, "w") |
|
56 | records = [] | |
45 |
|
|
57 | records.append(("L", hex(self._local))) | |
46 | for d, v in self._state.iteritems(): |
|
58 | for d, v in self._state.iteritems(): | |
47 |
|
|
59 | records.append(("F", "\0".join([d] + v))) | |
48 |
f.c |
|
60 | self._writerecords(records) | |
49 | self._dirty = False |
|
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 | def add(self, fcl, fco, fca, fd): |
|
72 | def add(self, fcl, fco, fca, fd): | |
51 | hash = util.sha1(fcl.path()).hexdigest() |
|
73 | hash = util.sha1(fcl.path()).hexdigest() | |
52 | self._repo.opener.write("merge/" + hash, fcl.data()) |
|
74 | self._repo.opener.write("merge/" + hash, fcl.data()) |
General Comments 0
You need to be logged in to leave comments.
Login now