changeset 40556:10c10da14c5d

remotefilelog: bump pack file formats to version 2 Drop support for format 0 and 1 packs. Version 2 will be different in that it'll use zlib compression instead of lz4, as the latter isn't really suitable for core. If I can make it work, I'll make compression engines pluggable, but the logic for handling these files is spread out enough it's a little tricky to get that right. Test changes are only due to pack files being renamed. The contents of the packs are the same. Differential Revision: https://phab.mercurial-scm.org/D4943
author Augie Fackler <augie@google.com>
date Wed, 03 Oct 2018 23:25:31 -0400
parents b6b2a3d22344
children e2a1584e9e3f
files hgext/remotefilelog/basepack.py hgext/remotefilelog/datapack.py hgext/remotefilelog/historypack.py hgext/remotefilelog/repack.py tests/test-remotefilelog-bgprefetch.t tests/test-remotefilelog-datapack.py tests/test-remotefilelog-gc.t tests/test-remotefilelog-gcrepack.t tests/test-remotefilelog-histpack.py tests/test-remotefilelog-repack-fast.t tests/test-remotefilelog-repack.t
diffstat 11 files changed, 217 insertions(+), 276 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/remotefilelog/basepack.py	Wed Oct 03 23:47:43 2018 -0400
+++ b/hgext/remotefilelog/basepack.py	Wed Oct 03 23:25:31 2018 -0400
@@ -260,7 +260,7 @@
 class versionmixin(object):
     # Mix-in for classes with multiple supported versions
     VERSION = None
-    SUPPORTED_VERSIONS = [0]
+    SUPPORTED_VERSIONS = [2]
 
     def _checkversion(self, version):
         if version in self.SUPPORTED_VERSIONS:
@@ -277,7 +277,7 @@
     # pages can be released (100MB)
     MAXPAGEDIN = 100 * 1024**2
 
-    SUPPORTED_VERSIONS = [0]
+    SUPPORTED_VERSIONS = [2]
 
     def __init__(self, path):
         self.path = path
@@ -315,12 +315,9 @@
 
     @util.propertycache
     def _indexend(self):
