manifest: use 't' for tree manifest flag
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 04 Dec 2015 14:24:45 -0800
changeset 28715 2a31433a59bafbf94f3d2f9a8895f0ed710ddfa0
parent 28714 ba5f20450b10c4ca1f89dca10c1d8a68a7d129ee
child 28716 69308357ecd151aa447311b9c56d513db49d5f5c
push id104
push usergszorc@mozilla.com
push dateTue, 08 Dec 2015 04:08:11 +0000
manifest: use 't' for tree manifest flag We currently use 'd' to indicate that a manifest entry is a directory. Let's switch to 't', since that's not a valid hex digit and therefore easier to spot in the raw manifest data. This will break any existing repos with tree manifests, but it's still an experimental feature and there are probably only a few test repos in existence with 'd' flags.
mercurial/manifest.py
tests/test-treemanifest.t
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -612,17 +612,17 @@ class treemanifest(object):
             lf, self._loadfunc = self._loadfunc, _noop
             lf(self)
         elif self._copyfunc is not _noop:
             cf, self._copyfunc = self._copyfunc, _noop
             cf(self)
 
     def setflag(self, f, flags):
         """Set the flags (symlink, executable) for path f."""
-        assert 'd' not in flags
+        assert 't' not in flags
         self._load()
         dir, subpath = _splittopdir(f)
         if dir:
             if dir not in self._dirs:
                 self._dirs[dir] = treemanifest(self._subpath(dir))
             self._dirs[dir].setflag(subpath, flags)
         else:
             self._flags[f] = flags
@@ -810,17 +810,17 @@ class treemanifest(object):
         _diff(self, m2)
         return result
 
     def unmodifiedsince(self, m2):
         return not self._dirty and not m2._dirty and self._node == m2._node
 
     def parse(self, text, readsubtree):
         for f, n, fl in _parse(text):
-            if fl == 'd':
+            if fl == 't':
                 f = f + '/'
                 self._dirs[f] = readsubtree(self._subpath(f), n)
             elif '/' in f:
                 # This is a flat manifest, so use __setitem__ and setflag rather
                 # than assigning directly to _files and _flags, so we can
                 # assign a path in a subdirectory, and to mark dirty (compared
                 # to nullid).
                 self[f] = n
@@ -841,17 +841,17 @@ class treemanifest(object):
                      usemanifestv2)
 
     def dirtext(self, usemanifestv2=False):
         """Get the full data of this directory as a bytestring. Make sure that
         any submanifests have been written first, so their nodeids are correct.
         """
         self._load()
         flags = self.flags
-        dirs = [(d[:-1], self._dirs[d]._node, 'd') for d in self._dirs]
+        dirs = [(d[:-1], self._dirs[d]._node, 't') for d in self._dirs]
         files = [(f, self._files[f], flags(f)) for f in self._files]
         return _text(sorted(dirs + files), usemanifestv2)
 
     def read(self, gettext, readsubtree):
         def _load_for_read(s):
             s.parse(gettext(), readsubtree)
             s._dirty = False
         self._loadfunc = _load_for_read
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -27,17 +27,17 @@ Submanifest is stored in separate revlog
   $ mkdir dir1
   $ echo 1 > dir1/a
   $ echo 1 > dir1/b
   $ echo 1 > e
   $ hg ci -Aqm 'add dir1'
   $ hg debugdata -m 1
   a\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (esc)
   b\x00362fef284ce2ca02aecc8de6d5e8a1c3af0556fe (esc)
-  dir1\x008b3ffd73f901e83304c83d33132c8e774ceac44ed (esc)
+  dir1\x008b3ffd73f901e83304c83d33132c8e774ceac44et (esc)
   e\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc)
   $ hg debugdata --dir dir1 0
   a\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc)
   b\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc)
 
 Can add nested directories
 
   $ mkdir dir1/dir1
