[Updated] D9673: engine: prevent a function call for each store file
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Wed Jan 13 17:14:41 UTC 2021
Closed by commit rHG52abb1af2995: engine: prevent a function call for each store file (authored by pulkit).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9673?vs=24771&id=24788
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9673/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9673
AFFECTED FILES
mercurial/upgrade_utils/engine.py
CHANGE DETAILS
diff --git a/mercurial/upgrade_utils/engine.py b/mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py
+++ b/mercurial/upgrade_utils/engine.py
@@ -376,36 +376,25 @@
)
-def _filterstorefile(srcrepo, dstrepo, requirements, path, mode, st):
- """Determine whether to copy a store file during upgrade.
-
- This function is called when migrating store files from ``srcrepo`` to
- ``dstrepo`` as part of upgrading a repository.
-
- Args:
- srcrepo: repo we are copying from
- dstrepo: repo we are copying to
- requirements: set of requirements for ``dstrepo``
- path: store file being examined
- mode: the ``ST_MODE`` file type of ``path``
- st: ``stat`` data structure for ``path``
+def _files_to_copy_post_revlog_clone(srcrepo):
+ """yields files which should be copied to destination after revlogs
+ are cloned"""
+ for path, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
+ # don't copy revlogs as they are already cloned
+ if path.endswith((b'.i', b'.d', b'.n', b'.nd')):
+ continue
+ # Skip transaction related files.
+ if path.startswith(b'undo'):
+ continue
+ # Only copy regular files.
+ if kind != stat.S_IFREG:
+ continue
+ # Skip other skipped files.
+ if path in (b'lock', b'fncache'):
+ continue
+ # TODO: should we skip cache too?
- Function should return ``True`` if the file is to be copied.
- """
- # Skip revlogs.
- if path.endswith((b'.i', b'.d', b'.n', b'.nd')):
- return False
- # Skip transaction related files.
- if path.startswith(b'undo'):
- return False
- # Only copy regular files.
- if mode != stat.S_IFREG:
- return False
- # Skip other skipped files.
- if path in (b'lock', b'fncache'):
- return False
-
- return True
+ yield path
def _replacestores(currentrepo, upgradedrepo, backupvfs, upgrade_op):
@@ -465,13 +454,7 @@
)
# Now copy other files in the store directory.
- # The sorted() makes execution deterministic.
- for p, kind, st in sorted(srcrepo.store.vfs.readdir(b'', stat=True)):
- if not _filterstorefile(
- srcrepo, dstrepo, upgrade_op.new_requirements, p, kind, st
- ):
- continue
-
+ for p in _files_to_copy_post_revlog_clone(srcrepo):
srcrepo.ui.status(_(b'copying %s\n') % p)
src = srcrepo.store.rawvfs.join(p)
dst = dstrepo.store.rawvfs.join(p)
To: pulkit, #hg-reviewers, marmoute, mharbison72
Cc: mharbison72, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210113/dcf7ae1b/attachment-0002.html>
More information about the Mercurial-patches
mailing list