annotate hgext/remotefilelog/__init__.py @ 43077:687b865b95ad

formatting: byteify all mercurial/ and hgext/ string literals Done with python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py') black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**') # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6972
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:48:39 -0400
parents 2372284d9457
children eef9a2d67051
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1 # __init__.py - remotefilelog extension
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
2 #
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
3 # Copyright 2013 Facebook, Inc.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
4 #
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
6 # GNU General Public License version 2 or any later version.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
7 """remotefilelog causes Mercurial to lazilly fetch file contents (EXPERIMENTAL)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
8
40562
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
9 This extension is HIGHLY EXPERIMENTAL. There are NO BACKWARDS COMPATIBILITY
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
10 GUARANTEES. This means that repositories created with this extension may
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
11 only be usable with the exact version of this extension/Mercurial that was
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
12 used. The extension attempts to enforce this in order to prevent repository
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
13 corruption.
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
14
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
15 remotefilelog works by fetching file contents lazily and storing them
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
16 in a cache on the client rather than in revlogs. This allows enormous
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
17 histories to be transferred only partially, making them easier to
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
18 operate on.
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
19
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
20 Configs:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
21
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
22 ``packs.maxchainlen`` specifies the maximum delta chain length in pack files
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
23
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
24 ``packs.maxpacksize`` specifies the maximum pack file size
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
25
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
26 ``packs.maxpackfilecount`` specifies the maximum number of packs in the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
27 shared cache (trees only for now)
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
28
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
29 ``remotefilelog.backgroundprefetch`` runs prefetch in background when True
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
30
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
31 ``remotefilelog.bgprefetchrevs`` specifies revisions to fetch on commit and
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
32 update, and on other commands that use them. Different from pullprefetch.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
33
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
34 ``remotefilelog.gcrepack`` does garbage collection during repack when True
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
35
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
36 ``remotefilelog.nodettl`` specifies maximum TTL of a node in seconds before
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
37 it is garbage collected
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
38
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
39 ``remotefilelog.repackonhggc`` runs repack on hg gc when True
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
40
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
41 ``remotefilelog.prefetchdays`` specifies the maximum age of a commit in
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
42 days after which it is no longer prefetched.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
43
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
44 ``remotefilelog.prefetchdelay`` specifies delay between background
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
45 prefetches in seconds after operations that change the working copy parent
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
46
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
47 ``remotefilelog.data.gencountlimit`` constraints the minimum number of data
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
48 pack files required to be considered part of a generation. In particular,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
49 minimum number of packs files > gencountlimit.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
50
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
51 ``remotefilelog.data.generations`` list for specifying the lower bound of
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
52 each generation of the data pack files. For example, list ['100MB','1MB']
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
53 or ['1MB', '100MB'] will lead to three generations: [0, 1MB), [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
54 1MB, 100MB) and [100MB, infinity).
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
55
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
56 ``remotefilelog.data.maxrepackpacks`` the maximum number of pack files to
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
57 include in an incremental data repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
58
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
59 ``remotefilelog.data.repackmaxpacksize`` the maximum size of a pack file for
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
60 it to be considered for an incremental data repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
61
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
62 ``remotefilelog.data.repacksizelimit`` the maximum total size of pack files
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
63 to include in an incremental data repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
64
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
65 ``remotefilelog.history.gencountlimit`` constraints the minimum number of
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
66 history pack files required to be considered part of a generation. In
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
67 particular, minimum number of packs files > gencountlimit.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
68
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
69 ``remotefilelog.history.generations`` list for specifying the lower bound of
40771
32a23c3f56d4 remotefilelog: fix typo in docstring
Augie Fackler <augie@google.com>
parents: 40657
diff changeset
70 each generation of the history pack files. For example, list [
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
71 '100MB', '1MB'] or ['1MB', '100MB'] will lead to three generations: [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
72 0, 1MB), [1MB, 100MB) and [100MB, infinity).
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
73
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
74 ``remotefilelog.history.maxrepackpacks`` the maximum number of pack files to
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
75 include in an incremental history repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
76
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
77 ``remotefilelog.history.repackmaxpacksize`` the maximum size of a pack file
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
78 for it to be considered for an incremental history repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
79
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
80 ``remotefilelog.history.repacksizelimit`` the maximum total size of pack
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
81 files to include in an incremental history repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
82
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
83 ``remotefilelog.backgroundrepack`` automatically consolidate packs in the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
84 background
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
85
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
86 ``remotefilelog.cachepath`` path to cache
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
87
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
88 ``remotefilelog.cachegroup`` if set, make cache directory sgid to this
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
89 group
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
90
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
91 ``remotefilelog.cacheprocess`` binary to invoke for fetching file data
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
92
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
93 ``remotefilelog.debug`` turn on remotefilelog-specific debug output
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
94
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
95 ``remotefilelog.excludepattern`` pattern of files to exclude from pulls
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
96
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
97 ``remotefilelog.includepattern`` pattern of files to include in pulls
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
98
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
99 ``remotefilelog.fetchwarning``: message to print when too many
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
100 single-file fetches occur
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
101
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
102 ``remotefilelog.getfilesstep`` number of files to request in a single RPC
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
103
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
104 ``remotefilelog.getfilestype`` if set to 'threaded' use threads to fetch
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
105 files, otherwise use optimistic fetching
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
106
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
107 ``remotefilelog.pullprefetch`` revset for selecting files that should be
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
108 eagerly downloaded rather than lazily
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
109
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
110 ``remotefilelog.reponame`` name of the repo. If set, used to partition
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
111 data from other repos in a shared store.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
112
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
113 ``remotefilelog.server`` if true, enable server-side functionality
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
114
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
115 ``remotefilelog.servercachepath`` path for caching blobs on the server
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
116
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
117 ``remotefilelog.serverexpiration`` number of days to keep cached server
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
118 blobs
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
119
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
120 ``remotefilelog.validatecache`` if set, check cache entries for corruption
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
121 before returning blobs
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
122
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
123 ``remotefilelog.validatecachelog`` if set, check cache entries for
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
124 corruption before returning metadata
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
125
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
126 """
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
127 from __future__ import absolute_import
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
128
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
129 import os
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
130 import time
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
131 import traceback
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
132
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
133 from mercurial.node import hex
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
134 from mercurial.i18n import _
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
135 from mercurial import (
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
136 changegroup,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
137 changelog,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
138 cmdutil,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
139 commands,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
140 configitems,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
141 context,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
142 copies,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
143 debugcommands as hgdebugcommands,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
144 dispatch,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
145 error,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
146 exchange,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
147 extensions,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
148 hg,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
149 localrepo,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
150 match,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
151 merge,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
152 node as nodemod,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
153 patch,
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
154 pycompat,
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
155 registrar,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
156 repair,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
157 repoview,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
158 revset,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
159 scmutil,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
160 smartset,
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
161 streamclone,
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
162 util,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
163 )
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
164 from . import (
40558
354acd0dc637 remotefilelog: rename capability for legacy ssh file fetching method
Augie Fackler <augie@google.com>
parents: 40552
diff changeset
165 constants,
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
166 debugcommands,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
167 fileserverclient,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
168 remotefilectx,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
169 remotefilelog,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
170 remotefilelogserver,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
171 repack as repackmod,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
172 shallowbundle,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
173 shallowrepo,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
174 shallowstore,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
175 shallowutil,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
176 shallowverifier,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
177 )
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
178
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
179 # ensures debug commands are registered
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
180 hgdebugcommands.command
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
181
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
182 cmdtable = {}
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
183 command = registrar.command(cmdtable)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
184
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
185 configtable = {}
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
186 configitem = registrar.configitem(configtable)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
187
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
188 configitem(b'remotefilelog', b'debug', default=False)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
189
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
190 configitem(b'remotefilelog', b'reponame', default=b'')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
191 configitem(b'remotefilelog', b'cachepath', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
192 configitem(b'remotefilelog', b'cachegroup', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
193 configitem(b'remotefilelog', b'cacheprocess', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
194 configitem(b'remotefilelog', b'cacheprocess.includepath', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
195 configitem(b"remotefilelog", b"cachelimit", default=b"1000 GB")
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
196
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
197 configitem(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
198 b'remotefilelog',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
199 b'fallbackpath',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
200 default=configitems.dynamicdefault,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
201 alias=[(b'remotefilelog', b'fallbackrepo')],
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
202 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
203
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
204 configitem(b'remotefilelog', b'validatecachelog', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
205 configitem(b'remotefilelog', b'validatecache', default=b'on')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
206 configitem(b'remotefilelog', b'server', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
207 configitem(b'remotefilelog', b'servercachepath', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
208 configitem(b"remotefilelog", b"serverexpiration", default=30)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
209 configitem(b'remotefilelog', b'backgroundrepack', default=False)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
210 configitem(b'remotefilelog', b'bgprefetchrevs', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
211 configitem(b'remotefilelog', b'pullprefetch', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
212 configitem(b'remotefilelog', b'backgroundprefetch', default=False)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
213 configitem(b'remotefilelog', b'prefetchdelay', default=120)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
214 configitem(b'remotefilelog', b'prefetchdays', default=14)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
215
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
216 configitem(b'remotefilelog', b'getfilesstep', default=10000)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
217 configitem(b'remotefilelog', b'getfilestype', default=b'optimistic')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
218 configitem(b'remotefilelog', b'batchsize', configitems.dynamicdefault)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
219 configitem(b'remotefilelog', b'fetchwarning', default=b'')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
220
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
221 configitem(b'remotefilelog', b'includepattern', default=None)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
222 configitem(b'remotefilelog', b'excludepattern', default=None)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
223
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
224 configitem(b'remotefilelog', b'gcrepack', default=False)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
225 configitem(b'remotefilelog', b'repackonhggc', default=False)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
226 configitem(b'repack', b'chainorphansbysize', default=True, experimental=True)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
227
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
228 configitem(b'packs', b'maxpacksize', default=0)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
229 configitem(b'packs', b'maxchainlen', default=1000)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
230
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
231 configitem(b'devel', b'remotefilelog.ensurestart', default=False)
42852
2c74337e6483 remotefilelog: reduce probability of race-condition in remotefilelog tests
Boris Feld <boris.feld@octobus.net>
parents: 42776
diff changeset
232
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
233 # default TTL limit is 30 days
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
234 _defaultlimit = 60 * 60 * 24 * 30
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
235 configitem(b'remotefilelog', b'nodettl', default=_defaultlimit)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
236
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
237 configitem(b'remotefilelog', b'data.gencountlimit', default=2),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
238 configitem(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
239 b'remotefilelog', b'data.generations', default=[b'1GB', b'100MB', b'1MB']
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
240 )
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
241 configitem(b'remotefilelog', b'data.maxrepackpacks', default=50)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
242 configitem(b'remotefilelog', b'data.repackmaxpacksize', default=b'4GB')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
243 configitem(b'remotefilelog', b'data.repacksizelimit', default=b'100MB')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
244
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
245 configitem(b'remotefilelog', b'history.gencountlimit', default=2),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
246 configitem(b'remotefilelog', b'history.generations', default=[b'100MB'])
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
247 configitem(b'remotefilelog', b'history.maxrepackpacks', default=50)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
248 configitem(b'remotefilelog', b'history.repackmaxpacksize', default=b'400MB')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
249 configitem(b'remotefilelog', b'history.repacksizelimit', default=b'100MB')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
250
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
251 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
252 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
253 # be specifying the version(s) of Mercurial they are tested with, or
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
254 # leave the attribute unspecified.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
255 testedwith = b'ships-with-hg-core'
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
256
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
257 repoclass = localrepo.localrepository
40560
fc2766860796 remotefilelog: consolidate and rename on-disk store requirement
Augie Fackler <augie@google.com>
parents: 40559
diff changeset
258 repoclass._basesupported.add(constants.SHALLOWREPO_REQUIREMENT)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
259
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
260 isenabled = shallowutil.isenabled
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
261
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
262
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
263 def uisetup(ui):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
264 """Wraps user facing Mercurial commands to swap them out with shallow
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
265 versions.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
266 """
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
267 hg.wirepeersetupfuncs.append(fileserverclient.peersetup)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
268
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
269 entry = extensions.wrapcommand(commands.table, b'clone', cloneshallow)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
270 entry[1].append(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
271 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
272 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
273 b'shallow',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
274 None,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
275 _(b"create a shallow clone which uses remote file " b"history"),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
276 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
277 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
278
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
279 extensions.wrapcommand(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
280 commands.table, b'debugindex', debugcommands.debugindex
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
281 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
282 extensions.wrapcommand(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
283 commands.table, b'debugindexdot', debugcommands.debugindexdot
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
284 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
285 extensions.wrapcommand(commands.table, b'log', log)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
286 extensions.wrapcommand(commands.table, b'pull', pull)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
287
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
288 # Prevent 'hg manifest --all'
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
289 def _manifest(orig, ui, repo, *args, **opts):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
290 if isenabled(repo) and opts.get(r'all'):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
291 raise error.Abort(_(b"--all is not supported in a shallow repo"))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
292
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
293 return orig(ui, repo, *args, **opts)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
294
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
295 extensions.wrapcommand(commands.table, b"manifest", _manifest)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
296
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
297 # Wrap remotefilelog with lfs code
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
298 def _lfsloaded(loaded=False):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
299 lfsmod = None
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
300 try:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
301 lfsmod = extensions.find(b'lfs')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
302 except KeyError:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
303 pass
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
304 if lfsmod:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
305 lfsmod.wrapfilelog(remotefilelog.remotefilelog)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
306 fileserverclient._lfsmod = lfsmod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
307
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
308 extensions.afterloaded(b'lfs', _lfsloaded)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
309
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
310 # debugdata needs remotefilelog.len to work
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
311 extensions.wrapcommand(commands.table, b'debugdata', debugdatashallow)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
312
42301
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
313 changegroup.cgpacker = shallowbundle.shallowcg1packer
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
314
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
315 extensions.wrapfunction(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
316 changegroup, b'_addchangegroupfiles', shallowbundle.addchangegroupfiles
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
317 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
318 extensions.wrapfunction(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
319 changegroup, b'makechangegroup', shallowbundle.makechangegroup
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
320 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
321 extensions.wrapfunction(localrepo, b'makestore', storewrapper)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
322 extensions.wrapfunction(exchange, b'pull', exchangepull)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
323 extensions.wrapfunction(merge, b'applyupdates', applyupdates)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
324 extensions.wrapfunction(merge, b'_checkunknownfiles', checkunknownfiles)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
325 extensions.wrapfunction(context.workingctx, b'_checklookup', checklookup)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
326 extensions.wrapfunction(scmutil, b'_findrenames', findrenames)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
327 extensions.wrapfunction(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
328 copies, b'_computeforwardmissing', computeforwardmissing
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
329 )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
330 extensions.wrapfunction(dispatch, b'runcommand', runcommand)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
331 extensions.wrapfunction(repair, b'_collectbrokencsets', _collectbrokencsets)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
332 extensions.wrapfunction(context.changectx, b'filectx', filectx)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
333 extensions.wrapfunction(context.workingctx, b'filectx', workingfilectx)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
334 extensions.wrapfunction(patch, b'trydiff', trydiff)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
335 extensions.wrapfunction(hg, b'verify', _verify)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
336 scmutil.fileprefetchhooks.add(b'remotefilelog', _fileprefetchhook)
42301
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
337
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
338 # disappointing hacks below
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
339 extensions.wrapfunction(scmutil, b'getrenamedfn', getrenamedfn)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
340 extensions.wrapfunction(revset, b'filelog', filelogrevset)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
341 revset.symbols[b'filelog'] = revset.filelog
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
342 extensions.wrapfunction(cmdutil, b'walkfilerevs', walkfilerevs)
42301
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
343
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
344
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
345 def cloneshallow(orig, ui, repo, *args, **opts):
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
346 if opts.get(r'shallow'):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
347 repos = []
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
348
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
349 def pull_shallow(orig, self, *args, **kwargs):
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
350 if not isenabled(self):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
351 repos.append(self.unfiltered())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
352 # set up the client hooks so the post-clone update works
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
353 setupclient(self.ui, self.unfiltered())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
354
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
355 # setupclient fixed the class on the repo itself
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
356 # but we also need to fix it on the repoview
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
357 if isinstance(self, repoview.repoview):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
358 self.__class__.__bases__ = (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
359 self.__class__.__bases__[0],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
360 self.unfiltered().__class__,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
361 )
40560
fc2766860796 remotefilelog: consolidate and rename on-disk store requirement
Augie Fackler <augie@google.com>
parents: 40559
diff changeset
362 self.requirements.add(constants.SHALLOWREPO_REQUIREMENT)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
363 self._writerequirements()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
364
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
365 # Since setupclient hadn't been called, exchange.pull was not
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
366 # wrapped. So we need to manually invoke our version of it.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
367 return exchangepull(orig, self, *args, **kwargs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
368 else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
369 return orig(self, *args, **kwargs)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
370
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
371 extensions.wrapfunction(exchange, b'pull', pull_shallow)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
372
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
373 # Wrap the stream logic to add requirements and to pass include/exclude
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
374 # patterns around.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
375 def setup_streamout(repo, remote):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
376 # Replace remote.stream_out with a version that sends file
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
377 # patterns.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
378 def stream_out_shallow(orig):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
379 caps = remote.capabilities()
40558
354acd0dc637 remotefilelog: rename capability for legacy ssh file fetching method
Augie Fackler <augie@google.com>
parents: 40552
diff changeset
380 if constants.NETWORK_CAP_LEGACY_SSH_GETFILES in caps:
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
381 opts = {}
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
382 if repo.includepattern:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
383 opts[r'includepattern'] = b'\0'.join(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
384 repo.includepattern
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
385 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
386 if repo.excludepattern:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
387 opts[r'excludepattern'] = b'\0'.join(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
388 repo.excludepattern
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
389 )
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
390 return remote._callstream(b'stream_out_shallow', **opts)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
391 else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
392 return orig()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
393
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
394 extensions.wrapfunction(remote, b'stream_out', stream_out_shallow)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
395
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
396 def stream_wrap(orig, op):
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
397 setup_streamout(op.repo, op.remote)
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
398 return orig(op)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
399
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
400 extensions.wrapfunction(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
401 streamclone, b'maybeperformlegacystreamclone', stream_wrap
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
402 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
403
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
404 def canperformstreamclone(orig, pullop, bundle2=False):
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
405 # remotefilelog is currently incompatible with the
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
406 # bundle2 flavor of streamclones, so force us to use
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
407 # v1 instead.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
408 if b'v2' in pullop.remotebundle2caps.get(b'stream', []):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
409 pullop.remotebundle2caps[b'stream'] = [
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
410 c for c in pullop.remotebundle2caps[b'stream'] if c != b'v2'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
411 ]
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
412 if bundle2:
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
413 return False, None
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
414 supported, requirements = orig(pullop, bundle2=bundle2)
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
415 if requirements is not None:
40560
fc2766860796 remotefilelog: consolidate and rename on-disk store requirement
Augie Fackler <augie@google.com>
parents: 40559
diff changeset
416 requirements.add(constants.SHALLOWREPO_REQUIREMENT)
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
417 return supported, requirements
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
418
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
419 extensions.wrapfunction(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
420 streamclone, b'canperformstreamclone', canperformstreamclone
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
421 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
422
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
423 try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
424 orig(ui, repo, *args, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
425 finally:
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
426 if opts.get(r'shallow'):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
427 for r in repos:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
428 if util.safehasattr(r, b'fileservice'):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
429 r.fileservice.close()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
430
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
431
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
432 def debugdatashallow(orig, *args, **kwds):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
433 oldlen = remotefilelog.remotefilelog.__len__
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
434 try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
435 remotefilelog.remotefilelog.__len__ = lambda x: 1
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
436 return orig(*args, **kwds)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
437 finally:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
438 remotefilelog.remotefilelog.__len__ = oldlen
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
439
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
440
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
441 def reposetup(ui, repo):
41061
c61b8dfb07c8 remotefilelog: use repo.local() instead of isinstance()
Matt Harbison <matt_harbison@yahoo.com>
parents: 40858
diff changeset
442 if not repo.local():
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
443 return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
444
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
445 # put here intentionally bc doesnt work in uisetup
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
446 ui.setconfig(b'hooks', b'update.prefetch', wcpprefetch)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
447 ui.setconfig(b'hooks', b'commit.prefetch', wcpprefetch)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
448
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
449 isserverenabled = ui.configbool(b'remotefilelog', b'server')
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
450 isshallowclient = isenabled(repo)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
451
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
452 if isserverenabled and isshallowclient:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
453 raise RuntimeError(b"Cannot be both a server and shallow client.")
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
454
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
455 if isshallowclient:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
456 setupclient(ui, repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
457
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
458 if isserverenabled:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
459 remotefilelogserver.setupserver(ui, repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
460
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
461
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
462 def setupclient(ui, repo):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
463 if not isinstance(repo, localrepo.localrepository):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
464 return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
465
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
466 # Even clients get the server setup since they need to have the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
467 # wireprotocol endpoints registered.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
468 remotefilelogserver.onetimesetup(ui)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
469 onetimeclientsetup(ui)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
470
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
471 shallowrepo.wraprepo(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
472 repo.store = shallowstore.wrapstore(repo.store)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
473
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
474
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
475 def storewrapper(orig, requirements, path, vfstype):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
476 s = orig(requirements, path, vfstype)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
477 if constants.SHALLOWREPO_REQUIREMENT in requirements:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
478 s = shallowstore.wrapstore(s)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
479
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
480 return s
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
481
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
482
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
483 # prefetch files before update
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
484 def applyupdates(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
485 orig, repo, actions, wctx, mctx, overwrite, wantfiledata, labels=None
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
486 ):
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
487 if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
488 manifest = mctx.manifest()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
489 files = []
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
490 for f, args, msg in actions[b'g']:
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
491 files.append((f, hex(manifest[f])))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
492 # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
493 repo.fileservice.prefetch(files)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
494 return orig(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
495 repo, actions, wctx, mctx, overwrite, wantfiledata, labels=labels
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
496 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
497
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
498
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
499 # Prefetch merge checkunknownfiles
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
500 def checkunknownfiles(orig, repo, wctx, mctx, force, actions, *args, **kwargs):
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
501 if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
502 files = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
503 sparsematch = repo.maybesparsematch(mctx.rev())
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
504 for f, (m, actionargs, msg) in actions.iteritems():
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
505 if sparsematch and not sparsematch(f):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
506 continue
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
507 if m in (b'c', b'dc', b'cm'):
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
508 files.append((f, hex(mctx.filenode(f))))
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
509 elif m == b'dg':
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
510 f2 = actionargs[0]
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
511 files.append((f2, hex(mctx.filenode(f2))))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
512 # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
513 repo.fileservice.prefetch(files)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
514 return orig(repo, wctx, mctx, force, actions, *args, **kwargs)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
515
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
516
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
517 # Prefetch files before status attempts to look at their size and contents
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
518 def checklookup(orig, self, files):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
519 repo = self._repo
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
520 if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
521 prefetchfiles = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
522 for parent in self._parents:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
523 for f in files:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
524 if f in parent:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
525 prefetchfiles.append((f, hex(parent.filenode(f))))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
526 # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
527 repo.fileservice.prefetch(prefetchfiles)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
528 return orig(self, files)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
529
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
530
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
531 # Prefetch the logic that compares added and removed files for renames
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
532 def findrenames(orig, repo, matcher, added, removed, *args, **kwargs):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
533 if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
534 files = []
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
535 pmf = repo[b'.'].manifest()
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
536 for f in removed:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
537 if f in pmf:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
538 files.append((f, hex(pmf[f])))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
539 # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
540 repo.fileservice.prefetch(files)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
541 return orig(repo, matcher, added, removed, *args, **kwargs)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
542
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
543
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
544 # prefetch files before pathcopies check
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
545 def computeforwardmissing(orig, a, b, match=None):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
546 missing = orig(a, b, match=match)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
547 repo = a._repo
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
548 if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
549 mb = b.manifest()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
550
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
551 files = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
552 sparsematch = repo.maybesparsematch(b.rev())
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
553 if sparsematch:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
554 sparsemissing = set()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
555 for f in missing:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
556 if sparsematch(f):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
557 files.append((f, hex(mb[f])))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
558 sparsemissing.add(f)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
559 missing = sparsemissing
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
560
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
561 # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
562 repo.fileservice.prefetch(files)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
563 return missing
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
564
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
565
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
566 # close cache miss server connection after the command has finished
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
567 def runcommand(orig, lui, repo, *args, **kwargs):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
568 fileservice = None
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
569 # repo can be None when running in chg:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
570 # - at startup, reposetup was called because serve is not norepo
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
571 # - a norepo command like "help" is called
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
572 if repo and isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
573 fileservice = repo.fileservice
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
574 try:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
575 return orig(lui, repo, *args, **kwargs)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
576 finally:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
577 if fileservice:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
578 fileservice.close()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
579
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
580
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
581 # prevent strip from stripping remotefilelogs
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
582 def _collectbrokencsets(orig, repo, files, striprev):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
583 if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
584 files = list([f for f in files if not repo.shallowmatch(f)])
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
585 return orig(repo, files, striprev)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
586
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
587
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
588 # changectx wrappers
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
589 def filectx(orig, self, path, fileid=None, filelog=None):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
590 if fileid is None:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
591 fileid = self.filenode(path)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
592 if isenabled(self._repo) and self._repo.shallowmatch(path):
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
593 return remotefilectx.remotefilectx(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
594 self._repo, path, fileid=fileid, changectx=self, filelog=filelog
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
595 )
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
596 return orig(self, path, fileid=fileid, filelog=filelog)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
597
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
598
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
599 def workingfilectx(orig, self, path, filelog=None):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
600 if isenabled(self._repo) and self._repo.shallowmatch(path):
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
601 return remotefilectx.remoteworkingfilectx(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
602 self._repo, path, workingctx=self, filelog=filelog
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
603 )
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
604 return orig(self, path, filelog=filelog)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
605
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
606
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
607 # prefetch required revisions before a diff
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
608 def trydiff(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
609 orig,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
610 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
611 revs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
612 ctx1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
613 ctx2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
614 modified,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
615 added,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
616 removed,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
617 copy,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
618 getfilectx,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
619 *args,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
620 **kwargs
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
621 ):
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
622 if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
623 prefetch = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
624 mf1 = ctx1.manifest()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
625 for fname in modified + added + removed:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
626 if fname in mf1:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
627 fnode = getfilectx(fname, ctx1).filenode()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
628 # fnode can be None if it's a edited working ctx file
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
629 if fnode:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
630 prefetch.append((fname, hex(fnode)))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
631 if fname not in removed:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
632 fnode = getfilectx(fname, ctx2).filenode()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
633 if fnode:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
634 prefetch.append((fname, hex(fnode)))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
635
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
636 repo.fileservice.prefetch(prefetch)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
637
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
638 return orig(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
639 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
640 revs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
641 ctx1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
642 ctx2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
643 modified,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
644 added,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
645 removed,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
646 copy,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
647 getfilectx,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
648 *args,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
649 **kwargs
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
650 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
651
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
652
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
653 # Prevent verify from processing files
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
654 # a stub for mercurial.hg.verify()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
655 def _verify(orig, repo, level=None):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
656 lock = repo.lock()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
657 try:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
658 return shallowverifier.shallowverifier(repo).verify()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
659 finally:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
660 lock.release()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
661
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
662
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
663 clientonetime = False
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
664
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
665
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
666 def onetimeclientsetup(ui):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
667 global clientonetime
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
668 if clientonetime:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
669 return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
670 clientonetime = True
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
671
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
672 # Don't commit filelogs until we know the commit hash, since the hash
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
673 # is present in the filelog blob.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
674 # This violates Mercurial's filelog->manifest->changelog write order,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
675 # but is generally fine for client repos.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
676 pendingfilecommits = []
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
677
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
678 def addrawrevision(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
679 orig,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
680 self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
681 rawtext,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
682 transaction,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
683 link,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
684 p1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
685 p2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
686 node,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
687 flags,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
688 cachedelta=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
689 _metatuple=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
690 ):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
691 if isinstance(link, int):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
692 pendingfilecommits.append(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
693 (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
694 self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
695 rawtext,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
696 transaction,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
697 link,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
698 p1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
699 p2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
700 node,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
701 flags,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
702 cachedelta,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
703 _metatuple,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
704 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
705 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
706 return node
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
707 else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
708 return orig(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
709 self,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
710 rawtext,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
711 transaction,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
712 link,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
713 p1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
714 p2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
715 node,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
716 flags,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
717 cachedelta,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
718 _metatuple=_metatuple,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
719 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
720
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
721 extensions.wrapfunction(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
722 remotefilelog.remotefilelog, b'addrawrevision', addrawrevision
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
723 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
724
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
725 def changelogadd(orig, self, *args):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
726 oldlen = len(self)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
727 node = orig(self, *args)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
728 newlen = len(self)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
729 if oldlen != newlen:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
730 for oldargs in pendingfilecommits:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
731 log, rt, tr, link, p1, p2, n, fl, c, m = oldargs
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
732 linknode = self.node(link)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
733 if linknode == node:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
734 log.addrawrevision(rt, tr, linknode, p1, p2, n, fl, c, m)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
735 else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
736 raise error.ProgrammingError(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
737 b'pending multiple integer revisions are not supported'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
738 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
739 else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
740 # "link" is actually wrong here (it is set to len(changelog))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
741 # if changelog remains unchanged, skip writing file revisions
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
742 # but still do a sanity check about pending multiple revisions
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
743 if len(set(x[3] for x in pendingfilecommits)) > 1:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
744 raise error.ProgrammingError(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
745 b'pending multiple integer revisions are not supported'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
746 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
747 del pendingfilecommits[:]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
748 return node
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
749
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
750 extensions.wrapfunction(changelog.changelog, b'add', changelogadd)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
751
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
752
42514
f93762f251d2 remotefilelog: check if RFL is enabled in getrenamedfn() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 42488
diff changeset
753 def getrenamedfn(orig, repo, endrev=None):
42515
e387cb22f6c0 remotefilelog: handle copies in changesets in getrenamedfn() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 42514
diff changeset
754 if not isenabled(repo) or copies.usechangesetcentricalgo(repo):
42514
f93762f251d2 remotefilelog: check if RFL is enabled in getrenamedfn() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 42488
diff changeset
755 return orig(repo, endrev)
f93762f251d2 remotefilelog: check if RFL is enabled in getrenamedfn() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 42488
diff changeset
756
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
757 rcache = {}
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
758
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
759 def getrenamed(fn, rev):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
760 '''looks up all renames for a file (up to endrev) the first
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
761 time the file is given. It indexes on the changerev and only
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
762 parses the manifest if linkrev != changerev.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
763 Returns rename info for fn at changerev rev.'''
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
764 if rev in rcache.setdefault(fn, {}):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
765 return rcache[fn][rev]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
766
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
767 try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
768 fctx = repo[rev].filectx(fn)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
769 for ancestor in fctx.ancestors():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
770 if ancestor.path() == fn:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
771 renamed = ancestor.renamed()
41192
2338eab5f8b7 remotefilelog: fix {file_copies} template keyword
Martin von Zweigbergk <martinvonz@google.com>
parents: 41061
diff changeset
772 rcache[fn][ancestor.rev()] = renamed and renamed[0]
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
773
41192
2338eab5f8b7 remotefilelog: fix {file_copies} template keyword
Martin von Zweigbergk <martinvonz@google.com>
parents: 41061
diff changeset
774 renamed = fctx.renamed()
2338eab5f8b7 remotefilelog: fix {file_copies} template keyword
Martin von Zweigbergk <martinvonz@google.com>
parents: 41061
diff changeset
775 return renamed and renamed[0]
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
776 except error.LookupError:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
777 return None
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
778
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
779 return getrenamed
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
780
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
781
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
782 def walkfilerevs(orig, repo, match, follow, revs, fncache):
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
783 if not isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
784 return orig(repo, match, follow, revs, fncache)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
785
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
786 # remotefilelog's can't be walked in rev order, so throw.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
787 # The caller will see the exception and walk the commit tree instead.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
788 if not follow:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
789 raise cmdutil.FileWalkError(b"Cannot walk via filelog")
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
790
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
791 wanted = set()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
792 minrev, maxrev = min(revs), max(revs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
793
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
794 pctx = repo[b'.']
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
795 for filename in match.files():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
796 if filename not in pctx:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
797 raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
798 _(b'cannot follow file not in parent ' b'revision: "%s"')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
799 % filename
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
800 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
801 fctx = pctx[filename]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
802
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
803 linkrev = fctx.linkrev()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
804 if linkrev >= minrev and linkrev <= maxrev:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
805 fncache.setdefault(linkrev, []).append(filename)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
806 wanted.add(linkrev)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
807
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
808 for ancestor in fctx.ancestors():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
809 linkrev = ancestor.linkrev()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
810 if linkrev >= minrev and linkrev <= maxrev:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
811 fncache.setdefault(linkrev, []).append(ancestor.path())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
812 wanted.add(linkrev)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
813
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
814 return wanted
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
815
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
816
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
817 def filelogrevset(orig, repo, subset, x):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
818 """``filelog(pattern)``
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
819 Changesets connected to the specified filelog.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
820
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
821 For performance reasons, ``filelog()`` does not show every changeset
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
822 that affects the requested file(s). See :hg:`help log` for details. For
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
823 a slower, more accurate result, use ``file()``.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
824 """
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
825
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
826 if not isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
827 return orig(repo, subset, x)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
828
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
829 # i18n: "filelog" is a keyword
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
830 pat = revset.getstring(x, _(b"filelog requires a pattern"))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
831 m = match.match(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
832 repo.root, repo.getcwd(), [pat], default=b'relpath', ctx=repo[None]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
833 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
834 s = set()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
835
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
836 if not match.patkind(pat):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
837 # slow
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
838 for r in subset:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
839 ctx = repo[r]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
840 cfiles = ctx.files()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
841 for f in m.files():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
842 if f in cfiles:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
843 s.add(ctx.rev())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
844 break
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
845 else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
846 # partial
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
847 files = (f for f in repo[None] if m(f))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
848 for f in files:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
849 fctx = repo[None].filectx(f)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
850 s.add(fctx.linkrev())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
851 for actx in fctx.ancestors():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
852 s.add(actx.linkrev())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
853
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
854 return smartset.baseset([r for r in subset if r in s])
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
855
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
856
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
857 @command(b'gc', [], _(b'hg gc [REPO...]'), norepo=True)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
858 def gc(ui, *args, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
859 '''garbage collect the client and server filelog caches
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
860 '''
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
861 cachepaths = set()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
862
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
863 # get the system client cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
864 systemcache = shallowutil.getcachepath(ui, allowempty=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
865 if systemcache:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
866 cachepaths.add(systemcache)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
867
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
868 # get repo client and server cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
869 repopaths = []
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
870 pwd = ui.environ.get(b'PWD')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
871 if pwd:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
872 repopaths.append(pwd)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
873
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
874 repopaths.extend(args)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
875 repos = []
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
876 for repopath in repopaths:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
877 try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
878 repo = hg.peer(ui, {}, repopath)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
879 repos.append(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
880
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
881 repocache = shallowutil.getcachepath(repo.ui, allowempty=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
882 if repocache:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
883 cachepaths.add(repocache)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
884 except error.RepoError:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
885 pass
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
886
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
887 # gc client cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
888 for cachepath in cachepaths:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
889 gcclient(ui, cachepath)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
890
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
891 # gc server cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
892 for repo in repos:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
893 remotefilelogserver.gcserver(ui, repo._repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
894
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
895
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
896 def gcclient(ui, cachepath):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
897 # get list of repos that use this cache
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
898 repospath = os.path.join(cachepath, b'repos')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
899 if not os.path.exists(repospath):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
900 ui.warn(_(b"no known cache at %s\n") % cachepath)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
901 return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
902
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
903 reposfile = open(repospath, b'rb')
42057
566daffc607d cleanup: use set literals where possible
Martin von Zweigbergk <martinvonz@google.com>
parents: 41790
diff changeset
904 repos = {r[:-1] for r in reposfile.readlines()}
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
905 reposfile.close()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
906
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
907 # build list of useful files
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
908 validrepos = []
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
909 keepkeys = set()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
910
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
911 sharedcache = None
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
912 filesrepacked = False
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
913
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
914 count = 0
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
915 progress = ui.makeprogress(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
916 _(b"analyzing repositories"), unit=b"repos", total=len(repos)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
917 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
918 for path in repos:
40858
05afb32e9380 remotefilelog: use progress helper when analyzing repos
Martin von Zweigbergk <martinvonz@google.com>
parents: 40771
diff changeset
919 progress.update(count)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
920 count += 1
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
921 try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
922 path = ui.expandpath(os.path.normpath(path))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
923 except TypeError as e:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
924 ui.warn(_(b"warning: malformed path: %r:%s\n") % (path, e))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
925 traceback.print_exc()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
926 continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
927 try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
928 peer = hg.peer(ui, {}, path)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
929 repo = peer._repo
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
930 except error.RepoError:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
931 continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
932
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
933 validrepos.append(path)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
934
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
935 # Protect against any repo or config changes that have happened since
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
936 # this repo was added to the repos file. We'd rather this loop succeed
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
937 # and too much be deleted, than the loop fail and nothing gets deleted.
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
938 if not isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
939 continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
940
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
941 if not util.safehasattr(repo, b'name'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
942 ui.warn(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
943 _(b"repo %s is a misconfigured remotefilelog repo\n") % path
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
944 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
945 continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
946
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
947 # If garbage collection on repack and repack on hg gc are enabled
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
948 # then loose files are repacked and garbage collected.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
949 # Otherwise regular garbage collection is performed.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
950 repackonhggc = repo.ui.configbool(b'remotefilelog', b'repackonhggc')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
951 gcrepack = repo.ui.configbool(b'remotefilelog', b'gcrepack')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
952 if repackonhggc and gcrepack:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
953 try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
954 repackmod.incrementalrepack(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
955 filesrepacked = True
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
956 continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
957 except (IOError, repackmod.RepackAlreadyRunning):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
958 # If repack cannot be performed due to not enough disk space
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
959 # continue doing garbage collection of loose files w/o repack
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
960 pass
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
961
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
962 reponame = repo.name
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
963 if not sharedcache:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
964 sharedcache = repo.sharedstore
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
965
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
966 # Compute a keepset which is not garbage collected
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
967 def keyfn(fname, fnode):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
968 return fileserverclient.getcachekey(reponame, fname, hex(fnode))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
969
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
970 keepkeys = repackmod.keepset(repo, keyfn=keyfn, lastkeepkeys=keepkeys)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
971
40858
05afb32e9380 remotefilelog: use progress helper when analyzing repos
Martin von Zweigbergk <martinvonz@google.com>
parents: 40771
diff changeset
972 progress.complete()
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
973
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
974 # write list of valid repos back
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
975 oldumask = os.umask(0o002)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
976 try:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
977 reposfile = open(repospath, b'wb')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
978 reposfile.writelines([(b"%s\n" % r) for r in validrepos])
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
979 reposfile.close()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
980 finally:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
981 os.umask(oldumask)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
982
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
983 # prune cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
984 if sharedcache is not None:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
985 sharedcache.gc(keepkeys)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
986 elif not filesrepacked:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
987 ui.warn(_(b"warning: no valid repos in repofile\n"))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
988
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
989
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
990 def log(orig, ui, repo, *pats, **opts):
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
991 if not isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
992 return orig(ui, repo, *pats, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
993
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
994 follow = opts.get(r'follow')
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
995 revs = opts.get(r'rev')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
996 if pats:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
997 # Force slowpath for non-follow patterns and follows that start from
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
998 # non-working-copy-parent revs.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
999 if not follow or revs:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1000 # This forces the slowpath
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
1001 opts[r'removed'] = True
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1002
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1003 # If this is a non-follow log without any revs specified, recommend that
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1004 # the user add -f to speed it up.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1005 if not follow and not revs:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1006 match = scmutil.match(repo[b'.'], pats, pycompat.byteskwargs(opts))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1007 isfile = not match.anypats()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1008 if isfile:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1009 for file in match.files():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1010 if not os.path.isfile(repo.wjoin(file)):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1011 isfile = False
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1012 break
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1013
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1014 if isfile:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1015 ui.warn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1016 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1017 b"warning: file log can be slow on large repos - "
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1018 + b"use -f to speed it up\n"
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1019 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1020 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1021
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1022 return orig(ui, repo, *pats, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1023
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1024
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1025 def revdatelimit(ui, revset):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1026 """Update revset so that only changesets no older than 'prefetchdays' days
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1027 are included. The default value is set to 14 days. If 'prefetchdays' is set
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1028 to zero or negative value then date restriction is not applied.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1029 """
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1030 days = ui.configint(b'remotefilelog', b'prefetchdays')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1031 if days > 0:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1032 revset = b'(%s) & date(-%s)' % (revset, days)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1033 return revset
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1034
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1035
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1036 def readytofetch(repo):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1037 """Check that enough time has passed since the last background prefetch.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1038 This only relates to prefetches after operations that change the working
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1039 copy parent. Default delay between background prefetches is 2 minutes.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1040 """
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1041 timeout = repo.ui.configint(b'remotefilelog', b'prefetchdelay')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1042 fname = repo.vfs.join(b'lastprefetch')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1043
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1044 ready = False
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1045 with open(fname, b'a'):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1046 # the with construct above is used to avoid race conditions
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1047 modtime = os.path.getmtime(fname)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1048 if (time.time() - modtime) > timeout:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1049 os.utime(fname, None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1050 ready = True
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1051
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1052 return ready
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1053
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1054
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1055 def wcpprefetch(ui, repo, **kwargs):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1056 """Prefetches in background revisions specified by bgprefetchrevs revset.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1057 Does background repack if backgroundrepack flag is set in config.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1058 """
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
1059 shallow = isenabled(repo)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1060 bgprefetchrevs = ui.config(b'remotefilelog', b'bgprefetchrevs')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1061 isready = readytofetch(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1062
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1063 if not (shallow and bgprefetchrevs and isready):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1064 return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1065
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1066 bgrepack = repo.ui.configbool(b'remotefilelog', b'backgroundrepack')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1067 # update a revset with a date limit
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1068 bgprefetchrevs = revdatelimit(ui, bgprefetchrevs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1069
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1070 def anon():
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1071 if util.safehasattr(repo, b'ranprefetch') and repo.ranprefetch:
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1072 return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1073 repo.ranprefetch = True
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1074 repo.backgroundprefetch(bgprefetchrevs, repack=bgrepack)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1075
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1076 repo._afterlock(anon)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1077
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1078
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1079 def pull(orig, ui, repo, *pats, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1080 result = orig(ui, repo, *pats, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1081
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
1082 if isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1083 # prefetch if it's configured
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1084 prefetchrevset = ui.config(b'remotefilelog', b'pullprefetch')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1085 bgrepack = repo.ui.configbool(b'remotefilelog', b'backgroundrepack')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1086 bgprefetch = repo.ui.configbool(b'remotefilelog', b'backgroundprefetch')
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1087 ensurestart = repo.ui.configbool(b'devel', b'remotefilelog.ensurestart')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1088
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1089 if prefetchrevset:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1090 ui.status(_(b"prefetching file contents\n"))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1091 revs = scmutil.revrange(repo, [prefetchrevset])
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1092 base = repo[b'.'].rev()
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1093 if bgprefetch:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1094 repo.backgroundprefetch(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1095 prefetchrevset, repack=bgrepack, ensurestart=ensurestart
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1096 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1097 else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1098 repo.prefetch(revs, base=base)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1099 if bgrepack:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1100 repackmod.backgroundrepack(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1101 repo, incremental=True, ensurestart=ensurestart
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1102 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1103 elif bgrepack:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1104 repackmod.backgroundrepack(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1105 repo, incremental=True, ensurestart=ensurestart
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1106 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1107
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1108 return result
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1109
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1110
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1111 def exchangepull(orig, repo, remote, *args, **kwargs):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1112 # Hook into the callstream/getbundle to insert bundle capabilities
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1113 # during a pull.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1114 def localgetbundle(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1115 orig, source, heads=None, common=None, bundlecaps=None, **kwargs
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1116 ):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1117 if not bundlecaps:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1118 bundlecaps = set()
40559
ed19958dbf5d remotefilelog: consolidate and rename bundle2 capability
Augie Fackler <augie@google.com>
parents: 40558
diff changeset
1119 bundlecaps.add(constants.BUNDLE2_CAPABLITY)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1120 return orig(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1121 source, heads=heads, common=common, bundlecaps=bundlecaps, **kwargs
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1122 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1123
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1124 if util.safehasattr(remote, b'_callstream'):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1125 remote._localrepo = repo
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1126 elif util.safehasattr(remote, b'getbundle'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1127 extensions.wrapfunction(remote, b'getbundle', localgetbundle)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1128
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1129 return orig(repo, remote, *args, **kwargs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1130
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1131
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1132 def _fileprefetchhook(repo, revs, match):
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
1133 if isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1134 allfiles = []
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1135 for rev in revs:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1136 if rev == nodemod.wdirrev or rev is None:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1137 continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1138 ctx = repo[rev]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1139 mf = ctx.manifest()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1140 sparsematch = repo.maybesparsematch(ctx.rev())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1141 for path in ctx.walk(match):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1142 if (not sparsematch or sparsematch(path)) and path in mf:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1143 allfiles.append((path, hex(mf[path])))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1144 repo.fileservice.prefetch(allfiles)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1145
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1146
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1147 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1148 b'debugremotefilelog',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1149 [(b'd', b'decompress', None, _(b'decompress the filelog first')),],
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1150 _(b'hg debugremotefilelog <path>'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1151 norepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1152 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1153 def debugremotefilelog(ui, path, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1154 return debugcommands.debugremotefilelog(ui, path, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1155
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1156
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1157 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1158 b'verifyremotefilelog',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1159 [(b'd', b'decompress', None, _(b'decompress the filelogs first')),],
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1160 _(b'hg verifyremotefilelogs <directory>'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1161 norepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1162 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1163 def verifyremotefilelog(ui, path, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1164 return debugcommands.verifyremotefilelog(ui, path, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1165
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1166
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1167 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1168 b'debugdatapack',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1169 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1170 (b'', b'long', None, _(b'print the long hashes')),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1171 (b'', b'node', b'', _(b'dump the contents of node'), b'NODE'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1172 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1173 _(b'hg debugdatapack <paths>'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1174 norepo=True,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1175 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1176 def debugdatapack(ui, *paths, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1177 return debugcommands.debugdatapack(ui, *paths, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1178
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1179
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1180 @command(b'debughistorypack', [], _(b'hg debughistorypack <path>'), norepo=True)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1181 def debughistorypack(ui, path, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1182 return debugcommands.debughistorypack(ui, path)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1183
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1184
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1185 @command(b'debugkeepset', [], _(b'hg debugkeepset'))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1186 def debugkeepset(ui, repo, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1187 # The command is used to measure keepset computation time
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1188 def keyfn(fname, fnode):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1189 return fileserverclient.getcachekey(repo.name, fname, hex(fnode))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1190
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1191 repackmod.keepset(repo, keyfn)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1192 return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1193
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1194
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1195 @command(b'debugwaitonrepack', [], _(b'hg debugwaitonrepack'))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1196 def debugwaitonrepack(ui, repo, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1197 return debugcommands.debugwaitonrepack(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1198
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1199
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1200 @command(b'debugwaitonprefetch', [], _(b'hg debugwaitonprefetch'))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1201 def debugwaitonprefetch(ui, repo, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1202 return debugcommands.debugwaitonprefetch(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1203
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1204
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1205 def resolveprefetchopts(ui, opts):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1206 if not opts.get(b'rev'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1207 revset = [b'.', b'draft()']
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1208
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1209 prefetchrevset = ui.config(b'remotefilelog', b'pullprefetch', None)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1210 if prefetchrevset:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1211 revset.append(b'(%s)' % prefetchrevset)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1212 bgprefetchrevs = ui.config(b'remotefilelog', b'bgprefetchrevs', None)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1213 if bgprefetchrevs:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1214 revset.append(b'(%s)' % bgprefetchrevs)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1215 revset = b'+'.join(revset)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1216
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1217 # update a revset with a date limit
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1218 revset = revdatelimit(ui, revset)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1219
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1220 opts[b'rev'] = [revset]
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1221
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1222 if not opts.get(b'base'):
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1223 opts[b'base'] = None
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1224
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1225 return opts
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1226
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1227
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1228 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1229 b'prefetch',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1230 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1231 (b'r', b'rev', [], _(b'prefetch the specified revisions'), _(b'REV')),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1232 (b'', b'repack', False, _(b'run repack after prefetch')),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1233 (b'b', b'base', b'', _(b"rev that is assumed to already be local")),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1234 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1235 + commands.walkopts,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1236 _(b'hg prefetch [OPTIONS] [FILE...]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1237 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1238 def prefetch(ui, repo, *pats, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1239 """prefetch file revisions from the server
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1240
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1241 Prefetchs file revisions for the specified revs and stores them in the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1242 local remotefilelog cache. If no rev is specified, the default rev is
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1243 used which is the union of dot, draft, pullprefetch and bgprefetchrev.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1244 File names or patterns can be used to limit which files are downloaded.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1245
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1246 Return 0 on success.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1247 """
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
1248 opts = pycompat.byteskwargs(opts)
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
1249 if not isenabled(repo):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1250 raise error.Abort(_(b"repo is not shallow"))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1251
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1252 opts = resolveprefetchopts(ui, opts)
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1253 revs = scmutil.revrange(repo, opts.get(b'rev'))
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1254 repo.prefetch(revs, opts.get(b'base'), pats, opts)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1255
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1256 ensurestart = repo.ui.configbool(b'devel', b'remotefilelog.ensurestart')
42852
2c74337e6483 remotefilelog: reduce probability of race-condition in remotefilelog tests
Boris Feld <boris.feld@octobus.net>
parents: 42776
diff changeset
1257
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1258 # Run repack in background
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1259 if opts.get(b'repack'):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1260 repackmod.backgroundrepack(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1261 repo, incremental=True, ensurestart=ensurestart
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1262 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1263
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1264
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1265 @command(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1266 b'repack',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1267 [
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1268 (b'', b'background', None, _(b'run in a background process'), None),
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1269 (b'', b'incremental', None, _(b'do an incremental repack'), None),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1270 (
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1271 b'',
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1272 b'packsonly',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1273 None,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1274 _(b'only repack packs (skip loose objects)'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1275 None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1276 ),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1277 ],
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1278 _(b'hg repack [OPTIONS]'),
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1279 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1280 def repack_(ui, repo, *pats, **opts):
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
1281 if opts.get(r'background'):
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1282 ensurestart = repo.ui.configbool(b'devel', b'remotefilelog.ensurestart')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1283 repackmod.backgroundrepack(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1284 repo,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1285 incremental=opts.get(r'incremental'),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1286 packsonly=opts.get(r'packsonly', False),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1287 ensurestart=ensurestart,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42852
diff changeset
1288 )
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1289 return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1290
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1291 options = {b'packsonly': opts.get(r'packsonly')}
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1292
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1293 try:
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
1294 if opts.get(r'incremental'):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1295 repackmod.incrementalrepack(repo, options=options)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1296 else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1297 repackmod.fullrepack(repo, options=options)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1298 except repackmod.RepackAlreadyRunning as ex:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1299 # Don't propogate the exception if the repack is already in
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
1300 # progress, since we want the command to exit 0.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1301 repo.ui.warn(b'%s\n' % ex)