##// END OF EJS Templates
remotefilelog: reduce probability of race-condition in remotefilelog tests...
Boris Feld -
r43110:2c74337e default
parent child Browse files
Show More
@@ -224,6 +224,8 b" configitem('repack', 'chainorphansbysize"
224 224 configitem('packs', 'maxpacksize', default=0)
225 225 configitem('packs', 'maxchainlen', default=1000)
226 226
227 configitem('devel', 'remotefilelog.ensurestart', default=False)
228
227 229 # default TTL limit is 30 days
228 230 _defaultlimit = 60 * 60 * 24 * 30
229 231 configitem('remotefilelog', 'nodettl', default=_defaultlimit)
@@ -949,19 +951,23 b' def pull(orig, ui, repo, *pats, **opts):'
949 951 prefetchrevset = ui.config('remotefilelog', 'pullprefetch')
950 952 bgrepack = repo.ui.configbool('remotefilelog', 'backgroundrepack')
951 953 bgprefetch = repo.ui.configbool('remotefilelog', 'backgroundprefetch')
954 ensurestart = repo.ui.configbool('devel', 'remotefilelog.ensurestart')
952 955
953 956 if prefetchrevset:
954 957 ui.status(_("prefetching file contents\n"))
955 958 revs = scmutil.revrange(repo, [prefetchrevset])
956 959 base = repo['.'].rev()
957 960 if bgprefetch:
958 repo.backgroundprefetch(prefetchrevset, repack=bgrepack)
961 repo.backgroundprefetch(prefetchrevset, repack=bgrepack,
962 ensurestart=ensurestart)
959 963 else:
960 964 repo.prefetch(revs, base=base)
961 965 if bgrepack:
962 repackmod.backgroundrepack(repo, incremental=True)
966 repackmod.backgroundrepack(repo, incremental=True,
967 ensurestart=ensurestart)
963 968 elif bgrepack:
964 repackmod.backgroundrepack(repo, incremental=True)
969 repackmod.backgroundrepack(repo, incremental=True,
970 ensurestart=ensurestart)
965 971
966 972 return result
967 973
@@ -1085,9 +1091,12 b' def prefetch(ui, repo, *pats, **opts):'
1085 1091 revs = scmutil.revrange(repo, opts.get('rev'))
1086 1092 repo.prefetch(revs, opts.get('base'), pats, opts)
1087 1093
1094 ensurestart = repo.ui.configbool('devel', 'remotefilelog.ensurestart')
1095
1088 1096 # Run repack in background
1089 1097 if opts.get('repack'):
1090 repackmod.backgroundrepack(repo, incremental=True)
1098 repackmod.backgroundrepack(repo, incremental=True,
1099 ensurestart=ensurestart)
1091 1100
1092 1101 @command('repack', [
1093 1102 ('', 'background', None, _('run in a background process'), None),
@@ -1096,8 +1105,10 b' def prefetch(ui, repo, *pats, **opts):'
1096 1105 ], _('hg repack [OPTIONS]'))
1097 1106 def repack_(ui, repo, *pats, **opts):
1098 1107 if opts.get(r'background'):
1108 ensurestart = repo.ui.configbool('devel', 'remotefilelog.ensurestart')
1099 1109 repackmod.backgroundrepack(repo, incremental=opts.get(r'incremental'),
1100 packsonly=opts.get(r'packsonly', False))
1110 packsonly=opts.get(r'packsonly', False),
1111 ensurestart=ensurestart)
1101 1112 return
1102 1113
1103 1114 options = {'packsonly': opts.get(r'packsonly')}
@@ -34,7 +34,8 b" osutil = policy.importmod(r'osutil')"
34 34 class RepackAlreadyRunning(error.Abort):
35 35 pass
36 36
37 def backgroundrepack(repo, incremental=True, packsonly=False):
37 def backgroundrepack(repo, incremental=True, packsonly=False,
38 ensurestart=False):
38 39 cmd = [procutil.hgexecutable(), '-R', repo.origroot, 'repack']
39 40 msg = _("(running background repack)\n")
40 41 if incremental:
@@ -44,7 +45,7 b' def backgroundrepack(repo, incremental=T'
44 45 cmd.append('--packsonly')
45 46 repo.ui.warn(msg)
46 47 # We know this command will find a binary, so don't block on it starting.
47 procutil.runbgcommand(cmd, encoding.environ, ensurestart=False)
48 procutil.runbgcommand(cmd, encoding.environ, ensurestart=ensurestart)
48 49
49 50 def fullrepack(repo, options=None):
50 51 """If ``packsonly`` is True, stores creating only loose objects are skipped.
@@ -183,7 +183,7 b' def wraprepo(repo):'
183 183 origctx=origctx)
184 184
185 185 def backgroundprefetch(self, revs, base=None, repack=False, pats=None,
186 opts=None):
186 opts=None, ensurestart=False):
187 187 """Runs prefetch in background with optional repack
188 188 """
189 189 cmd = [procutil.hgexecutable(), '-R', repo.origroot, 'prefetch']
@@ -193,7 +193,8 b' def wraprepo(repo):'
193 193 cmd += ['-r', revs]
194 194 # We know this command will find a binary, so don't block
195 195 # on it starting.
196 procutil.runbgcommand(cmd, encoding.environ, ensurestart=False)
196 procutil.runbgcommand(cmd, encoding.environ,
197 ensurestart=ensurestart)
197 198
198 199 def prefetch(self, revs, base=None, pats=None, opts=None):
199 200 """Prefetches all the necessary file revisions for the given revs
@@ -1,6 +1,12 b''
1 1 #require no-windows
2 2
3 3 $ . "$TESTDIR/remotefilelog-library.sh"
4 # devel.remotefilelog.ensurestart: reduce race condition with
5 # waiton{repack/prefetch}
6 $ cat >> $HGRCPATH <<EOF
7 > [devel]
8 > remotefilelog.ensurestart=True
9 > EOF
4 10
5 11 $ hg init master
6 12 $ cd master
@@ -1,10 +1,13 b''
1 1 #require no-windows
2 2
3 3 $ . "$TESTDIR/remotefilelog-library.sh"
4
4 # devel.remotefilelog.ensurestart: reduce race condition with
5 # waiton{repack/prefetch}
5 6 $ cat >> $HGRCPATH <<EOF
6 7 > [remotefilelog]
7 8 > fastdatapack=True
9 > [devel]
10 > remotefilelog.ensurestart=True
8 11 > EOF
9 12
10 13 $ hg init master
@@ -1,6 +1,12 b''
1 1 #require no-windows
2 2
3 3 $ . "$TESTDIR/remotefilelog-library.sh"
4 # devel.remotefilelog.ensurestart: reduce race condition with
5 # waiton{repack/prefetch}
6 $ cat >> $HGRCPATH <<EOF
7 > [devel]
8 > remotefilelog.ensurestart=True
9 > EOF
4 10
5 11 $ hg init master
6 12 $ cd master
General Comments 0
You need to be logged in to leave comments. Login now