Patchwork [2,of,4,mergedriver] mergestate: move _read() call to read constructor

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 18, 2015, 6:41 a.m.
Message ID <631058f5fee42e8a0b71.1447828897@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11469/
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 1447797896 28800
#      Tue Nov 17 14:04:56 2015 -0800
# Node ID 631058f5fee42e8a0b719807a97bf40903df7551
# Parent  2869fd1811666940c049c171ee074c0020e776eb
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 631058f5fee4
mergestate: move _read() call to read constructor

With this patch, mergestate.fresh() will no longer abort when it encounters an
unsupported merge type. However we hold off on testing it until backwards
compatibility is in place.
Martin von Zweigbergk - Nov. 18, 2015, 6:57 a.m.
On Tue, Nov 17, 2015 at 10:43 PM Siddharth Agarwal <sid0@fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1447797896 28800
> #      Tue Nov 17 14:04:56 2015 -0800
> # Node ID 631058f5fee42e8a0b719807a97bf40903df7551
> # Parent  2869fd1811666940c049c171ee074c0020e776eb
> # Available At http://42.netv6.net/sid0-wip/hg/
> #              hg pull http://42.netv6.net/sid0-wip/hg/ -r 631058f5fee4
> mergestate: move _read() call to read constructor
>
> With this patch, mergestate.fresh() will no longer abort when it
> encounters an
>

I'll fix this up in flight with s/fresh/clean/ here and in the patch body.


> unsupported merge type. However we hold off on testing it until backwards
> compatibility is in place.
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -87,12 +87,15 @@ class mergestate(object):
>      def read(repo):
>          """Initialize the merge state, reading it from disk."""
>          ms = mergestate(repo)
> +        ms._read()
>          return ms
>
>      def __init__(self, repo):
> +        """Initialize the merge state.
> +
> +        Do not use this directly! Instead call read() or fresh()."""
>          self._repo = repo
>          self._dirty = False
> -        self._read()
>
>      def reset(self, node=None, other=None):
>          self._state = {}
> _______________________________________________
> 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
@@ -87,12 +87,15 @@  class mergestate(object):
     def read(repo):
         """Initialize the merge state, reading it from disk."""
         ms = mergestate(repo)
+        ms._read()
         return ms
 
     def __init__(self, repo):
+        """Initialize the merge state.
+
+        Do not use this directly! Instead call read() or fresh()."""
         self._repo = repo
         self._dirty = False
-        self._read()
 
     def reset(self, node=None, other=None):
         self._state = {}