Patchwork [2,of,2,v2] manifest: disallow setting the node id of an entry to None

login
register
mail settings
Submitter Augie Fackler
Date Dec. 15, 2014, 5:59 p.m.
Message ID <f8ad4740ed42aae9112d.1418666398@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/7117/
State Superseded
Headers show

Comments

Augie Fackler - Dec. 15, 2014, 5:59 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1418409644 18000
#      Fri Dec 12 13:40:44 2014 -0500
# Node ID f8ad4740ed42aae9112d5f2ed2f5df128c5d2257
# Parent  85f3187042f6fe3db123b17b87f4f0b290a47c02
manifest: disallow setting the node id of an entry to None

manifest.diff() uses None as a special value to denote the absence of
a file, so setting a file node to None means you then can't trust
manifest.diff().

This should also make future manifest work slightly easier.
Augie Fackler - Dec. 15, 2014, 7:03 p.m.
It's not my day at the comparison operator store. I just found a bug
in this series, a v3 to follow.

On Mon, Dec 15, 2014 at 12:59 PM, Augie Fackler <raf@durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1418409644 18000
> #      Fri Dec 12 13:40:44 2014 -0500
> # Node ID f8ad4740ed42aae9112d5f2ed2f5df128c5d2257
> # Parent  85f3187042f6fe3db123b17b87f4f0b290a47c02
> manifest: disallow setting the node id of an entry to None
>
> manifest.diff() uses None as a special value to denote the absence of
> a file, so setting a file node to None means you then can't trust
> manifest.diff().
>
> This should also make future manifest work slightly easier.
>
> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
> --- a/mercurial/manifest.py
> +++ b/mercurial/manifest.py
> @@ -17,6 +17,9 @@ class manifestdict(dict):
>              flags = {}
>          dict.__init__(self, mapping)
>          self._flags = flags
> +    def __setitem__(self, k, v):
> +        assert v is not None
> +        dict.__setitem__(self, k, v)
>      def flags(self, f):
>          return self._flags.get(f, "")
>      def withflags(self):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -17,6 +17,9 @@  class manifestdict(dict):
             flags = {}
         dict.__init__(self, mapping)
         self._flags = flags
+    def __setitem__(self, k, v):
+        assert v is not None
+        dict.__setitem__(self, k, v)
     def flags(self, f):
         return self._flags.get(f, "")
     def withflags(self):