comparison mercurial/manifest.py @ 29940:fa145a205a7f

manifest: move revlog specific options from manifest to manifestrevlog The manifestv2 and treeondisk options are specific to how we serialize the manifest into revlogs, so let's move them onto the manifestrevlog class. This will allow us to add a manifestlog.add() function in a future diff that will rely on manifestrevlog to make decisions about how to serialize the given manifest to disk. We have to move a little bit of extra logic about the 'dir' as well, since it is used in conjunction with the treeondisk option to decide the revlog file name. It's probably good to move this down to the manifestrevlog class anyway, since it's specific to the revlog.
author Durham Goode <durham@fb.com>
date Tue, 13 Sep 2016 16:00:41 -0700
parents 80be4436e4cc
children 1cc93a154723
comparison
equal deleted inserted replaced
29939:80be4436e4cc 29940:fa145a205a7f
894 894
895 class manifestrevlog(revlog.revlog): 895 class manifestrevlog(revlog.revlog):
896 '''A revlog that stores manifest texts. This is responsible for caching the 896 '''A revlog that stores manifest texts. This is responsible for caching the
897 full-text manifest contents. 897 full-text manifest contents.
898 ''' 898 '''
899 def __init__(self, opener, indexfile): 899 def __init__(self, opener, dir=''):
900 super(manifestrevlog, self).__init__(opener, indexfile)
901
902 # During normal operations, we expect to deal with not more than four 900 # During normal operations, we expect to deal with not more than four
903 # revs at a time (such as during commit --amend). When rebasing large 901 # revs at a time (such as during commit --amend). When rebasing large
904 # stacks of commits, the number can go up, hence the config knob below. 902 # stacks of commits, the number can go up, hence the config knob below.
905 cachesize = 4 903 cachesize = 4
904 usetreemanifest = False
905 usemanifestv2 = False
906 opts = getattr(opener, 'options', None) 906 opts = getattr(opener, 'options', None)
907 if opts is not None: 907 if opts is not None:
908 cachesize = opts.get('manifestcachesize', cachesize) 908 cachesize = opts.get('manifestcachesize', cachesize)
909 usetreemanifest = opts.get('treemanifest', usetreemanifest)
910 usemanifestv2 = opts.get('manifestv2', usemanifestv2)
911
912 self._treeondisk = usetreemanifest
913 self._usemanifestv2 = usemanifestv2
914
909 self._fulltextcache = util.lrucachedict(cachesize) 915 self._fulltextcache = util.lrucachedict(cachesize)
916
917 indexfile = "00manifest.i"
918 if dir:
919 assert self._treeondisk, 'opts is %r' % opts
920 if not dir.endswith('/'):
921 dir = dir + '/'
922 indexfile = "meta/" + dir + "00manifest.i"
923 self._dir = dir
924
925 super(manifestrevlog, self).__init__(opener, indexfile)
910 926
911 @property 927 @property
912 def fulltextcache(self): 928 def fulltextcache(self):
913 return self._fulltextcache 929 return self._fulltextcache
914 930
1091 # During normal operations, we expect to deal with not more than four 1107 # During normal operations, we expect to deal with not more than four
1092 # revs at a time (such as during commit --amend). When rebasing large 1108 # revs at a time (such as during commit --amend). When rebasing large
1093 # stacks of commits, the number can go up, hence the config knob below. 1109 # stacks of commits, the number can go up, hence the config knob below.
1094 cachesize = 4 1110 cachesize = 4
1095 usetreemanifest = False 1111 usetreemanifest = False
1096 usemanifestv2 = False
1097 opts = getattr(opener, 'options', None) 1112 opts = getattr(opener, 'options', None)
1098 if opts is not None: 1113 if opts is not None:
1099 cachesize = opts.get('manifestcachesize', cachesize) 1114 cachesize = opts.get('manifestcachesize', cachesize)
1100 usetreemanifest = opts.get('treemanifest', usetreemanifest) 1115 usetreemanifest = opts.get('treemanifest', usetreemanifest)
1101 usemanifestv2 = opts.get('manifestv2', usemanifestv2)
1102 self._mancache = util.lrucachedict(cachesize) 1116 self._mancache = util.lrucachedict(cachesize)
1103 self._treeinmem = usetreemanifest 1117 self._treeinmem = usetreemanifest
1104 self._treeondisk = usetreemanifest 1118 super(manifest, self).__init__(opener, dir=dir)
1105 self._usemanifestv2 = usemanifestv2
1106 indexfile = "00manifest.i"
1107 if dir:
1108 assert self._treeondisk, 'opts is %r' % opts
1109 if not dir.endswith('/'):
1110 dir = dir + '/'
1111 indexfile = "meta/" + dir + "00manifest.i"
1112 super(manifest, self).__init__(opener, indexfile)
1113 self._dir = dir
1114 # The dirlogcache is kept on the root manifest log 1119 # The dirlogcache is kept on the root manifest log
1115 if dir: 1120 if dir:
1116 self._dirlogcache = dirlogcache 1121 self._dirlogcache = dirlogcache
1117 else: 1122 else:
1118 self._dirlogcache = {'': self} 1123 self._dirlogcache = {'': self}