##// END OF EJS Templates
engine: prevent a function call for each store file...
Pulkit Goyal -
r46846:52abb1af default
parent child Browse files
Show More
@@ -376,36 +376,25 b' def _clonerevlogs('
376 )
376 )
377
377
378
378
379 def _filterstorefile(srcrepo, dstrepo, requirements, path, mode, st):
379 def _files_to_copy_post_revlog_clone(srcrepo):
380 """Determine whether to copy a store file during upgrade.
380 """yields files which should be copied to destination after revlogs
381
381 are cloned"""
382 This function is called when migrating store files from ``srcrepo`` to
382 for path, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
383 ``dstrepo`` as part of upgrading a repository.
383 # don't copy revlogs as they are already cloned
384
384 if path.endswith((b'.i', b'.d', b'.n', b'.nd')):
385 Args:
385 continue
386 srcrepo: repo we are copying from
386 # Skip transaction related files.
387 dstrepo: repo we are copying to
387 if path.startswith(b'undo'):
388 requirements: set of requirements for ``dstrepo``
388 continue
389 path: store file being examined
389 # Only copy regular files.
390 mode: the ``ST_MODE`` file type of ``path``
390 if kind != stat.S_IFREG:
391 st: ``stat`` data structure for ``path``
391 continue
392 # Skip other skipped files.
393 if path in (b'lock', b'fncache'):
394 continue
395 # TODO: should we skip cache too?
392
396
393 Function should return ``True`` if the file is to be copied.
397 yield path
394 """
395 # Skip revlogs.
396 if path.endswith((b'.i', b'.d', b'.n', b'.nd')):
397 return False
398 # Skip transaction related files.
399 if path.startswith(b'undo'):
400 return False
401 # Only copy regular files.
402 if mode != stat.S_IFREG:
403 return False
404 # Skip other skipped files.
405 if path in (b'lock', b'fncache'):
406 return False
407
408 return True
409
398
410
399
411 def _replacestores(currentrepo, upgradedrepo, backupvfs, upgrade_op):
400 def _replacestores(currentrepo, upgradedrepo, backupvfs, upgrade_op):
@@ -465,13 +454,7 b' def upgrade(ui, srcrepo, dstrepo, upgrad'
465 )
454 )
466
455
467 # Now copy other files in the store directory.
456 # Now copy other files in the store directory.
468 # The sorted() makes execution deterministic.
457 for p in _files_to_copy_post_revlog_clone(srcrepo):
469 for p, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
470 if not _filterstorefile(
471 srcrepo, dstrepo, upgrade_op.new_requirements, p, kind, st
472 ):
473 continue
474
475 srcrepo.ui.status(_(b'copying %s\n') % p)
458 srcrepo.ui.status(_(b'copying %s\n') % p)
476 src = srcrepo.store.rawvfs.join(p)
459 src = srcrepo.store.rawvfs.join(p)
477 dst = dstrepo.store.rawvfs.join(p)
460 dst = dstrepo.store.rawvfs.join(p)
General Comments 0
You need to be logged in to leave comments. Login now