Patchwork [1,of,3,STABLE] context: reimplement memfilectx.cmp()

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 16, 2018, 8:24 a.m.
Message ID <79dc95eb84b0f09a39fb.1544948660@mimosa>
Download mbox | patch
Permalink /patch/37202/
State New
Headers show

Comments

Yuya Nishihara - Dec. 16, 2018, 8:24 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1544947726 -32400
#      Sun Dec 16 17:08:46 2018 +0900
# Node ID 79dc95eb84b0f09a39fb396c65ec591f9f0de224
# Parent  f1a69099327b6c3d92d2541fe8d40f8fe37a546e
context: reimplement memfilectx.cmp()

If I added a sanity check to basefilectx, test-context.py exploded. This
patch copies the naive implementation from overlayworkingfilectx.
Pulkit Goyal - Dec. 16, 2018, 1:20 p.m.
On Sun, Dec 16, 2018 at 11:27 AM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1544947726 -32400
> #      Sun Dec 16 17:08:46 2018 +0900
> # Node ID 79dc95eb84b0f09a39fb396c65ec591f9f0de224
> # Parent  f1a69099327b6c3d92d2541fe8d40f8fe37a546e
> context: reimplement memfilectx.cmp()
>
> If I added a sanity check to basefilectx, test-context.py exploded. This
> patch copies the naive implementation from overlayworkingfilectx.
>

Did you mean the whole series is for stable or just this patch? And how did
you managed to put the STABLE flag on just one email and not rest? I want
to learn that trick.
Yuya Nishihara - Dec. 16, 2018, 2:08 p.m.
On Sun, 16 Dec 2018 16:20:12 +0300, Pulkit Goyal wrote:
> On Sun, Dec 16, 2018 at 11:27 AM Yuya Nishihara <yuya@tcha.org> wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1544947726 -32400
> > #      Sun Dec 16 17:08:46 2018 +0900
> > # Node ID 79dc95eb84b0f09a39fb396c65ec591f9f0de224
> > # Parent  f1a69099327b6c3d92d2541fe8d40f8fe37a546e
> > context: reimplement memfilectx.cmp()
> >
> > If I added a sanity check to basefilectx, test-context.py exploded. This
> > patch copies the naive implementation from overlayworkingfilectx.
> >
> 
> Did you mean the whole series is for stable or just this patch?

1 for stable, and the others for default (once merged.)

I didn't tried, but memfilectx.cmp() would crash if the other fctx had data
of the same size.

> And how did
> you managed to put the STABLE flag on just one email and not rest? I want
> to learn that trick.

As I'm a templater guru, I just hacked it.

  --config patchbomb.flagtemplate='{ifeq(node|short, "<hash>", "STABLE")}'

Not lovely.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2330,6 +2330,9 @@  class memfilectx(committablefilectx):
         if copied:
             self._copied = (copied, nullid)
 
+    def cmp(self, fctx):
+        return self.data() != fctx.data()
+
     def data(self):
         return self._data