Mercurial > hg
changeset 20651:c1a52dd56eb4
merge: add blank line between mergestate's method
This class is now too big to be a single big block of continuous text.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 05 Mar 2014 10:22:43 -0800 |
parents | e811b93f2cb1 |
children | 2a4871c2511d |
files | mercurial/merge.py |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Mon Mar 03 23:21:24 2014 +0900 +++ b/mercurial/merge.py Wed Mar 05 10:22:43 2014 -0800 @@ -47,10 +47,12 @@ ''' statepathv1 = "merge/state" statepathv2 = "merge/state2" + def __init__(self, repo): self._repo = repo self._dirty = False self._read() + def reset(self, node=None, other=None): self._state = {} if node: @@ -58,6 +60,7 @@ self._other = other shutil.rmtree(self._repo.join("merge"), True) self._dirty = False + def _read(self): self._state = {} records = self._readrecords() @@ -73,6 +76,7 @@ raise util.Abort(_('unsupported merge state record:' % rtype)) self._dirty = False + def _readrecords(self): v1records = self._readrecordsv1() v2records = self._readrecordsv2() @@ -101,6 +105,7 @@ return v1records else: return v2records + def _readrecordsv1(self): records = [] try: @@ -115,6 +120,7 @@ if err.errno != errno.ENOENT: raise return records + def _readrecordsv2(self): records = [] try: @@ -135,6 +141,7 @@ if err.errno != errno.ENOENT: raise return records + def commit(self): if self._dirty: records = [] @@ -144,9 +151,11 @@ records.append(("F", "\0".join([d] + v))) self._writerecords(records) self._dirty = False + def _writerecords(self, records): self._writerecordsv1(records) self._writerecordsv2(records) + def _writerecordsv1(self, records): f = self._repo.opener(self.statepathv1, "w") irecords = iter(records) @@ -157,6 +166,7 @@ if rtype == "F": f.write("%s\n" % _droponode(data)) f.close() + def _writerecordsv2(self, records): f = self._repo.opener(self.statepathv2, "w") for key, data in records: @@ -164,6 +174,7 @@ format = ">sI%is" % len(data) f.write(_pack(format, key, len(data), data)) f.close() + def add(self, fcl, fco, fca, fd): hash = util.sha1(fcl.path()).hexdigest() self._repo.opener.write("merge/" + hash, fcl.data()) @@ -172,20 +183,26 @@ fco.path(), hex(fco.filenode()), fcl.flags()] self._dirty = True + def __contains__(self, dfile): return dfile in self._state + def __getitem__(self, dfile): return self._state[dfile][0] + def __iter__(self): l = self._state.keys() l.sort() for f in l: yield f + def files(self): return self._state.keys() + def mark(self, dfile, state): self._state[dfile][0] = state self._dirty = True + def resolve(self, dfile, wctx): if self[dfile] == 'r': return 0