author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Tue, 14 Apr 2020 04:23:20 +0200 | |
changeset 44796 | d36283e20833 |
parent 43117 | 8ff1ecfadcd1 |
child 48875 | 6000f5b25c9b |
permissions | -rw-r--r-- |
40999
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
1 |
# repocache.py - in-memory repository cache for long-running services |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
2 |
# |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
3 |
# Copyright 2018 Yuya Nishihara <yuya@tcha.org> |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
4 |
# |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
6 |
# GNU General Public License version 2 or any later version. |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
7 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
8 |
from __future__ import absolute_import |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
9 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
10 |
import collections |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
11 |
import gc |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
12 |
import threading |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
13 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
14 |
from . import ( |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
15 |
error, |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
16 |
hg, |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
17 |
obsolete, |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
18 |
scmutil, |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
19 |
util, |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
20 |
) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
21 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
22 |
|
40999
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
23 |
class repoloader(object): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
24 |
"""Load repositories in background thread |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
25 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
26 |
This is designed for a forking server. A cached repo cannot be obtained |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
27 |
until the server fork()s a worker and the loader thread stops. |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
28 |
""" |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
29 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
30 |
def __init__(self, ui, maxlen): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
31 |
self._ui = ui.copy() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
32 |
self._cache = util.lrucachedict(max=maxlen) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
33 |
# use deque and Event instead of Queue since deque can discard |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
34 |
# old items to keep at most maxlen items. |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
35 |
self._inqueue = collections.deque(maxlen=maxlen) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
36 |
self._accepting = False |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
37 |
self._newentry = threading.Event() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
38 |
self._thread = None |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
39 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
40 |
def start(self): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
41 |
assert not self._thread |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
42 |
if self._inqueue.maxlen == 0: |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
43 |
# no need to spawn loader thread as the cache is disabled |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
44 |
return |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
45 |
self._accepting = True |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
46 |
self._thread = threading.Thread(target=self._mainloop) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
47 |
self._thread.start() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
48 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
49 |
def stop(self): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
50 |
if not self._thread: |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
51 |
return |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
52 |
self._accepting = False |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
53 |
self._newentry.set() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
54 |
self._thread.join() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
55 |
self._thread = None |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
56 |
self._cache.clear() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
57 |
self._inqueue.clear() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
58 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
59 |
def load(self, path): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
60 |
"""Request to load the specified repository in background""" |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
61 |
self._inqueue.append(path) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
62 |
self._newentry.set() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
63 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
64 |
def get(self, path): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
65 |
"""Return a cached repo if available |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
66 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
67 |
This function must be called after fork(), where the loader thread |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
68 |
is stopped. Otherwise, the returned repo might be updated by the |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
69 |
loader thread. |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
70 |
""" |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
71 |
if self._thread and self._thread.is_alive(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
72 |
raise error.ProgrammingError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43077
diff
changeset
|
73 |
b'cannot obtain cached repo while loader is active' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
74 |
) |
40999
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
75 |
return self._cache.peek(path, None) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
76 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
77 |
def _mainloop(self): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
78 |
while self._accepting: |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
79 |
# Avoid heavy GC after fork(), which would cancel the benefit of |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
80 |
# COW. We assume that GIL is acquired while GC is underway in the |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
81 |
# loader thread. If that isn't true, we might have to move |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
82 |
# gc.collect() to the main thread so that fork() would never stop |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
83 |
# the thread where GC is in progress. |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
84 |
gc.collect() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
85 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
86 |
self._newentry.wait() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
87 |
while self._accepting: |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
88 |
self._newentry.clear() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
89 |
try: |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
90 |
path = self._inqueue.popleft() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
91 |
except IndexError: |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
92 |
break |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
93 |
scmutil.callcatch(self._ui, lambda: self._load(path)) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
94 |
|
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
95 |
def _load(self, path): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
96 |
start = util.timer() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
97 |
# TODO: repo should be recreated if storage configuration changed |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
98 |
try: |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
99 |
# pop before loading so inconsistent state wouldn't be exposed |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
100 |
repo = self._cache.pop(path) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
101 |
except KeyError: |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
102 |
repo = hg.repository(self._ui, path).unfiltered() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
103 |
_warmupcache(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
104 |
repo.ui.log( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
105 |
b'repocache', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
106 |
b'loaded repo into cache: %s (in %.3fs)\n', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
107 |
path, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
108 |
util.timer() - start, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
109 |
) |
40999
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
110 |
self._cache.insert(path, repo) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
111 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
112 |
|
40999
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
113 |
# TODO: think about proper API of preloading cache |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
114 |
def _warmupcache(repo): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
115 |
repo.invalidateall() |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
116 |
repo.changelog |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
117 |
repo.obsstore._all |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
118 |
repo.obsstore.successors |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
119 |
repo.obsstore.predecessors |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
120 |
repo.obsstore.children |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
121 |
for name in obsolete.cachefuncs: |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
122 |
obsolete.getrevs(repo, name) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
123 |
repo._phasecache.loadphaserevs(repo) |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
124 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40999
diff
changeset
|
125 |
|
40999
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
126 |
# TODO: think about proper API of attaching preloaded attributes |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
127 |
def copycache(srcrepo, destrepo): |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
128 |
"""Copy cached attributes from srcrepo to destrepo""" |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
129 |
destfilecache = destrepo._filecache |
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
130 |
srcfilecache = srcrepo._filecache |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
131 |
if b'changelog' in srcfilecache: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
132 |
destfilecache[b'changelog'] = ce = srcfilecache[b'changelog'] |
40999
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
133 |
ce.obj.opener = ce.obj._realopener = destrepo.svfs |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
134 |
if b'obsstore' in srcfilecache: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
135 |
destfilecache[b'obsstore'] = ce = srcfilecache[b'obsstore'] |
40999
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
136 |
ce.obj.svfs = destrepo.svfs |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
137 |
if b'_phasecache' in srcfilecache: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
138 |
destfilecache[b'_phasecache'] = ce = srcfilecache[b'_phasecache'] |
40999
dcac24ec935b
commandserver: preload repository in master server and reuse its file cache
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
139 |
ce.obj.opener = destrepo.svfs |