-        if self.VERSION == 0:
-            return self.indexsize
-        else:
-            nodecount = struct.unpack_from('!Q', self._index,
-                                           self.params.indexstart - 8)[0]
-            return self.params.indexstart + nodecount * self.INDEXENTRYLENGTH
+        nodecount = struct.unpack_from('!Q', self._index,
+                                       self.params.indexstart - 8)[0]
+        return self.params.indexstart + nodecount * self.INDEXENTRYLENGTH
 
     def freememory(self):
         """Unmap and remap the memory to free it up after known expensive
@@ -361,9 +358,10 @@
 
 class mutablebasepack(versionmixin):
 
-    def __init__(self, ui, packdir, version=0):
+    def __init__(self, ui, packdir, version=2):
         self._checkversion(version)
-
+        # TODO(augie): make this configurable
+        self._compressor = 'GZ'
         opener = vfsmod.vfs(packdir)
         opener.createmode = 0o444
         self.opener = opener
@@ -496,8 +494,7 @@
 
         self._writeheader(params)
         self.idxfp.write(rawfanouttable)
-        if self.VERSION == 1:
-            self.idxfp.write(rawentrieslength)
+        self.idxfp.write(rawentrieslength)
         self.idxfp.write(rawindex)
         self.idxfp.close()
 
@@ -538,6 +535,5 @@
         self.fanoutsize = self.fanoutcount * 4
 
         self.indexstart = FANOUTSTART + self.fanoutsize
-        if version == 1:
-            # Skip the index length
-            self.indexstart += 8
+        # Skip the index length
+        self.indexstart += 8
--- a/hgext/remotefilelog/datapack.py	Wed Oct 03 23:47:43 2018 -0400
+++ b/hgext/remotefilelog/datapack.py	Wed Oct 03 23:25:31 2018 -0400
@@ -5,7 +5,6 @@
 from mercurial.node import hex, nullid
 from mercurial.i18n import _
 from mercurial import (
-    error,
     pycompat,
     util,
 )
@@ -95,7 +94,7 @@
     INDEXFORMAT = '!20siQQ'
     INDEXENTRYLENGTH = 40
 
-    SUPPORTED_VERSIONS = [0, 1]
+    SUPPORTED_VERSIONS = [2]
 
     def getmissing(self, keys):
         missing = []
@@ -115,10 +114,6 @@
         if value is None:
             raise KeyError((name, hex(node)))
 
-        # version 0 does not support metadata
-        if self.VERSION == 0:
-            return {}
-
         node, deltabaseoffset, offset, size = value
         rawentry = self._data[offset:offset + size]
 
@@ -203,14 +198,11 @@
         delta = lz4wrapper.lz4decompress(delta)
 
         if getmeta:
-            if self.VERSION == 0:
-                meta = {}
-            else:
-                metastart = deltastart + 8 + deltalen
-                metalen = struct.unpack_from('!I', rawentry, metastart)[0]
+            metastart = deltastart + 8 + deltalen
+            metalen = struct.unpack_from('!I', rawentry, metastart)[0]
 
-                rawmeta = rawentry[metastart + 4:metastart + 4 + metalen]
-                meta = shallowutil.parsepackmeta(rawmeta)
+            rawmeta = rawentry[metastart + 4:metastart + 4 + metalen]
+            meta = shallowutil.parsepackmeta(rawmeta)
             return filename, node, deltabasenode, delta, meta
         else:
             return filename, node, deltabasenode, delta
@@ -316,10 +308,9 @@
             uncompressedlen = struct.unpack('<I', data[offset:offset + 4])[0]
             offset += deltalen
 
-            if self.VERSION == 1:
-                # <4 byte len> + <metadata-list>
-                metalen = struct.unpack_from('!I', data, offset)[0]
-                offset += 4 + metalen
+            # <4 byte len> + <metadata-list>
+            metalen = struct.unpack_from('!I', data, offset)[0]
+            offset += 4 + metalen
 
             yield (filename, node, deltabase, uncompressedlen)
 
@@ -406,7 +397,7 @@
     INDEXENTRYLENGTH = datapack.INDEXENTRYLENGTH
 
     # v1 has metadata support
-    SUPPORTED_VERSIONS = [0, 1]
+    SUPPORTED_VERSIONS = [2]
 
     def add(self, name, node, deltabasenode, delta, metadata=None):
         # metadata is a dict, ex. {METAKEYFLAG: flag}
@@ -431,15 +422,10 @@
             delta,
         ))
 
-        if self.VERSION == 1:
-            # v1 support metadata
-            rawmeta = shallowutil.buildpackmeta(metadata)
-            rawdata += struct.pack('!I', len(rawmeta)) # unsigned 4 byte
-            rawdata += rawmeta
-        else:
-            # v0 cannot store metadata, raise if metadata contains flag
-            if metadata and metadata.get(constants.METAKEYFLAG, 0) != 0:
-                raise error.ProgrammingError('v0 pack cannot store flags')
+        # v1 support metadata
+        rawmeta = shallowutil.buildpackmeta(metadata)
+        rawdata += struct.pack('!I', len(rawmeta)) # unsigned 4 byte
+        rawdata += rawmeta
 
         offset = self.packfp.tell()
 
--- a/hgext/remotefilelog/historypack.py	Wed Oct 03 23:47:43 2018 -0400
+++ b/hgext/remotefilelog/historypack.py	Wed Oct 03 23:25:31 2018 -0400
@@ -15,10 +15,8 @@
 )
 
 # (filename hash, offset, size)
-INDEXFORMAT0 = '!20sQQ'
-INDEXENTRYLENGTH0 = struct.calcsize(INDEXFORMAT0)
-INDEXFORMAT1 = '!20sQQII'
-INDEXENTRYLENGTH1 = struct.calcsize(INDEXFORMAT1)
+INDEXFORMAT2 = '!20sQQII'
+INDEXENTRYLENGTH2 = struct.calcsize(INDEXFORMAT2)
 NODELENGTH = 20
 
 NODEINDEXFORMAT = '!20sQ'
@@ -84,17 +82,12 @@
     INDEXSUFFIX = INDEXSUFFIX
     PACKSUFFIX = PACKSUFFIX
 
-    SUPPORTED_VERSIONS = [0, 1]
+    SUPPORTED_VERSIONS = [2]
 
     def __init__(self, path):
         super(historypack, self).__init__(path)
-
-        if self.VERSION == 0:
-            self.INDEXFORMAT = INDEXFORMAT0
-            self.INDEXENTRYLENGTH = INDEXENTRYLENGTH0
-        else:
-            self.INDEXFORMAT = INDEXFORMAT1
-            self.INDEXENTRYLENGTH = INDEXENTRYLENGTH1
+        self.INDEXFORMAT = INDEXFORMAT2
+        self.INDEXENTRYLENGTH = INDEXENTRYLENGTH2
 
     def getmissing(self, keys):
         missing = []
@@ -215,22 +208,17 @@
             raise KeyError(name)
 
         rawentry = struct.unpack(self.INDEXFORMAT, entry)
-        if self.VERSION == 0:
-            x, offset, size = rawentry
-            nodeindexoffset = None
-            nodeindexsize = None
-        else:
-            x, offset, size, nodeindexoffset, nodeindexsize = rawentry
-            rawnamelen = self._index[nodeindexoffset:nodeindexoffset +
-                                                     constants.FILENAMESIZE]
-            actualnamelen = struct.unpack('!H', rawnamelen)[0]
-            nodeindexoffset += constants.FILENAMESIZE
-            actualname = self._index[nodeindexoffset:nodeindexoffset +
-                                                     actualnamelen]
-            if actualname != name:
-                raise KeyError("found file name %s when looking for %s" %
-                               (actualname, name))
-            nodeindexoffset += actualnamelen
+        x, offset, size, nodeindexoffset, nodeindexsize = rawentry
+        rawnamelen = self._index[nodeindexoffset:nodeindexoffset +
+                                                 constants.FILENAMESIZE]
+        actualnamelen = struct.unpack('!H', rawnamelen)[0]
+        nodeindexoffset += constants.FILENAMESIZE
+        actualname = self._index[nodeindexoffset:nodeindexoffset +
+                                                 actualnamelen]
+        if actualname != name:
+            raise KeyError("found file name %s when looking for %s" %
+                           (actualname, name))
+        nodeindexoffset += actualnamelen
 
         filenamelength = struct.unpack('!H', self._data[offset:offset +
                                                     constants.FILENAMESIZE])[0]
@@ -406,24 +394,16 @@
     INDEXSUFFIX = INDEXSUFFIX
     PACKSUFFIX = PACKSUFFIX
 
-    SUPPORTED_VERSIONS = [0, 1]
+    SUPPORTED_VERSIONS = [2]
 
-    def __init__(self, ui, packpath, version=0):
-        # internal config: remotefilelog.historypackv1
-        if version == 0 and ui.configbool('remotefilelog', 'historypackv1'):
-            version = 1
-
+    def __init__(self, ui, packpath, version=2):
         super(mutablehistorypack, self).__init__(ui, packpath, version=version)
         self.files = {}
         self.entrylocations = {}
         self.fileentries = {}
 
-        if version == 0:
-            self.INDEXFORMAT = INDEXFORMAT0
-            self.INDEXENTRYLENGTH = INDEXENTRYLENGTH0
-        else:
-            self.INDEXFORMAT = INDEXFORMAT1
-            self.INDEXENTRYLENGTH = INDEXENTRYLENGTH1
+        self.INDEXFORMAT = INDEXFORMAT2
+        self.INDEXENTRYLENGTH = INDEXENTRYLENGTH2
 
         self.NODEINDEXFORMAT = NODEINDEXFORMAT
         self.NODEINDEXENTRYLENGTH = NODEINDEXENTRYLENGTH
@@ -499,7 +479,6 @@
         fileindexlength = self.INDEXENTRYLENGTH
         nodeindexformat = self.NODEINDEXFORMAT
         nodeindexlength = self.NODEINDEXENTRYLENGTH
-        version = self.VERSION
 
         files = ((hashlib.sha1(filename).digest(), filename, offset, size)
                 for filename, (offset, size) in self.files.iteritems())
@@ -515,31 +494,27 @@
         nodecount = 0
         for namehash, filename, offset, size in files:
             # File section index
-            if version == 0:
-                rawentry = struct.pack(fileindexformat, namehash, offset, size)
-            else:
-                nodelocations = self.entrylocations[filename]
+            nodelocations = self.entrylocations[filename]
 
-                nodeindexsize = len(nodelocations) * nodeindexlength
+            nodeindexsize = len(nodelocations) * nodeindexlength
 
-                rawentry = struct.pack(fileindexformat, namehash, offset, size,
-                                       nodeindexoffset, nodeindexsize)
-                # Node index
-                nodeindexentries.append(struct.pack(constants.FILENAMESTRUCT,
-                                                    len(filename)) + filename)
-                nodeindexoffset += constants.FILENAMESIZE + len(filename)
+            rawentry = struct.pack(fileindexformat, namehash, offset, size,
+                                   nodeindexoffset, nodeindexsize)
+            # Node index
+            nodeindexentries.append(struct.pack(constants.FILENAMESTRUCT,
+                                                len(filename)) + filename)
+            nodeindexoffset += constants.FILENAMESIZE + len(filename)
 
-                for node, location in sorted(nodelocations.iteritems()):
-                    nodeindexentries.append(struct.pack(nodeindexformat, node,
-                                                        location))
-                    nodecount += 1
+            for node, location in sorted(nodelocations.iteritems()):
+                nodeindexentries.append(struct.pack(nodeindexformat, node,
+                                                    location))
+                nodecount += 1
 
-                nodeindexoffset += len(nodelocations) * nodeindexlength
+            nodeindexoffset += len(nodelocations) * nodeindexlength
 
             fileindexentries.append(rawentry)
 
         nodecountraw = ''
-        if version == 1:
-            nodecountraw = struct.pack('!Q', nodecount)
+        nodecountraw = struct.pack('!Q', nodecount)
         return (''.join(fileindexentries) + nodecountraw +
                 ''.join(nodeindexentries))
--- a/hgext/remotefilelog/repack.py	Wed Oct 03 23:47:43 2018 -0400
+++ b/hgext/remotefilelog/repack.py	Wed Oct 03 23:25:31 2018 -0400
@@ -345,10 +345,7 @@
     packer = repacker(repo, data, history, fullhistory, category,
                       gc=garbagecollect, isold=isold, options=options)
 
-    # internal config: remotefilelog.datapackversion
-    dv = repo.ui.configint('remotefilelog', 'datapackversion', 0)
-
-    with datapack.mutabledatapack(repo.ui, packpath, version=dv) as dpack:
+    with datapack.mutabledatapack(repo.ui, packpath, version=2) as dpack:
         with historypack.mutablehistorypack(repo.ui, packpath) as hpack:
             try:
                 packer.run(dpack, hpack)
--- a/tests/test-remotefilelog-bgprefetch.t	Wed Oct 03 23:47:43 2018 -0400
+++ b/tests/test-remotefilelog-bgprefetch.t	Wed Oct 03 23:25:31 2018 -0400
@@ -107,10 +107,10 @@
   $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>%1
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/94d53eef9e622533aec1fc6d8053cb086e785d21.histidx
-  $TESTTMP/hgcache/master/packs/94d53eef9e622533aec1fc6d8053cb086e785d21.histpack
-  $TESTTMP/hgcache/master/packs/f3644bc7773e8289deda7f765138120c838f4e6e.dataidx
-  $TESTTMP/hgcache/master/packs/f3644bc7773e8289deda7f765138120c838f4e6e.datapack
+  $TESTTMP/hgcache/master/packs/3616094d229ed39e2593f79c772676d4ec00253a.dataidx
+  $TESTTMP/hgcache/master/packs/3616094d229ed39e2593f79c772676d4ec00253a.datapack
+  $TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histidx
+  $TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -143,10 +143,10 @@
   $ sleep 1
   $ hg debugwaitonrepack >/dev/null 2>%1
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/27c52c105a1ddf8c75143a6b279b04c24b1f4bee.histidx
-  $TESTTMP/hgcache/master/packs/27c52c105a1ddf8c75143a6b279b04c24b1f4bee.histpack
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0.dataidx
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0.datapack
+  $TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
+  $TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46.dataidx
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46.datapack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -154,7 +154,7 @@
 # could only be downloaded by the background prefetch
 
   $ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1`
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0:
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46:
   w:
   Node          Delta Base    Delta Length  Blob Size
   bb6ccd5dceaa  000000000000  2             2
@@ -195,10 +195,10 @@
   $ sleep 1
   $ hg debugwaitonrepack >/dev/null 2>%1
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/27c52c105a1ddf8c75143a6b279b04c24b1f4bee.histidx
-  $TESTTMP/hgcache/master/packs/27c52c105a1ddf8c75143a6b279b04c24b1f4bee.histpack
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0.dataidx
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0.datapack
+  $TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
+  $TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46.dataidx
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46.datapack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -206,7 +206,7 @@
 # could only be downloaded by the background prefetch
 
   $ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1`
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0:
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46:
   w:
   Node          Delta Base    Delta Length  Blob Size
   bb6ccd5dceaa  000000000000  2             2
@@ -249,7 +249,7 @@
 # could only be downloaded by the background prefetch
 
   $ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1`
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0:
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46:
   w:
   Node          Delta Base    Delta Length  Blob Size
   bb6ccd5dceaa  000000000000  2             2
@@ -287,16 +287,16 @@
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/27c52c105a1ddf8c75143a6b279b04c24b1f4bee.histidx
-  $TESTTMP/hgcache/master/packs/27c52c105a1ddf8c75143a6b279b04c24b1f4bee.histpack
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0.dataidx
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0.datapack
+  $TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
+  $TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46.dataidx
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46.datapack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
 # Ensure that files were prefetched
   $ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1`
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0:
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46:
   w:
   Node          Delta Base    Delta Length  Blob Size
   bb6ccd5dceaa  000000000000  2             2
@@ -331,16 +331,16 @@
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/27c52c105a1ddf8c75143a6b279b04c24b1f4bee.histidx
-  $TESTTMP/hgcache/master/packs/27c52c105a1ddf8c75143a6b279b04c24b1f4bee.histpack
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0.dataidx
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0.datapack
+  $TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
+  $TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46.dataidx
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46.datapack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
 # Ensure that files were prefetched
   $ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1`
-  $TESTTMP/hgcache/master/packs/8299d5a1030f073f4adbb3b6bd2ad3bdcc276df0:
+  $TESTTMP/hgcache/master/packs/ac19aff076286bebe3ff108c96c6445a0fe27c46:
   w:
   Node          Delta Base    Delta Length  Blob Size
   bb6ccd5dceaa  000000000000  2             2
--- a/tests/test-remotefilelog-datapack.py	Wed Oct 03 23:47:43 2018 -0400
+++ b/tests/test-remotefilelog-datapack.py	Wed Oct 03 23:25:31 2018 -0400
@@ -49,15 +49,14 @@
     def getFakeHash(self):
         return ''.join(chr(random.randint(0, 255)) for _ in range(20))
 
-    def createPack(self, revisions=None, packdir=None, version=0):
+    def createPack(self, revisions=None, packdir=None):
         if revisions is None:
             revisions = [("filename", self.getFakeHash(), nullid, "content")]
 
         if packdir is None:
             packdir = self.makeTempDir()
 
-        packer = datapack.mutabledatapack(
-            uimod.ui(), packdir, version=version)
+        packer = datapack.mutabledatapack(uimod.ui(), packdir, version=2)
 
         for args in revisions:
             filename, node, base, content = args[0:4]
@@ -175,7 +174,7 @@
                     'Z': 'random_string',
                     '_': '\0' * i}
             revisions.append((filename, node, nullid, content, meta))
-        pack = self.createPack(revisions, version=1)
+        pack = self.createPack(revisions)
         for name, node, x, content, origmeta in revisions:
             parsedmeta = pack.getmeta(name, node)
             # flag == 0 should be optimized out
@@ -183,18 +182,6 @@
                 del origmeta[constants.METAKEYFLAG]
             self.assertEquals(parsedmeta, origmeta)
 
-    def testPackMetadataThrows(self):
-        filename = '1'
-        content = '2'
-        node = self.getHash(content)
-        meta = {constants.METAKEYFLAG: 3}
-        revisions = [(filename, node, nullid, content, meta)]
-        try:
-            self.createPack(revisions, version=0)
-            self.assertTrue(False, "should throw if metadata is not supported")
-        except RuntimeError:
-            pass
-
     def testGetMissing(self):
         """Test the getmissing() api.
         """
--- a/tests/test-remotefilelog-gc.t	Wed Oct 03 23:47:43 2018 -0400
+++ b/tests/test-remotefilelog-gc.t	Wed Oct 03 23:25:31 2018 -0400
@@ -90,10 +90,10 @@
 
 # Ensure that loose files are repacked
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/8d3499c65d926e4f107cf03c6b0df833222025b4.histidx
-  $TESTTMP/hgcache/master/packs/8d3499c65d926e4f107cf03c6b0df833222025b4.histpack
-  $TESTTMP/hgcache/master/packs/9c7046f8cad0417c39aa7c03ce13e0ba991306c2.dataidx
-  $TESTTMP/hgcache/master/packs/9c7046f8cad0417c39aa7c03ce13e0ba991306c2.datapack
+  $TESTTMP/hgcache/master/packs/173691d550fabb9d33db8da192f1c9bc62dd11a4.dataidx
+  $TESTTMP/hgcache/master/packs/173691d550fabb9d33db8da192f1c9bc62dd11a4.datapack
+  $TESTTMP/hgcache/master/packs/837b83c1ef6485a336eb4421ac5973c0ec130fbb.histidx
+  $TESTTMP/hgcache/master/packs/837b83c1ef6485a336eb4421ac5973c0ec130fbb.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
--- a/tests/test-remotefilelog-gcrepack.t	Wed Oct 03 23:47:43 2018 -0400
+++ b/tests/test-remotefilelog-gcrepack.t	Wed Oct 03 23:25:31 2018 -0400
@@ -45,13 +45,13 @@
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | grep ".datapack\|.histpack"
-  $TESTTMP/hgcache/master/packs/9a2ea858fe2967db9b6ea4c0ca238881cae9d6eb.histpack
-  $TESTTMP/hgcache/master/packs/f7a942a6e4673d2c7b697fdd926ca2d153831ca4.datapack
+  $TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack
+  $TESTTMP/hgcache/master/packs/be1bfed71a51645d8c3b9dc73e234e3a8ff06ac1.datapack
 
 # Ensure that all file versions were prefetched
 
   $ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1`
-  $TESTTMP/hgcache/master/packs/f7a942a6e4673d2c7b697fdd926ca2d153831ca4:
+  $TESTTMP/hgcache/master/packs/be1bfed71a51645d8c3b9dc73e234e3a8ff06ac1:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1406e7411862  000000000000  2             2
@@ -78,14 +78,14 @@
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | grep ".datapack\|.histpack"
-  $TESTTMP/hgcache/master/packs/05baa499c6b07f2bf0ea3d2c8151da1cb86f5e33.datapack
-  $TESTTMP/hgcache/master/packs/9a2ea858fe2967db9b6ea4c0ca238881cae9d6eb.histpack
+  $TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack
+  $TESTTMP/hgcache/master/packs/b868298fad9bf477b4e9d9455226c440b0135fe6.datapack
 
 # Ensure that file 'x' was garbage collected. It should be GCed because it is not in the keepset
 # and is old (commit date is 0.0 in tests). Ensure that file 'y' is present as it is in the keepset.
 
   $ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1`
-  $TESTTMP/hgcache/master/packs/05baa499c6b07f2bf0ea3d2c8151da1cb86f5e33:
+  $TESTTMP/hgcache/master/packs/b868298fad9bf477b4e9d9455226c440b0135fe6:
   y:
   Node          Delta Base    Delta Length  Blob Size
   50dbc4572b8e  000000000000  3             3
@@ -106,13 +106,13 @@
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | grep ".datapack\|.histpack"
-  $TESTTMP/hgcache/master/packs/9a2ea858fe2967db9b6ea4c0ca238881cae9d6eb.histpack
-  $TESTTMP/hgcache/master/packs/f7a942a6e4673d2c7b697fdd926ca2d153831ca4.datapack
+  $TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack
+  $TESTTMP/hgcache/master/packs/be1bfed71a51645d8c3b9dc73e234e3a8ff06ac1.datapack
 
 # Ensure that all file versions were prefetched
 
   $ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1`
-  $TESTTMP/hgcache/master/packs/f7a942a6e4673d2c7b697fdd926ca2d153831ca4:
+  $TESTTMP/hgcache/master/packs/be1bfed71a51645d8c3b9dc73e234e3a8ff06ac1:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1406e7411862  000000000000  2             2
@@ -140,13 +140,13 @@
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | grep ".datapack\|.histpack"
-  $TESTTMP/hgcache/master/packs/9a2ea858fe2967db9b6ea4c0ca238881cae9d6eb.histpack
-  $TESTTMP/hgcache/master/packs/f7a942a6e4673d2c7b697fdd926ca2d153831ca4.datapack
+  $TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack
+  $TESTTMP/hgcache/master/packs/be1bfed71a51645d8c3b9dc73e234e3a8ff06ac1.datapack
 
 # Ensure that all file versions were prefetched
 
   $ hg debugdatapack `ls -ct $TESTTMP/hgcache/master/packs/*.datapack | head -n 1`
-  $TESTTMP/hgcache/master/packs/f7a942a6e4673d2c7b697fdd926ca2d153831ca4:
+  $TESTTMP/hgcache/master/packs/be1bfed71a51645d8c3b9dc73e234e3a8ff06ac1:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1406e7411862  000000000000  2             2
--- a/tests/test-remotefilelog-histpack.py	Wed Oct 03 23:47:43 2018 -0400
+++ b/tests/test-remotefilelog-histpack.py	Wed Oct 03 23:25:31 2018 -0400
@@ -55,7 +55,7 @@
 
         packdir = self.makeTempDir()
         packer = historypack.mutablehistorypack(uimod.ui(), packdir,
-                                                version=1)
+                                                version=2)
 
         for filename, node, p1, p2, linknode, copyfrom in revisions:
             packer.add(filename, node, p1, p2, linknode, copyfrom)
--- a/tests/test-remotefilelog-repack-fast.t	Wed Oct 03 23:47:43 2018 -0400
+++ b/tests/test-remotefilelog-repack-fast.t	Wed Oct 03 23:25:31 2018 -0400
@@ -50,19 +50,19 @@
   $TESTTMP/hgcache
   $TESTTMP/hgcache/master
   $TESTTMP/hgcache/master/packs
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histidx
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histpack
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.dataidx
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.datapack
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.dataidx
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.datapack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
 # Test that the packs are readonly
   $ ls_l $CACHEDIR/master/packs
-  -r--r--r--    1145 276d308429d0303762befa376788300f0310f90e.histidx
-  -r--r--r--     172 276d308429d0303762befa376788300f0310f90e.histpack
-  -r--r--r--    1074 8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.dataidx
-  -r--r--r--      69 8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.datapack
+  -r--r--r--    1145 1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx
+  -r--r--r--     172 1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack
+  -r--r--r--    1074 add67cb28ae0a2962111588ce49467ca9ebb9195.dataidx
+  -r--r--r--      69 add67cb28ae0a2962111588ce49467ca9ebb9195.datapack
   -rw-r--r--       0 repacklock
 
 # Test that the data in the new packs is accessible
@@ -83,20 +83,20 @@
 
   $ find $CACHEDIR -type f | sort
   $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/d4a3ed9310e5bd9887e3bf779da5077efab28216
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histidx
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histpack
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.dataidx
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.datapack
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.dataidx
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.datapack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
   $ hg repack --traceback
 
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histidx
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.dataidx
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.datapack
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.dataidx
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.datapack
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histidx
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -113,10 +113,10 @@
 # and did not change the pack names
   $ hg repack
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histidx
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.dataidx
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.datapack
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.dataidx
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.datapack
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histidx
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -137,10 +137,10 @@
   1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
   $ find $CACHEDIR -type f | sort
   $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1bb2e6237e035c8f8ef508e281f1ce075bc6db72
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histidx
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.dataidx
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.datapack
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.dataidx
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.datapack
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histidx
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -149,17 +149,17 @@
   $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/094b530486dad4427a0faf6bcbc031571b99ca24.histidx
-  $TESTTMP/hgcache/master/packs/094b530486dad4427a0faf6bcbc031571b99ca24.histpack
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15.dataidx
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15.datapack
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123.dataidx
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123.datapack
+  $TESTTMP/hgcache/master/packs/604552d403a1381749faf656feca0ca265a6d52c.histidx
+  $TESTTMP/hgcache/master/packs/604552d403a1381749faf656feca0ca265a6d52c.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
 # Test debug commands
 
   $ hg debugdatapack $TESTTMP/hgcache/master/packs/*.datapack
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15:
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1bb2e6237e03  000000000000  8             8
@@ -168,7 +168,7 @@
   
   Total:                      32            18        (77.8% bigger)
   $ hg debugdatapack --long $TESTTMP/hgcache/master/packs/*.datapack
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15:
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123:
   x:
   Node                                      Delta Base                                Delta Length  Blob Size
   1bb2e6237e035c8f8ef508e281f1ce075bc6db72  0000000000000000000000000000000000000000  8             8
@@ -177,7 +177,7 @@
   
   Total:                                                                              32            18        (77.8% bigger)
   $ hg debugdatapack $TESTTMP/hgcache/master/packs/*.datapack --node d4a3ed9310e5bd9887e3bf779da5077efab28216
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15:
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123:
   
   x
   Node                                      Delta Base                                Delta SHA1                                Delta Length
@@ -226,10 +226,10 @@
   2 files fetched over 2 fetches - (2 misses, 0.00% hit ratio) over * (glob)
   $ hg repack
   $ ls $TESTTMP/hgcache/master/packs
-  e8fdf7ae22b772dcc291f905b9c6e5f381d28739.dataidx
-  e8fdf7ae22b772dcc291f905b9c6e5f381d28739.datapack
-  ebbd7411e00456c0eec8d1150a77e2b3ef490f3f.histidx
-  ebbd7411e00456c0eec8d1150a77e2b3ef490f3f.histpack
+  308a7aba9c54a0b71ae5adbbccd00c0aff20876e.dataidx
+  308a7aba9c54a0b71ae5adbbccd00c0aff20876e.datapack
+  bfd60adb76018bb952e27cd23fc151bf94865d7d.histidx
+  bfd60adb76018bb952e27cd23fc151bf94865d7d.histpack
   repacklock
   $ hg debughistorypack $TESTTMP/hgcache/master/packs/*.histidx
   
@@ -259,7 +259,7 @@
   $ rm -rf $CACHEDIR/master/packs/*hist*
   $ hg repack
   $ hg debugdatapack $TESTTMP/hgcache/master/packs/*.datapack
-  $TESTTMP/hgcache/master/packs/a8d86ff8e1a11a77a85f5fea567f56a757583eda:
+  $TESTTMP/hgcache/master/packs/ba4649b56263282b0699f9a6e7e34a4a2bac1638:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1bb2e6237e03  000000000000  8             8
@@ -296,9 +296,9 @@
   [1]
   $ hg repack --incremental
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--      67 b5a62f3496ccbd2479497cdbc7345f3304735f33.datapack
+  -r--r--r--      67 6409c5a1d61b251906689d4d1282ac44df6a7898.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--      90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack
+  -r--r--r--      90 955a622173324b2d8b53e1147f209f1cf125302e.histpack
 
 3 gen1 packs, 1 gen0 pack - packs 3 gen1 into 1
   $ hg prefetch -r 1
@@ -308,25 +308,25 @@
   $ hg prefetch -r 3
   1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--      67 b5a62f3496ccbd2479497cdbc7345f3304735f33.datapack
+  -r--r--r--      67 6409c5a1d61b251906689d4d1282ac44df6a7898.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--      90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack
+  -r--r--r--      90 955a622173324b2d8b53e1147f209f1cf125302e.histpack
   $ hg repack --incremental
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--     225 8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15.datapack
-  -r--r--r--      67 b5a62f3496ccbd2479497cdbc7345f3304735f33.datapack
+  -r--r--r--     225 06ae46494f0e3b9beda53eae8fc0e55139f13123.datapack
+  -r--r--r--      67 6409c5a1d61b251906689d4d1282ac44df6a7898.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--     336 094b530486dad4427a0faf6bcbc031571b99ca24.histpack
-  -r--r--r--      90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack
+  -r--r--r--     336 604552d403a1381749faf656feca0ca265a6d52c.histpack
+  -r--r--r--      90 955a622173324b2d8b53e1147f209f1cf125302e.histpack
 
 1 gen3 pack, 1 gen0 pack - does nothing
   $ hg repack --incremental
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--     225 8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15.datapack
-  -r--r--r--      67 b5a62f3496ccbd2479497cdbc7345f3304735f33.datapack
+  -r--r--r--     225 06ae46494f0e3b9beda53eae8fc0e55139f13123.datapack
+  -r--r--r--      67 6409c5a1d61b251906689d4d1282ac44df6a7898.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--     336 094b530486dad4427a0faf6bcbc031571b99ca24.histpack
-  -r--r--r--      90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack
+  -r--r--r--     336 604552d403a1381749faf656feca0ca265a6d52c.histpack
+  -r--r--r--      90 955a622173324b2d8b53e1147f209f1cf125302e.histpack
 
 Pull should run background repack
   $ cat >> .hg/hgrc <<EOF
@@ -351,9 +351,9 @@
   $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>&1
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--     301 09b8bf49256b3fc2175977ba97d6402e91a9a604.datapack
+  -r--r--r--     301 671913bebdb7b95aae52a546662753eac7606e40.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--     336 094b530486dad4427a0faf6bcbc031571b99ca24.histpack
+  -r--r--r--     336 604552d403a1381749faf656feca0ca265a6d52c.histpack
 
 Test environment variable resolution
   $ CACHEPATH=$TESTTMP/envcache hg prefetch --config 'remotefilelog.cachepath=$CACHEPATH'
--- a/tests/test-remotefilelog-repack.t	Wed Oct 03 23:47:43 2018 -0400
+++ b/tests/test-remotefilelog-repack.t	Wed Oct 03 23:25:31 2018 -0400
@@ -45,19 +45,19 @@
   $TESTTMP/hgcache
   $TESTTMP/hgcache/master
   $TESTTMP/hgcache/master/packs
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histidx
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histpack
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.dataidx
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.datapack
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.dataidx
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.datapack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
 # Test that the packs are readonly
   $ ls_l $CACHEDIR/master/packs
-  -r--r--r--    1145 276d308429d0303762befa376788300f0310f90e.histidx
-  -r--r--r--     172 276d308429d0303762befa376788300f0310f90e.histpack
-  -r--r--r--    1074 8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.dataidx
-  -r--r--r--      69 8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.datapack
+  -r--r--r--    1145 1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx
+  -r--r--r--     172 1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack
+  -r--r--r--    1074 add67cb28ae0a2962111588ce49467ca9ebb9195.dataidx
+  -r--r--r--      69 add67cb28ae0a2962111588ce49467ca9ebb9195.datapack
   -rw-r--r--       0 repacklock
 
 # Test that the data in the new packs is accessible
@@ -78,10 +78,10 @@
 
   $ find $CACHEDIR -type f | sort
   $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/d4a3ed9310e5bd9887e3bf779da5077efab28216
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histidx
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histpack
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.dataidx
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.datapack
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.dataidx
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.datapack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -91,20 +91,20 @@
 
   $ find $CACHEDIR -type f | sort
   $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/d4a3ed9310e5bd9887e3bf779da5077efab28216
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histidx
-  $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histpack
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.dataidx
-  $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.datapack
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histidx
+  $TESTTMP/hgcache/master/packs/1e91b207daf5d7b48f1be9c587d6b5ae654ce78c.histpack
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.dataidx
+  $TESTTMP/hgcache/master/packs/add67cb28ae0a2962111588ce49467ca9ebb9195.datapack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
   $ hg repack --traceback
 
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histidx
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.dataidx
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.datapack
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.dataidx
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.datapack
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histidx
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -121,10 +121,10 @@
 # and did not change the pack names
   $ hg repack
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histidx
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.dataidx
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.datapack
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.dataidx
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.datapack
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histidx
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -145,10 +145,10 @@
   1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
   $ find $CACHEDIR -type f | sort
   $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/1bb2e6237e035c8f8ef508e281f1ce075bc6db72
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histidx
-  $TESTTMP/hgcache/master/packs/077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.dataidx
-  $TESTTMP/hgcache/master/packs/935861cae0be6ce41a0d47a529e4d097e9e68a69.datapack
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.dataidx
+  $TESTTMP/hgcache/master/packs/1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.datapack
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histidx
+  $TESTTMP/hgcache/master/packs/8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
@@ -157,17 +157,17 @@
   $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
-  $TESTTMP/hgcache/master/packs/094b530486dad4427a0faf6bcbc031571b99ca24.histidx
-  $TESTTMP/hgcache/master/packs/094b530486dad4427a0faf6bcbc031571b99ca24.histpack
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15.dataidx
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15.datapack
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123.dataidx
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123.datapack
+  $TESTTMP/hgcache/master/packs/604552d403a1381749faf656feca0ca265a6d52c.histidx
+  $TESTTMP/hgcache/master/packs/604552d403a1381749faf656feca0ca265a6d52c.histpack
   $TESTTMP/hgcache/master/packs/repacklock
   $TESTTMP/hgcache/repos
 
 # Test debug commands
 
   $ hg debugdatapack $TESTTMP/hgcache/master/packs/*.datapack
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15:
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1bb2e6237e03  000000000000  8             8
@@ -176,7 +176,7 @@
   
   Total:                      32            18        (77.8% bigger)
   $ hg debugdatapack --long $TESTTMP/hgcache/master/packs/*.datapack
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15:
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123:
   x:
   Node                                      Delta Base                                Delta Length  Blob Size
   1bb2e6237e035c8f8ef508e281f1ce075bc6db72  0000000000000000000000000000000000000000  8             8
@@ -185,7 +185,7 @@
   
   Total:                                                                              32            18        (77.8% bigger)
   $ hg debugdatapack $TESTTMP/hgcache/master/packs/*.datapack --node d4a3ed9310e5bd9887e3bf779da5077efab28216
-  $TESTTMP/hgcache/master/packs/8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15:
+  $TESTTMP/hgcache/master/packs/06ae46494f0e3b9beda53eae8fc0e55139f13123:
   
   x
   Node                                      Delta Base                                Delta SHA1                                Delta Length
@@ -234,10 +234,10 @@
   2 files fetched over 2 fetches - (2 misses, 0.00% hit ratio) over * (glob)
   $ hg repack
   $ ls $TESTTMP/hgcache/master/packs
-  e8fdf7ae22b772dcc291f905b9c6e5f381d28739.dataidx
-  e8fdf7ae22b772dcc291f905b9c6e5f381d28739.datapack
-  ebbd7411e00456c0eec8d1150a77e2b3ef490f3f.histidx
-  ebbd7411e00456c0eec8d1150a77e2b3ef490f3f.histpack
+  308a7aba9c54a0b71ae5adbbccd00c0aff20876e.dataidx
+  308a7aba9c54a0b71ae5adbbccd00c0aff20876e.datapack
+  bfd60adb76018bb952e27cd23fc151bf94865d7d.histidx
+  bfd60adb76018bb952e27cd23fc151bf94865d7d.histpack
   repacklock
   $ hg debughistorypack $TESTTMP/hgcache/master/packs/*.histidx
   
@@ -267,7 +267,7 @@
   $ rm -rf $CACHEDIR/master/packs/*hist*
   $ hg repack
   $ hg debugdatapack $TESTTMP/hgcache/master/packs/*.datapack
-  $TESTTMP/hgcache/master/packs/a8d86ff8e1a11a77a85f5fea567f56a757583eda:
+  $TESTTMP/hgcache/master/packs/ba4649b56263282b0699f9a6e7e34a4a2bac1638:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1bb2e6237e03  000000000000  8             8
@@ -304,9 +304,9 @@
   [1]
   $ hg repack --incremental
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--      67 b5a62f3496ccbd2479497cdbc7345f3304735f33.datapack
+  -r--r--r--      67 6409c5a1d61b251906689d4d1282ac44df6a7898.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--      90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack
+  -r--r--r--      90 955a622173324b2d8b53e1147f209f1cf125302e.histpack
 
 3 gen1 packs, 1 gen0 pack - packs 3 gen1 into 1
   $ hg prefetch -r 1
@@ -317,9 +317,9 @@
   abort: unknown revision '38'!
   [255]
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--      67 b5a62f3496ccbd2479497cdbc7345f3304735f33.datapack
+  -r--r--r--      67 6409c5a1d61b251906689d4d1282ac44df6a7898.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--      90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack
+  -r--r--r--      90 955a622173324b2d8b53e1147f209f1cf125302e.histpack
 
 For the data packs, setting the limit for the repackmaxpacksize to be 64 such
 that data pack with size 65 is more than the limit. This effectively ensures
@@ -329,31 +329,31 @@
   $ hg repack --incremental --config remotefilelog.data.repackmaxpacksize=64 \
   > --config remotefilelog.history.repackmaxpacksize=0
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--     147 935861cae0be6ce41a0d47a529e4d097e9e68a69.datapack
-  -r--r--r--      67 b5a62f3496ccbd2479497cdbc7345f3304735f33.datapack
+  -r--r--r--     147 1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.datapack
+  -r--r--r--      67 6409c5a1d61b251906689d4d1282ac44df6a7898.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--     254 077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack
-  -r--r--r--      90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack
+  -r--r--r--     254 8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack
+  -r--r--r--      90 955a622173324b2d8b53e1147f209f1cf125302e.histpack
 
 Setting limit for the repackmaxpacksize to be the size of the biggest pack file
 which ensures that it is effectively ignored in the incremental repacking.
   $ hg repack --incremental --config remotefilelog.data.repackmaxpacksize=65 \
   > --config remotefilelog.history.repackmaxpacksize=336
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--     147 935861cae0be6ce41a0d47a529e4d097e9e68a69.datapack
-  -r--r--r--      67 b5a62f3496ccbd2479497cdbc7345f3304735f33.datapack
+  -r--r--r--     147 1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.datapack
+  -r--r--r--      67 6409c5a1d61b251906689d4d1282ac44df6a7898.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--     254 077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack
-  -r--r--r--      90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack
+  -r--r--r--     254 8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack
+  -r--r--r--      90 955a622173324b2d8b53e1147f209f1cf125302e.histpack
 
 1 gen3 pack, 1 gen0 pack - does nothing
   $ hg repack --incremental
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--     147 935861cae0be6ce41a0d47a529e4d097e9e68a69.datapack
-  -r--r--r--      67 b5a62f3496ccbd2479497cdbc7345f3304735f33.datapack
+  -r--r--r--     147 1bd27e610ee06450e5f3bb0cd3afb6870e4cf375.datapack
+  -r--r--r--      67 6409c5a1d61b251906689d4d1282ac44df6a7898.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--     254 077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack
-  -r--r--r--      90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack
+  -r--r--r--     254 8abe7889aae389337d12ebe6085d4ee13854c7c9.histpack
+  -r--r--r--      90 955a622173324b2d8b53e1147f209f1cf125302e.histpack
 
 Pull should run background repack
   $ cat >> .hg/hgrc <<EOF
@@ -378,9 +378,9 @@
   $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>&1
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
-  -r--r--r--     301 09b8bf49256b3fc2175977ba97d6402e91a9a604.datapack
+  -r--r--r--     301 671913bebdb7b95aae52a546662753eac7606e40.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
-  -r--r--r--     336 094b530486dad4427a0faf6bcbc031571b99ca24.histpack
+  -r--r--r--     336 604552d403a1381749faf656feca0ca265a6d52c.histpack
 
 Test environment variable resolution
   $ CACHEPATH=$TESTTMP/envcache hg prefetch --config 'remotefilelog.cachepath=$CACHEPATH'
@@ -414,7 +414,7 @@
 Test limiting the max delta chain length
   $ hg repack --config packs.maxchainlen=1
   $ hg debugdatapack $TESTTMP/hgcache/master/packs/*.dataidx
-  $TESTTMP/hgcache/master/packs/a8378d888fe4325250720e51311a65d2509be742:
+  $TESTTMP/hgcache/master/packs/80f7c299aeb22849ebc28fbd11bb76078aa55918:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1bb2e6237e03  000000000000  8             8
@@ -432,8 +432,8 @@
 Test huge pack cleanup using different values of packs.maxpacksize:
   $ hg repack --incremental --debug
   $ hg repack --incremental --debug --config packs.maxpacksize=512
-  removing oversize packfile $TESTTMP/hgcache/master/packs/a8378d888fe4325250720e51311a65d2509be742.datapack (426 bytes)
-  removing oversize packfile $TESTTMP/hgcache/master/packs/a8378d888fe4325250720e51311a65d2509be742.dataidx (1.21 KB)
+  removing oversize packfile $TESTTMP/hgcache/master/packs/80f7c299aeb22849ebc28fbd11bb76078aa55918.datapack (426 bytes)
+  removing oversize packfile $TESTTMP/hgcache/master/packs/80f7c299aeb22849ebc28fbd11bb76078aa55918.dataidx (1.21 KB)
 
 Do a repack where the new pack reuses a delta from the old pack
   $ clearcache
@@ -441,7 +441,7 @@
   2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over * (glob)
   $ hg repack
   $ hg debugdatapack $CACHEDIR/master/packs/*.datapack
-  $TESTTMP/hgcache/master/packs/abf210f6c3aa4dd0ecc7033633ad73591be16c95:
+  $TESTTMP/hgcache/master/packs/90cfb1a45e2549500caace30add04b58a6b243af:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1bb2e6237e03  000000000000  8             8
@@ -452,7 +452,7 @@
   2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over * (glob)
   $ hg repack
   $ hg debugdatapack $CACHEDIR/master/packs/*.datapack
-  $TESTTMP/hgcache/master/packs/09b8bf49256b3fc2175977ba97d6402e91a9a604:
+  $TESTTMP/hgcache/master/packs/671913bebdb7b95aae52a546662753eac7606e40:
   x:
   Node          Delta Base    Delta Length  Blob Size
   1bb2e6237e03  000000000000  8             8