2186 if not (os.path.isfile(filename) and os.access(filename, os.R_OK)): |
2186 if not (os.path.isfile(filename) and os.access(filename, os.R_OK)): |
2187 raise error.Abort("not a readable file: %s" % filename) |
2187 raise error.Abort("not a readable file: %s" % filename) |
2188 |
2188 |
2189 run_variables = [None, None] |
2189 run_variables = [None, None] |
2190 |
2190 |
|
2191 # we create the new repository next to the other one for two reasons: |
|
2192 # - this way we use the same file system, which are relevant for benchmark |
|
2193 # - if /tmp/ is small, the operation could overfills it. |
|
2194 source_repo_dir = os.path.dirname(repo.root) |
|
2195 |
2191 @contextlib.contextmanager |
2196 @contextlib.contextmanager |
2192 def context(): |
2197 def context(): |
2193 with open(filename, mode='rb') as bundle: |
2198 with open(filename, mode='rb') as bundle: |
2194 with tempfile.TemporaryDirectory() as tmp_dir: |
2199 with tempfile.TemporaryDirectory( |
|
2200 prefix=b'hg-perf-stream-consume-', |
|
2201 dir=source_repo_dir, |
|
2202 ) as tmp_dir: |
2195 tmp_dir = fsencode(tmp_dir) |
2203 tmp_dir = fsencode(tmp_dir) |
2196 run_variables[0] = bundle |
2204 run_variables[0] = bundle |
2197 run_variables[1] = tmp_dir |
2205 run_variables[1] = tmp_dir |
2198 yield |
2206 yield |
2199 run_variables[0] = None |
2207 run_variables[0] = None |