[PATCH 3 of 6 mergedriver] mergestate: add a constructor that sets up a fresh merge state
Martin von Zweigbergk
martinvonz at google.com
Wed Nov 18 00:20:59 UTC 2015
On Tue, Nov 17, 2015 at 4:01 PM Siddharth Agarwal <sid0 at fb.com> wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0 at fb.com>
> # Date 1447797080 28800
> # Tue Nov 17 13:51:20 2015 -0800
> # Node ID bb1b25b554d6efe340f3c74b58fec40cd56fd557
> # Parent a879917dec18a4621476c8af18724f5d5696c663
> mergestate: add a constructor that sets up a fresh merge state
>
> Eventually, we'll move the read call out of the constructor. This will:
> - avoid unnecessary reads when we're going to nuke the merge state anyway
> - avoid raising an exception if there's an unsupported merge record
>
> I chose 'fresh' for the name because I wanted to avoid anything with the
> word
> 'new' in it, and 'reset' is more an action performed on a merge state than
> a
> way to get a new merge state.
>
When I saw patch 4/6, I was wondering how the merge state got removed from
disk. It turns out that ms.reset() does that. So this method (fresh()) *is*
a method for performing an action after all, right?
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -75,6 +75,14 @@ class mergestate(object):
> statepathv1 = 'merge/state'
> statepathv2 = 'merge/state2'
>
> + @staticmethod
> + def fresh(repo, node=None, other=None):
> + """Initialize a fresh merge state, removing any existing state on
> + disk."""
> + ms = mergestate(repo)
> + ms.reset(node, other)
> + return ms
> +
> def __init__(self, repo):
> self._repo = repo
> self._dirty = False
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20151118/741650af/attachment-0002.html>
More information about the Mercurial-devel
mailing list