mergestate.commit: factor out making the list of records
authorSiddharth Agarwal <sid0@fb.com>
Tue, 17 Nov 2015 14:23:26 -0800
changeset 27006 9d58dc193c46
parent 27005 3185c01c551c
child 27007 c8cbef073645
mergestate.commit: factor out making the list of records Will aid in testing.
mercurial/merge.py
--- a/mercurial/merge.py	Tue Nov 17 14:04:56 2015 -0800
+++ b/mercurial/merge.py	Tue Nov 17 14:23:26 2015 -0800
@@ -286,20 +286,24 @@
     def commit(self):
         """Write current state on disk (if necessary)"""
         if self._dirty:
-            records = []
-            records.append(('L', hex(self._local)))
-            records.append(('O', hex(self._other)))
-            if self.mergedriver:
-                records.append(('m', '\0'.join([
-                    self.mergedriver, self._mdstate])))
-            for d, v in self._state.iteritems():
-                if v[0] == 'd':
-                    records.append(('D', '\0'.join([d] + v)))
-                else:
-                    records.append(('F', '\0'.join([d] + v)))
+            records = self._makerecords()
             self._writerecords(records)
             self._dirty = False
 
+    def _makerecords(self):
+        records = []
+        records.append(('L', hex(self._local)))
+        records.append(('O', hex(self._other)))
+        if self.mergedriver:
+            records.append(('m', '\0'.join([
+                self.mergedriver, self._mdstate])))
+        for d, v in self._state.iteritems():
+            if v[0] == 'd':
+                records.append(('D', '\0'.join([d] + v)))
+            else:
+                records.append(('F', '\0'.join([d] + v)))
+        return records
+
     def _writerecords(self, records):
         """Write current state on disk (both v1 and v2)"""
         self._writerecordsv1(records)