comparison mercurial/scmutil.py @ 45072:a56ba57c837d

scmutil: allowing different files to be prefetched per revision The old API takes a list of revision separate from the file matcher, and thus provides no way to fetch different sets of files from each revision. In preparation for adding one such usage, I'm changing the API to take a list of (revision, file matcher) tuples instead. Differential Revision: https://phab.mercurial-scm.org/D8721
author Rodrigo Damazio Bovendorp <rdamazio@google.com>
date Thu, 09 Jul 2020 18:48:55 -0700
parents d044b66d8429
children a03c177a4679
comparison
equal deleted inserted replaced
45071:196ba4d4eb86 45072:a56ba57c837d
1878 b'pull', 1878 b'pull',
1879 b'unbundle', 1879 b'unbundle',
1880 ] 1880 ]
1881 1881
1882 1882
1883 def prefetchfiles(repo, revs, match): 1883 def prefetchfiles(repo, revmatches):
1884 """Invokes the registered file prefetch functions, allowing extensions to 1884 """Invokes the registered file prefetch functions, allowing extensions to
1885 ensure the corresponding files are available locally, before the command 1885 ensure the corresponding files are available locally, before the command
1886 uses them.""" 1886 uses them.
1887 if match: 1887
1888 # The command itself will complain about files that don't exist, so 1888 Args:
1889 # don't duplicate the message. 1889 revmatches: a list of (revision, match) tuples to indicate the files to
1890 match = matchmod.badmatch(match, lambda fn, msg: None) 1890 fetch at each revision. If any of the match elements is None, it matches
1891 else: 1891 all files.
1892 match = matchall(repo) 1892 """
1893 1893
1894 fileprefetchhooks(repo, revs, match) 1894 def _matcher(m):
1895 if m:
1896 assert isinstance(m, matchmod.basematcher)
1897 # The command itself will complain about files that don't exist, so
1898 # don't duplicate the message.
1899 return matchmod.badmatch(m, lambda fn, msg: None)
1900 else:
1901 return matchall(repo)
1902
1903 revbadmatches = [(rev, _matcher(match)) for (rev, match) in revmatches]
1904
1905 fileprefetchhooks(repo, revbadmatches)
1895 1906
1896 1907
1897 # a list of (repo, revs, match) prefetch functions 1908 # a list of (repo, revs, match) prefetch functions
1898 fileprefetchhooks = util.hooks() 1909 fileprefetchhooks = util.hooks()
1899 1910