Patchwork [3,of,4,mergedriver] mergestate.commit: factor out making the list of records

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 18, 2015, 6:41 a.m.
Message ID <5a8a002259aa129e3c3a.1447828898@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11470/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Siddharth Agarwal - Nov. 18, 2015, 6:41 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447799006 28800
#      Tue Nov 17 14:23:26 2015 -0800
# Node ID 5a8a002259aa129e3c3a332df860d09db62c2964
# Parent  631058f5fee42e8a0b719807a97bf40903df7551
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 5a8a002259aa
mergestate.commit: factor out making the list of records

Will aid in testing.
Martin von Zweigbergk - Nov. 18, 2015, 6:58 p.m.
I've pushed up to this patch to the clowncopter, thanks

On Tue, Nov 17, 2015 at 10:44 PM Siddharth Agarwal <sid0@fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1447799006 28800
> #      Tue Nov 17 14:23:26 2015 -0800
> # Node ID 5a8a002259aa129e3c3a332df860d09db62c2964
> # Parent  631058f5fee42e8a0b719807a97bf40903df7551
> # Available At http://42.netv6.net/sid0-wip/hg/
> #              hg pull http://42.netv6.net/sid0-wip/hg/ -r 5a8a002259aa
> mergestate.commit: factor out making the list of records
>
> Will aid in testing.
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -286,20 +286,24 @@ class mergestate(object):
>      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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -286,20 +286,24 @@  class mergestate(object):
     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)