Patchwork [inline-doc,V2] manifest: document the extra letter in working copy manifest node

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 27, 2014, 1:20 a.m.
Message ID <02ad837bfdf82dffdcab.1417051204@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6881/
State Accepted
Commit 4275059e56652a089bbda0d75b14b30341f234a1
Headers show

Comments

Pierre-Yves David - Nov. 27, 2014, 1:20 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1417045021 28800
#      Wed Nov 26 15:37:01 2014 -0800
# Node ID 02ad837bfdf82dffdcab978872ba1e3f20b866d0
# Parent  9da5a7413eb8bc3e708eee62bc38342c8ff7f917
manifest: document the extra letter in working copy manifest node

As the second developer to get confused by this in November, I'm adding some
documentation for the next poor soul.
Martin von Zweigbergk - Nov. 27, 2014, 3:58 a.m.
Looks good to me.

Just FYI, I might send some patches to replace the 'a' and 'm' by just '+',
so this knowledge doesn't have to be shared between context.py and
merge.py. This patch will probably effectively be reverted then, but since
I can't know whether it would be accepted, that's no reason to hold this
patch up.

On Wed Nov 26 2014 at 5:21:20 PM Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1417045021 28800
> #      Wed Nov 26 15:37:01 2014 -0800
> # Node ID 02ad837bfdf82dffdcab978872ba1e3f20b866d0
> # Parent  9da5a7413eb8bc3e708eee62bc38342c8ff7f917
> manifest: document the extra letter in working copy manifest node
>
> As the second developer to get confused by this in November, I'm adding
> some
> documentation for the next poor soul.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -1033,11 +1033,17 @@ class committablectx(basectx):
>      def _flagfunc(self):
>          return self._repo.dirstate.flagfunc(self._buildflagfunc)
>
>      @propertycache
>      def _manifest(self):
> -        """generate a manifest corresponding to the values in
> self._status"""
> +        """generate a manifest corresponding to the values in self._status
> +
> +        This reuse the file nodeid from parent, but we append an extra
> letter
> +        when modified.  Modified files get an extra 'm' while added files
> get
> +        appened an extra 'a'. This is used by manifests merge to see that
> files
> +        are different and by update logic to avoid deleting newly added
> files.
> +        """
>
>          man = self._parents[0].manifest().copy()
>          if len(self._parents) > 1:
>              man2 = self.p2().manifest()
>              def getman(f):
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -455,11 +455,14 @@ def manifestmerge(repo, wctx, p2, pa, br
>              if n1 != ma[f]:
>                  if acceptremote:
>                      actions['r'].append((f, None, "remote delete"))
>                  else:
>                      actions['cd'].append((f, None, "prompt
> changed/deleted"))
> -            elif n1[20:] == 'a': # added, no remote
> +            elif n1[20:] == 'a':
> +                # This extra 'a' is added by working copy manifest to
> mark the
> +                # file as locally added. We should forget it instead of
> +                # deleting it.
>                  actions['f'].append((f, None, "remote deleted"))
>              else:
>                  actions['r'].append((f, None, "other deleted"))
>          elif n2 and f in movewithdir:
>              f2 = movewithdir[f]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Augie Fackler - Nov. 28, 2014, 4 p.m.
On Wed, Nov 26, 2014 at 05:20:04PM -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1417045021 28800
> #      Wed Nov 26 15:37:01 2014 -0800
> # Node ID 02ad837bfdf82dffdcab978872ba1e3f20b866d0
> # Parent  9da5a7413eb8bc3e708eee62bc38342c8ff7f917
> manifest: document the extra letter in working copy manifest node

queued this, thanks

>
> As the second developer to get confused by this in November, I'm adding some
> documentation for the next poor soul.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -1033,11 +1033,17 @@ class committablectx(basectx):
>      def _flagfunc(self):
>          return self._repo.dirstate.flagfunc(self._buildflagfunc)
>
>      @propertycache
>      def _manifest(self):
> -        """generate a manifest corresponding to the values in self._status"""
> +        """generate a manifest corresponding to the values in self._status
> +
> +        This reuse the file nodeid from parent, but we append an extra letter
> +        when modified.  Modified files get an extra 'm' while added files get
> +        appened an extra 'a'. This is used by manifests merge to see that files
> +        are different and by update logic to avoid deleting newly added files.
> +        """
>
>          man = self._parents[0].manifest().copy()
>          if len(self._parents) > 1:
>              man2 = self.p2().manifest()
>              def getman(f):
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -455,11 +455,14 @@ def manifestmerge(repo, wctx, p2, pa, br
>              if n1 != ma[f]:
>                  if acceptremote:
>                      actions['r'].append((f, None, "remote delete"))
>                  else:
>                      actions['cd'].append((f, None, "prompt changed/deleted"))
> -            elif n1[20:] == 'a': # added, no remote
> +            elif n1[20:] == 'a':
> +                # This extra 'a' is added by working copy manifest to mark the
> +                # file as locally added. We should forget it instead of
> +                # deleting it.
>                  actions['f'].append((f, None, "remote deleted"))
>              else:
>                  actions['r'].append((f, None, "other deleted"))
>          elif n2 and f in movewithdir:
>              f2 = movewithdir[f]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1033,11 +1033,17 @@  class committablectx(basectx):
     def _flagfunc(self):
         return self._repo.dirstate.flagfunc(self._buildflagfunc)
 
     @propertycache
     def _manifest(self):
-        """generate a manifest corresponding to the values in self._status"""
+        """generate a manifest corresponding to the values in self._status
+
+        This reuse the file nodeid from parent, but we append an extra letter
+        when modified.  Modified files get an extra 'm' while added files get
+        appened an extra 'a'. This is used by manifests merge to see that files
+        are different and by update logic to avoid deleting newly added files.
+        """
 
         man = self._parents[0].manifest().copy()
         if len(self._parents) > 1:
             man2 = self.p2().manifest()
             def getman(f):
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -455,11 +455,14 @@  def manifestmerge(repo, wctx, p2, pa, br
             if n1 != ma[f]:
                 if acceptremote:
                     actions['r'].append((f, None, "remote delete"))
                 else:
                     actions['cd'].append((f, None, "prompt changed/deleted"))
-            elif n1[20:] == 'a': # added, no remote
+            elif n1[20:] == 'a':
+                # This extra 'a' is added by working copy manifest to mark the
+                # file as locally added. We should forget it instead of
+                # deleting it.
                 actions['f'].append((f, None, "remote deleted"))
             else:
                 actions['r'].append((f, None, "other deleted"))
         elif n2 and f in movewithdir:
             f2 = movewithdir[f]