@@ -119,21 +119,21 @@ Merge creates 2-parent revision of direc
   $ hg ci -m 'conflict-free merge involving dir1/'
   $ cat dir1/a
   5
   $ cat dir1/b
   6
   $ hg debugindex --dir dir1
      rev    offset  length  delta linkrev nodeid       p1           p2
        0         0      54     -1       1 8b3ffd73f901 000000000000 000000000000
-       1        54      68      0       2 b66d046c644f 8b3ffd73f901 000000000000
-       2       122      12      1       4 b87265673c8a b66d046c644f 000000000000
-       3       134      55      1       5 aa5d3adcec72 b66d046c644f 000000000000
-       4       189      55      1       6 e29b066b91ad b66d046c644f 000000000000
-       5       244      55      4       7 a120ce2b83f5 e29b066b91ad aa5d3adcec72
+       1        54      68      0       2 68e9d057c5a8 8b3ffd73f901 000000000000
+       2       122      12      1       4 4698198d2624 68e9d057c5a8 000000000000
+       3       134      55      1       5 44844058ccce 68e9d057c5a8 000000000000
+       4       189      55      1       6 bf3d9b744927 68e9d057c5a8 000000000000
+       5       244      55      4       7 dde7c0af2a03 bf3d9b744927 44844058ccce
 
 Merge keeping directory from parent 1 does not create revlog entry. (Note that
 dir1's manifest does change, but only because dir1/a's filelog changes.)
 
   $ hg co 'desc("add dir2")'
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo 8 > dir2/a
   $ hg ci -m 'modify dir2/a'
@@ -254,41 +254,41 @@ Merge of two trees
 Parent of tree root manifest should be flat manifest, and two for merge
 
   $ hg debugindex -m
      rev    offset  length  delta linkrev nodeid       p1           p2
        0         0      80     -1       0 40536115ed9e 000000000000 000000000000
        1        80      83      0       1 f3376063c255 40536115ed9e 000000000000
        2       163      89      0       2 5d9b9da231a2 40536115ed9e 000000000000
        3       252      83      2       3 d17d663cbd8a 5d9b9da231a2 f3376063c255
-       4       335     124      1       4 c05a51345f86 f3376063c255 000000000000
-       5       459     124      2       5 82594b1f557d 5d9b9da231a2 f3376063c255
+       4       335     124      1       4 51e32a8c60ee f3376063c255 000000000000
+       5       459     126      2       5 cc5baa78b230 5d9b9da231a2 f3376063c255
 
 
 Status across flat/tree boundary should work
 
   $ hg status --rev '.^' --rev .
   M a
   M dir1/a
   M dir1/dir1/a
 
 
 Turning off treemanifest config has no effect
 
   $ hg debugindex .hg/store/meta/dir1/00manifest.i
      rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0     125     -1       4 63c9c0557d24 000000000000 000000000000
-       1       125     109      0       5 23d12a1f6e0e 000000000000 000000000000
+       0         0     127     -1       4 064927a0648a 000000000000 000000000000
+       1       127     111      0       5 25ecb8cb8618 000000000000 000000000000
   $ echo 2 > dir1/a
   $ hg --config experimental.treemanifest=False ci -qm 'modify dir1/a'
   $ hg debugindex .hg/store/meta/dir1/00manifest.i
      rev    offset  length  delta linkrev nodeid       p1           p2
-       0         0     125     -1       4 63c9c0557d24 000000000000 000000000000
-       1       125     109      0       5 23d12a1f6e0e 000000000000 000000000000
-       2       234      55      1       6 3cb2d87b4250 23d12a1f6e0e 000000000000
+       0         0     127     -1       4 064927a0648a 000000000000 000000000000
+       1       127     111      0       5 25ecb8cb8618 000000000000 000000000000
+       2       238      55      1       6 5b16163a30c6 25ecb8cb8618 000000000000
 
 Create deeper repo with tree manifests.
 
   $ cd ..
   $ hg --config experimental.treemanifest=True init deeprepo
   $ cd deeprepo
 
   $ mkdir a