Mercurial > hg
annotate hgext/largefiles/lfutil.py @ 51676:031d66801d5f
typing: add a trivial type hint to `mercurial/posix.py` to avoid an @overload
Since hg 3dbc7b1ecaba, pytype added an `@overload` for this function, without a
type on the parameter. That's wrong, and undermines the hints on the
non-trivial functions.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 10 Jul 2024 18:05:40 -0400 |
parents | e32f23f15623 |
children | 0b2c978f595f |
rev | line source |
---|---|
15168 | 1 # Copyright 2009-2010 Gregory P. Ward |
2 # Copyright 2009-2010 Intelerad Medical Systems Incorporated | |
3 # Copyright 2010-2011 Fog Creek Software | |
4 # Copyright 2010-2011 Unity Technologies | |
5 # | |
6 # This software may be used and distributed according to the terms of the | |
7 # GNU General Public License version 2 or any later version. | |
8 | |
9 '''largefiles utility code: must not import other modules in this package.''' | |
10 | |
43583
73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43085
diff
changeset
|
11 import contextlib |
29309
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
12 import copy |
15168 | 13 import os |
14 import stat | |
29309
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
15 |
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
16 from mercurial.i18n import _ |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46895
diff
changeset
|
17 from mercurial.node import hex |
43085
eef9a2d67051
py3: manually import pycompat.open into files that need it
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43077
diff
changeset
|
18 from mercurial.pycompat import open |
15168 | 19 |
29309
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
20 from mercurial import ( |
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
21 dirstate, |
30820
6a70cf94d1b5
py3: replace pycompat.getenv with encoding.environ.get
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30664
diff
changeset
|
22 encoding, |
29309
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
23 error, |
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
24 httpconnection, |
29320
016a90152e9c
largefiles: rename match_ to matchmod import in lfutil
liscju <piotr.listkiewicz@gmail.com>
parents:
29309
diff
changeset
|
25 match as matchmod, |
30640
7a3e67bfa417
py3: replace os.name with pycompat.osname (part 2 of 2)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30181
diff
changeset
|
26 pycompat, |
47280
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47012
diff
changeset
|
27 requirements, |
29309
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
28 scmutil, |
33373
fb320398a21c
dirstate: expose a sparse matcher on dirstate (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32309
diff
changeset
|
29 sparse, |
29309
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
30 util, |
31247
04b4286278ec
vfs: use 'vfs' module directly in 'hgext.largefile'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
31 vfs as vfsmod, |
29309
bfc1052570b6
py3: make largefiles/lfutil.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents:
28877
diff
changeset
|
32 ) |
44062
2d49482d0dd4
hgext: replace references to hashlib.sha1 with hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43584
diff
changeset
|
33 from mercurial.utils import hashutil |
48382
991e6f728b50
status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48169
diff
changeset
|
34 from mercurial.dirstateutils import timestamp |
15168 | 35 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
36 shortname = b'.hglf' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
37 shortnameslash = shortname + b'/' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
38 longname = b'largefiles' |
15168 | 39 |
40 # -- Private worker functions ------------------------------------------ | |
41 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
42 |
43583
73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43085
diff
changeset
|
43 @contextlib.contextmanager |
43584
a02e4c12ae60
largefiles: allow "lfstatus" context manager to set value to False
Martin von Zweigbergk <martinvonz@google.com>
parents:
43583
diff
changeset
|
44 def lfstatus(repo, value=True): |
43583
73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43085
diff
changeset
|
45 oldvalue = getattr(repo, 'lfstatus', False) |
43584
a02e4c12ae60
largefiles: allow "lfstatus" context manager to set value to False
Martin von Zweigbergk <martinvonz@google.com>
parents:
43583
diff
changeset
|
46 repo.lfstatus = value |
43583
73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43085
diff
changeset
|
47 try: |
73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43085
diff
changeset
|
48 yield |
73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43085
diff
changeset
|
49 finally: |
73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43085
diff
changeset
|
50 repo.lfstatus = oldvalue |
73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43085
diff
changeset
|
51 |
73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Martin von Zweigbergk <martinvonz@google.com>
parents:
43085
diff
changeset
|
52 |
15227
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
53 def getminsize(ui, assumelfiles, opt, default=10): |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
54 lfsize = opt |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
55 if not lfsize and assumelfiles: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
56 lfsize = ui.config(longname, b'minsize', default=default) |
15227
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
57 if lfsize: |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
58 try: |
15228
ee625de3541e
largefiles: allow minimum size to be a float
Greg Ward <greg@gerg.ca>
parents:
15227
diff
changeset
|
59 lfsize = float(lfsize) |
15227
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
60 except ValueError: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
61 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
62 _(b'largefiles: size must be number (not %s)\n') % lfsize |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
63 ) |
15227
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
64 if lfsize is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
65 raise error.Abort(_(b'minimum size for largefiles must be specified')) |
15227
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
66 return lfsize |
a7686abf73a6
largefiles: factor out lfutil.getminsize()
Greg Ward <greg@gerg.ca>
parents:
15226
diff
changeset
|
67 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
68 |
15168 | 69 def link(src, dest): |
28576
33bd95443e7f
largefiles: add some docstrings
Mads Kiilerich <madski@unity3d.com>
parents:
28575
diff
changeset
|
70 """Try to create hardlink - if that fails, efficiently make a copy.""" |
18998
d035c3902111
largefiles: refactoring - create destination dir in lfutil.link
Mads Kiilerich <madski@unity3d.com>
parents:
18980
diff
changeset
|
71 util.makedirs(os.path.dirname(dest)) |
15168 | 72 try: |
15206
f85c76b16f27
largefiles: fix commit of specified file on non-windows
Na'Tosha Bard <natosha@unity3d.com>
parents:
15188
diff
changeset
|
73 util.oslink(src, dest) |
15168 | 74 except OSError: |
15572
926bc23d0b6a
largefiles: copy files into .hg/largefiles atomically
Martin Geisler <mg@aragost.com>
parents:
15571
diff
changeset
|
75 # if hardlinks fail, fallback on atomic copy |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
76 with open(src, b'rb') as srcf, util.atomictempfile(dest) as dstf: |
33438 | 77 for chunk in util.filechunkiter(srcf): |
78 dstf.write(chunk) | |
15168 | 79 os.chmod(dest, os.stat(src).st_mode) |
80 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
81 |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
82 def usercachepath(ui, hash): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
83 """Return the correct location in the "global" largefiles cache for a file |
28574
7a4e1749cb07
largefiles: refactor usercachepath - extract user cache path function
Mads Kiilerich <madski@unity3d.com>
parents:
28560
diff
changeset
|
84 with the given hash. |
7a4e1749cb07
largefiles: refactor usercachepath - extract user cache path function
Mads Kiilerich <madski@unity3d.com>
parents:
28560
diff
changeset
|
85 This cache is used for sharing of largefiles across repositories - both |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
86 to preserve download bandwidth and storage space.""" |
28575
78e4e558fa74
largefiles: drop partial support for not having a user cache
Mads Kiilerich <madski@unity3d.com>
parents:
28574
diff
changeset
|
87 return os.path.join(_usercachedir(ui), hash) |
28574
7a4e1749cb07
largefiles: refactor usercachepath - extract user cache path function
Mads Kiilerich <madski@unity3d.com>
parents:
28560
diff
changeset
|
88 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
89 |
35279
be4481d6222e
largefiles: refactor _usercachedir() to allow reuse with lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
34757
diff
changeset
|
90 def _usercachedir(ui, name=longname): |
28574
7a4e1749cb07
largefiles: refactor usercachepath - extract user cache path function
Mads Kiilerich <madski@unity3d.com>
parents:
28560
diff
changeset
|
91 '''Return the location of the "global" largefiles cache.''' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
92 path = ui.configpath(name, b'usercache') |
15168 | 93 if path: |
28574
7a4e1749cb07
largefiles: refactor usercachepath - extract user cache path function
Mads Kiilerich <madski@unity3d.com>
parents:
28560
diff
changeset
|
94 return path |
44379
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
95 |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
96 hint = None |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
97 |
34645 | 98 if pycompat.iswindows: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
99 appdata = encoding.environ.get( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
100 b'LOCALAPPDATA', encoding.environ.get(b'APPDATA') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
101 ) |
28574
7a4e1749cb07
largefiles: refactor usercachepath - extract user cache path function
Mads Kiilerich <madski@unity3d.com>
parents:
28560
diff
changeset
|
102 if appdata: |
35279
be4481d6222e
largefiles: refactor _usercachedir() to allow reuse with lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
34757
diff
changeset
|
103 return os.path.join(appdata, name) |
44379
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
104 |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
105 hint = _(b"define %s or %s in the environment, or set %s.usercache") % ( |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
106 b"LOCALAPPDATA", |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
107 b"APPDATA", |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
108 name, |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
109 ) |
34647 | 110 elif pycompat.isdarwin: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
111 home = encoding.environ.get(b'HOME') |
28574
7a4e1749cb07
largefiles: refactor usercachepath - extract user cache path function
Mads Kiilerich <madski@unity3d.com>
parents:
28560
diff
changeset
|
112 if home: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
113 return os.path.join(home, b'Library', b'Caches', name) |
44379
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
114 |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
115 hint = _(b"define %s in the environment, or set %s.usercache") % ( |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
116 b"HOME", |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
117 name, |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
118 ) |
34646 | 119 elif pycompat.isposix: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
120 path = encoding.environ.get(b'XDG_CACHE_HOME') |
28574
7a4e1749cb07
largefiles: refactor usercachepath - extract user cache path function
Mads Kiilerich <madski@unity3d.com>
parents:
28560
diff
changeset
|
121 if path: |
35279
be4481d6222e
largefiles: refactor _usercachedir() to allow reuse with lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
34757
diff
changeset
|
122 return os.path.join(path, name) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
123 home = encoding.environ.get(b'HOME') |
28574
7a4e1749cb07
largefiles: refactor usercachepath - extract user cache path function
Mads Kiilerich <madski@unity3d.com>
parents:
28560
diff
changeset
|
124 if home: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
125 return os.path.join(home, b'.cache', name) |
44379
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
126 |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
127 hint = _(b"define %s or %s in the environment, or set %s.usercache") % ( |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
128 b"XDG_CACHE_HOME", |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
129 b"HOME", |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
130 name, |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
131 ) |
15168 | 132 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
133 raise error.Abort( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
134 _(b'unknown operating system: %s\n') % pycompat.osname |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
135 ) |
44379
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
136 |
ca82929e433d
lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents:
44062
diff
changeset
|
137 raise error.Abort(_(b'unknown %s usercache location') % name, hint=hint) |
15168 | 138 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
139 |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
140 def inusercache(ui, hash): |
15658
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
141 path = usercachepath(ui, hash) |
28575
78e4e558fa74
largefiles: drop partial support for not having a user cache
Mads Kiilerich <madski@unity3d.com>
parents:
28574
diff
changeset
|
142 return os.path.exists(path) |
15168 | 143 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
144 |
15168 | 145 def findfile(repo, hash): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
146 """Return store path of the largefile with the specified hash. |
28576
33bd95443e7f
largefiles: add some docstrings
Mads Kiilerich <madski@unity3d.com>
parents:
28575
diff
changeset
|
147 As a side effect, the file might be linked from user cache. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
148 Return None if the file can't be found locally.""" |
24631
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
149 path, exists = findstorepath(repo, hash) |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
150 if exists: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
151 repo.ui.note(_(b'found %s in store\n') % hash) |
24631
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
152 return path |
15317
41f371150ccb
largefiles: make the store primary, and the user cache secondary
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15316
diff
changeset
|
153 elif inusercache(repo.ui, hash): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
154 repo.ui.note(_(b'found %s in system cache\n') % hash) |
15408
db8b0ee74025
largefiles: ensure destination directory exists before findfile links to there
Hao Lian <hao@fogcreek.com>
parents:
15392
diff
changeset
|
155 path = storepath(repo, hash) |
db8b0ee74025
largefiles: ensure destination directory exists before findfile links to there
Hao Lian <hao@fogcreek.com>
parents:
15392
diff
changeset
|
156 link(usercachepath(repo.ui, hash), path) |
15913
c35dcde25174
largefiles: refactor lfutil.findfiles to be more logical
Na'Tosha Bard <natosha@unity3d.com>
parents:
15796
diff
changeset
|
157 return path |
c35dcde25174
largefiles: refactor lfutil.findfiles to be more logical
Na'Tosha Bard <natosha@unity3d.com>
parents:
15796
diff
changeset
|
158 return None |
15168 | 159 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
160 |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
161 class largefilesdirstate(dirstate.dirstate): |
50027
0b4a6912292e
largefiles: link the core dirstate._changing context to the lfdirstate one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50020
diff
changeset
|
162 _large_file_dirstate = True |
50123
4e95341c89aa
dirstate: distinct transaction callback from largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50116
diff
changeset
|
163 _tr_key_suffix = b'-large-files' |
50027
0b4a6912292e
largefiles: link the core dirstate._changing context to the lfdirstate one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50020
diff
changeset
|
164 |
15168 | 165 def __getitem__(self, key): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
166 return super(largefilesdirstate, self).__getitem__(unixpath(key)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
167 |
47593
f927ad5a4e2c
dirstate: add a `set_tracked` method for "hg add"-like usage
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47545
diff
changeset
|
168 def set_tracked(self, f): |
f927ad5a4e2c
dirstate: add a `set_tracked` method for "hg add"-like usage
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47545
diff
changeset
|
169 return super(largefilesdirstate, self).set_tracked(unixpath(f)) |
f927ad5a4e2c
dirstate: add a `set_tracked` method for "hg add"-like usage
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47545
diff
changeset
|
170 |
47599
cce51119bfe6
dirstate: add a `set_untracked` method for "hg remove"-like usage
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47593
diff
changeset
|
171 def set_untracked(self, f): |
cce51119bfe6
dirstate: add a `set_untracked` method for "hg remove"-like usage
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47593
diff
changeset
|
172 return super(largefilesdirstate, self).set_untracked(unixpath(f)) |
cce51119bfe6
dirstate: add a `set_untracked` method for "hg remove"-like usage
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47593
diff
changeset
|
173 |
47712
95b864a670df
largefile: respect the `normal` signature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47700
diff
changeset
|
174 def normal(self, f, parentfiledata=None): |
95b864a670df
largefile: respect the `normal` signature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47700
diff
changeset
|
175 # not sure if we should pass the `parentfiledata` down or throw it |
95b864a670df
largefile: respect the `normal` signature
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47700
diff
changeset
|
176 # away. So throwing it away to stay on the safe side. |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
177 return super(largefilesdirstate, self).normal(unixpath(f)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
178 |
15168 | 179 def remove(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
180 return super(largefilesdirstate, self).remove(unixpath(f)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
181 |
15168 | 182 def add(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
183 return super(largefilesdirstate, self).add(unixpath(f)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
184 |
15168 | 185 def drop(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
186 return super(largefilesdirstate, self).drop(unixpath(f)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
187 |
15168 | 188 def forget(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
189 return super(largefilesdirstate, self).forget(unixpath(f)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
190 |
15793
3ef07ecdb0d5
largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents:
15700
diff
changeset
|
191 def normallookup(self, f): |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
192 return super(largefilesdirstate, self).normallookup(unixpath(f)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
193 |
21085
66c6da0bc7e2
largefiles: fix profile of unused largefilesdirstate._ignore
Mads Kiilerich <madski@unity3d.com>
parents:
21042
diff
changeset
|
194 def _ignore(self, f): |
18148
bf6252d12c34
largefiles: simplify lfdirstate ignore handling - it is only for tracking .hglf
Mads Kiilerich <madski@unity3d.com>
parents:
18147
diff
changeset
|
195 return False |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
196 |
48168
df3021c1f093
largefiles: pass current transaction to `lfdirstate.write()`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48144
diff
changeset
|
197 def write(self, tr): |
26749
4a82cb5c1dc8
dirstate: show develwarn for write() invocation without transaction
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26627
diff
changeset
|
198 # (1) disable PENDING mode always |
4a82cb5c1dc8
dirstate: show develwarn for write() invocation without transaction
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26627
diff
changeset
|
199 # (lfdirstate isn't yet managed as a part of the transaction) |
4a82cb5c1dc8
dirstate: show develwarn for write() invocation without transaction
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26627
diff
changeset
|
200 # (2) avoid develwarn 'use dirstate.write with ....' |
48169
1e98f9b5bc71
largefiles: add tr backup for largefilesdirstate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48168
diff
changeset
|
201 if tr: |
1e98f9b5bc71
largefiles: add tr backup for largefilesdirstate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
48168
diff
changeset
|
202 tr.addbackup(b'largefiles/dirstate', location=b'plain') |
26749
4a82cb5c1dc8
dirstate: show develwarn for write() invocation without transaction
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26627
diff
changeset
|
203 super(largefilesdirstate, self).write(None) |
15168 | 204 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
205 |
17659
ae57920ac188
largefiles: enable islfilesrepo() prior to a commit (issue3541)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17270
diff
changeset
|
206 def openlfdirstate(ui, repo, create=True): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
207 """ |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
208 Return a dirstate object that tracks largefiles: i.e. its root is |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
209 the repo root, but it is saved in .hg/largefiles/dirstate. |
50027
0b4a6912292e
largefiles: link the core dirstate._changing context to the lfdirstate one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50020
diff
changeset
|
210 |
0b4a6912292e
largefiles: link the core dirstate._changing context to the lfdirstate one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50020
diff
changeset
|
211 If a dirstate object already exists and is being used for a 'changing_*' |
0b4a6912292e
largefiles: link the core dirstate._changing context to the lfdirstate one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50020
diff
changeset
|
212 context, it will be returned. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
213 """ |
50027
0b4a6912292e
largefiles: link the core dirstate._changing context to the lfdirstate one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50020
diff
changeset
|
214 sub_dirstate = getattr(repo.dirstate, '_sub_dirstate', None) |
0b4a6912292e
largefiles: link the core dirstate._changing context to the lfdirstate one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50020
diff
changeset
|
215 if sub_dirstate is not None: |
0b4a6912292e
largefiles: link the core dirstate._changing context to the lfdirstate one
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50020
diff
changeset
|
216 return sub_dirstate |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
217 vfs = repo.vfs |
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
218 lfstoredir = longname |
31247
04b4286278ec
vfs: use 'vfs' module directly in 'hgext.largefile'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31216
diff
changeset
|
219 opener = vfsmod.vfs(vfs.join(lfstoredir)) |
47280
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47012
diff
changeset
|
220 use_dirstate_v2 = requirements.DIRSTATE_V2_REQUIREMENT in repo.requirements |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
221 lfdirstate = largefilesdirstate( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
222 opener, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
223 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
224 repo.root, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
225 repo.dirstate._validate, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
226 lambda: sparse.matcher(repo), |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
227 repo.nodeconstants, |
47280
1766130fe9ba
dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents:
47012
diff
changeset
|
228 use_dirstate_v2, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
229 ) |
15168 | 230 |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
231 # If the largefiles dirstate does not exist, populate and create |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
232 # it. This ensures that we create it on the first meaningful |
15794
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
233 # largefiles operation in a new clone. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
234 if create and not vfs.exists(vfs.join(lfstoredir, b'dirstate')): |
49965
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
235 try: |
50153
98890baf324e
large-files: use a `changing_files` context when initializing the dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50137
diff
changeset
|
236 with repo.wlock(wait=False), lfdirstate.changing_files(repo): |
49965
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
237 matcher = getstandinmatcher(repo) |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
238 standins = repo.dirstate.walk( |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
239 matcher, subrepos=[], unknown=False, ignored=False |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
240 ) |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
241 |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
242 if len(standins) > 0: |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
243 vfs.makedirs(lfstoredir) |
21917
ac3b3a2d976d
largefiles: avoid unnecessary creation of .hg/largefiles when opening lfdirstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
21085
diff
changeset
|
244 |
50020
e2f3cba678ce
largefiles: remove the `changing_parents` context in `openlfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50016
diff
changeset
|
245 for standin in standins: |
e2f3cba678ce
largefiles: remove the `changing_parents` context in `openlfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50016
diff
changeset
|
246 lfile = splitstandin(standin) |
e2f3cba678ce
largefiles: remove the `changing_parents` context in `openlfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50016
diff
changeset
|
247 lfdirstate.hacky_extension_update_file( |
e2f3cba678ce
largefiles: remove the `changing_parents` context in `openlfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50016
diff
changeset
|
248 lfile, |
e2f3cba678ce
largefiles: remove the `changing_parents` context in `openlfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50016
diff
changeset
|
249 p1_tracked=True, |
e2f3cba678ce
largefiles: remove the `changing_parents` context in `openlfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50016
diff
changeset
|
250 wc_tracked=True, |
e2f3cba678ce
largefiles: remove the `changing_parents` context in `openlfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50016
diff
changeset
|
251 possibly_dirty=True, |
e2f3cba678ce
largefiles: remove the `changing_parents` context in `openlfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50016
diff
changeset
|
252 ) |
49965
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
253 except error.LockError: |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
254 # Assume that whatever was holding the lock was important. |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
255 # If we were doing something important, we would already have |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
256 # either the lock or a largefile dirstate. |
0cf4c1b80fd9
largefile: make sure we hold the lock when updating the second dirstate
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
257 pass |
15168 | 258 return lfdirstate |
259 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
260 |
23039
1350b9170089
largefiles: remove confusing rev parameter for lfdirstatestatus
Mads Kiilerich <madski@unity3d.com>
parents:
22919
diff
changeset
|
261 def lfdirstatestatus(lfdirstate, repo): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
262 pctx = repo[b'.'] |
41676
0531dff73d0b
match: delete unused root and cwd arguments from {always,never,exact}() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41397
diff
changeset
|
263 match = matchmod.always() |
48390
322525db4c98
status: use filesystem time boundary to invalidate racy mtime
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48382
diff
changeset
|
264 unsure, s, mtime_boundary = lfdirstate.status( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
265 match, subrepos=[], ignored=False, clean=False, unknown=False |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
266 ) |
22919
1982bdb7e2cc
largefiles: access status fields by name rather than index
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22912
diff
changeset
|
267 modified, clean = s.modified, s.clean |
48382
991e6f728b50
status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48169
diff
changeset
|
268 wctx = repo[None] |
15794
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
269 for lfile in unsure: |
18299
a7a88a458a4c
largefiles: fix revert removing a largefile from a merge
Mads Kiilerich <madski@unity3d.com>
parents:
18154
diff
changeset
|
270 try: |
31657
641f3a6098d0
largefiles: rename local variable appropriately
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31652
diff
changeset
|
271 fctx = pctx[standin(lfile)] |
18299
a7a88a458a4c
largefiles: fix revert removing a largefile from a merge
Mads Kiilerich <madski@unity3d.com>
parents:
18154
diff
changeset
|
272 except LookupError: |
a7a88a458a4c
largefiles: fix revert removing a largefile from a merge
Mads Kiilerich <madski@unity3d.com>
parents:
18154
diff
changeset
|
273 fctx = None |
31740
a40e979b9d97
largefiles: use readasstandin() to read hex hash directly from filectx
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31739
diff
changeset
|
274 if not fctx or readasstandin(fctx) != hashfile(repo.wjoin(lfile)): |
15794
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
275 modified.append(lfile) |
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
276 else: |
0d91211dd12f
largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents:
15793
diff
changeset
|
277 clean.append(lfile) |
48382
991e6f728b50
status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48169
diff
changeset
|
278 st = wctx[lfile].lstat() |
991e6f728b50
status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48169
diff
changeset
|
279 mode = st.st_mode |
991e6f728b50
status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48169
diff
changeset
|
280 size = st.st_size |
48396
c0d88407b7d4
largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48390
diff
changeset
|
281 mtime = timestamp.reliable_mtime_of(st, mtime_boundary) |
c0d88407b7d4
largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48390
diff
changeset
|
282 if mtime is not None: |
c0d88407b7d4
largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48390
diff
changeset
|
283 cache_data = (mode, size, mtime) |
c0d88407b7d4
largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48390
diff
changeset
|
284 lfdirstate.set_clean(lfile, cache_data) |
22912
3b8e6c095239
lfutil: avoid creating unnecessary copy of status tuple
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22911
diff
changeset
|
285 return s |
15168 | 286 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
287 |
15168 | 288 def listlfiles(repo, rev=None, matcher=None): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
289 """return a list of largefiles in the working copy or the |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
290 specified changeset""" |
15168 | 291 |
292 if matcher is None: | |
293 matcher = getstandinmatcher(repo) | |
294 | |
295 # ignore unknown files in working directory | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
296 return [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
297 splitstandin(f) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
298 for f in repo[rev].walk(matcher) |
48106
82e142b9ad18
dirstate-item: use item's property instead of `state` in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47755
diff
changeset
|
299 if rev is not None or repo.dirstate.get_entry(f).any_tracked |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
300 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
301 |
15168 | 302 |
24631
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
303 def instore(repo, hash, forcelocal=False): |
29419
01c0324acfec
largefiles: fix misleading comments in lfutil instore and storepath
liscju <piotr.listkiewicz@gmail.com>
parents:
29349
diff
changeset
|
304 '''Return true if a largefile with the given hash exists in the store''' |
24631
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
305 return os.path.exists(storepath(repo, hash, forcelocal)) |
15168 | 306 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
307 |
24631
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
308 def storepath(repo, hash, forcelocal=False): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
309 """Return the correct location in the repository largefiles store for a |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
310 file with the given hash.""" |
24631
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
311 if not forcelocal and repo.shared(): |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
312 return repo.vfs.reljoin(repo.sharedpath, longname, hash) |
31332
a5ae1d79e271
largefiles: directly use repo.vfs.join
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31247
diff
changeset
|
313 return repo.vfs.join(longname, hash) |
15168 | 314 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
315 |
24629
8dc2533f03ef
largefiles: introduce lfutil.findstorepath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24627
diff
changeset
|
316 def findstorepath(repo, hash): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
317 """Search through the local store path(s) to find the file for the given |
24629
8dc2533f03ef
largefiles: introduce lfutil.findstorepath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24627
diff
changeset
|
318 hash. If the file is not found, its path in the primary store is returned. |
8dc2533f03ef
largefiles: introduce lfutil.findstorepath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24627
diff
changeset
|
319 The return value is a tuple of (path, exists(path)). |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
320 """ |
24631
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
321 # For shared repos, the primary store is in the share source. But for |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
322 # backward compatibility, force a lookup in the local store if it wasn't |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
323 # found in the share source. |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
324 path = storepath(repo, hash, False) |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
325 |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
326 if instore(repo, hash): |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
327 return (path, True) |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
328 elif repo.shared() and instore(repo, hash, True): |
29329
f359cdc91e21
largefiles: fix support for local largefiles while using share extension
Henrik Stuart <henriks@unity3d.com>
parents:
28877
diff
changeset
|
329 return storepath(repo, hash, True), True |
24631
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
330 |
2a3f24786d09
largefiles: use the share source as the primary local store (issue4471)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24629
diff
changeset
|
331 return (path, False) |
24629
8dc2533f03ef
largefiles: introduce lfutil.findstorepath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24627
diff
changeset
|
332 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
333 |
15168 | 334 def copyfromcache(repo, hash, filename): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
335 """Copy the specified largefile from the repo or system cache to |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
336 filename in the repository. Return true on success or false if the |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
337 file was not found in either cache (which should not happened: |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
338 this is meant to be called only after ensuring that the needed |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
339 largefile exists in the cache).""" |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
340 wvfs = repo.wvfs |
15168 | 341 path = findfile(repo, hash) |
342 if path is None: | |
343 return False | |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
344 wvfs.makedirs(wvfs.dirname(wvfs.join(filename))) |
15570
0f208626d503
largefiles: add comment about non-atomic working directory
Martin Geisler <mg@aragost.com>
parents:
15553
diff
changeset
|
345 # The write may fail before the file is fully written, but we |
0f208626d503
largefiles: add comment about non-atomic working directory
Martin Geisler <mg@aragost.com>
parents:
15553
diff
changeset
|
346 # don't use atomic writes in the working copy. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
347 with open(path, b'rb') as srcfd, wvfs(filename, b'wb') as destfd: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
348 gothash = copyandhash(util.filechunkiter(srcfd), destfd) |
26823
45e8bd2f36f0
largefiles: check hash of files in the store before copying to working dir
Mads Kiilerich <madski@unity3d.com>
parents:
26817
diff
changeset
|
349 if gothash != hash: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
350 repo.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
351 _(b'%s: data corruption in %s with hash %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
352 % (filename, path, gothash) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
353 ) |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
354 wvfs.unlink(filename) |
26823
45e8bd2f36f0
largefiles: check hash of files in the store before copying to working dir
Mads Kiilerich <madski@unity3d.com>
parents:
26817
diff
changeset
|
355 return False |
15168 | 356 return True |
357 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
358 |
31738
068b06b43cdf
largefiles: make copytostore() accept only changectx as the 2nd argument (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31737
diff
changeset
|
359 def copytostore(repo, ctx, file, fstandin): |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
360 wvfs = repo.wvfs |
31738
068b06b43cdf
largefiles: make copytostore() accept only changectx as the 2nd argument (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31737
diff
changeset
|
361 hash = readasstandin(ctx[fstandin]) |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
362 if instore(repo, hash): |
15168 | 363 return |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
364 if wvfs.exists(file): |
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
365 copytostoreabsolute(repo, wvfs.join(file), hash) |
27903
512a814c5595
largefiles: fix commit of missing largefiles
Mads Kiilerich <madski@unity3d.com>
parents:
26823
diff
changeset
|
366 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
367 repo.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
368 _(b"%s: largefile %s not available from local store\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
369 % (file, hash) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
370 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
371 |
15168 | 372 |
15796
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
373 def copyalltostore(repo, node): |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
374 '''Copy all largefiles in a given revision to the store''' |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
375 |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
376 ctx = repo[node] |
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
377 for filename in ctx.files(): |
31613
5c1d3f1b8f44
largefiles: omit redundant isstandin() before splitstandin()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31332
diff
changeset
|
378 realfile = splitstandin(filename) |
5c1d3f1b8f44
largefiles: omit redundant isstandin() before splitstandin()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31332
diff
changeset
|
379 if realfile is not None and filename in ctx.manifest(): |
31736
dd2079fae003
largefiles: add copytostore() fstandin argument to replace readstandin() (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31735
diff
changeset
|
380 copytostore(repo, ctx, realfile, filename) |
15796
3e5b6045ccfc
largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
15794
diff
changeset
|
381 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
382 |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
383 def copytostoreabsolute(repo, file, hash): |
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
384 if inusercache(repo.ui, hash): |
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
385 link(usercachepath(repo.ui, hash), storepath(repo, hash)) |
23276
4be754832829
largefiles: move "copyalltostore" invocation into "markcommitted"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23274
diff
changeset
|
386 else: |
18998
d035c3902111
largefiles: refactoring - create destination dir in lfutil.link
Mads Kiilerich <madski@unity3d.com>
parents:
18980
diff
changeset
|
387 util.makedirs(os.path.dirname(storepath(repo, hash))) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
388 with open(file, b'rb') as srcf: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
389 with util.atomictempfile( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
390 storepath(repo, hash), createmode=repo.store.createmode |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
391 ) as dstf: |
30142
3dcaf1c4e90d
largefiles: use context for file closing
Mads Kiilerich <madski@unity3d.com>
parents:
29644
diff
changeset
|
392 for chunk in util.filechunkiter(srcf): |
3dcaf1c4e90d
largefiles: use context for file closing
Mads Kiilerich <madski@unity3d.com>
parents:
29644
diff
changeset
|
393 dstf.write(chunk) |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
394 linktousercache(repo, hash) |
15168 | 395 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
396 |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15304
diff
changeset
|
397 def linktousercache(repo, hash): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
398 """Link / copy the largefile with the specified hash from the store |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
399 to the cache.""" |
15658
971c55ce03b8
largefiles: don't require a user cache (issue3088) (issue3155)
Kevin Gessner <kevin@fogcreek.com>
parents:
15572
diff
changeset
|
400 path = usercachepath(repo.ui, hash) |
28575
78e4e558fa74
largefiles: drop partial support for not having a user cache
Mads Kiilerich <madski@unity3d.com>
parents:
28574
diff
changeset
|
401 link(storepath(repo, hash), path) |
15168 | 402 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
403 |
25292
31d543cd7062
largefiles: pass in whole matcher to getstandinmatcher()
Martin von Zweigbergk <martinvonz@google.com>
parents:
25291
diff
changeset
|
404 def getstandinmatcher(repo, rmatcher=None): |
31d543cd7062
largefiles: pass in whole matcher to getstandinmatcher()
Martin von Zweigbergk <martinvonz@google.com>
parents:
25291
diff
changeset
|
405 '''Return a match object that applies rmatcher to the standin directory''' |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
406 wvfs = repo.wvfs |
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
407 standindir = shortname |
25470
378a8e700e02
largefiles: use the optional badfn argument when building a matcher
Matt Harbison <matt_harbison@yahoo.com>
parents:
25293
diff
changeset
|
408 |
378a8e700e02
largefiles: use the optional badfn argument when building a matcher
Matt Harbison <matt_harbison@yahoo.com>
parents:
25293
diff
changeset
|
409 # no warnings about missing files or directories |
378a8e700e02
largefiles: use the optional badfn argument when building a matcher
Matt Harbison <matt_harbison@yahoo.com>
parents:
25293
diff
changeset
|
410 badfn = lambda f, msg: None |
378a8e700e02
largefiles: use the optional badfn argument when building a matcher
Matt Harbison <matt_harbison@yahoo.com>
parents:
25293
diff
changeset
|
411 |
25293
ab618e52788a
largefiles: avoid match.files() in conditions
Martin von Zweigbergk <martinvonz@google.com>
parents:
25292
diff
changeset
|
412 if rmatcher and not rmatcher.always(): |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
413 pats = [wvfs.join(standindir, pat) for pat in rmatcher.files()] |
26025
ba8089433090
largefiles: ensure lfutil.getstandinmatcher() only matches standins
Matt Harbison <matt_harbison@yahoo.com>
parents:
25470
diff
changeset
|
414 if not pats: |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
415 pats = [wvfs.join(standindir)] |
25470
378a8e700e02
largefiles: use the optional badfn argument when building a matcher
Matt Harbison <matt_harbison@yahoo.com>
parents:
25293
diff
changeset
|
416 match = scmutil.match(repo[None], pats, badfn=badfn) |
18724
894a5897a9dd
largefiles: getstandinmatcher should not depend on existence of directories
Mads Kiilerich <madski@unity3d.com>
parents:
18490
diff
changeset
|
417 else: |
15168 | 418 # no patterns: relative to repo root |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
419 match = scmutil.match(repo[None], [wvfs.join(standindir)], badfn=badfn) |
15168 | 420 return match |
421 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
422 |
15168 | 423 def composestandinmatcher(repo, rmatcher): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
424 """Return a matcher that accepts standins corresponding to the |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
425 files accepted by rmatcher. Pass the list of files in the matcher |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
426 as the paths specified by the user.""" |
25292
31d543cd7062
largefiles: pass in whole matcher to getstandinmatcher()
Martin von Zweigbergk <martinvonz@google.com>
parents:
25291
diff
changeset
|
427 smatcher = getstandinmatcher(repo, rmatcher) |
15168 | 428 isstandin = smatcher.matchfn |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
429 |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
430 def composedmatchfn(f): |
15168 | 431 return isstandin(f) and rmatcher.matchfn(splitstandin(f)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
432 |
51624
e32f23f15623
largefiles: mark more matchers as having been tampered with
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50928
diff
changeset
|
433 smatcher._was_tampered_with = True |
16247
d87d9d8a8e03
largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents:
16245
diff
changeset
|
434 smatcher.matchfn = composedmatchfn |
15168 | 435 |
436 return smatcher | |
437 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
438 |
15168 | 439 def standin(filename): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
440 """Return the repo-relative path to the standin for the specified big |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
441 file.""" |
15168 | 442 # Notes: |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
17270
diff
changeset
|
443 # 1) Some callers want an absolute path, but for instance addlargefiles |
18154
93c697d9c158
largefiles: remove trivial portability wrappers
Mads Kiilerich <madski@unity3d.com>
parents:
18153
diff
changeset
|
444 # needs it repo-relative so it can be passed to repo[None].add(). So |
93c697d9c158
largefiles: remove trivial portability wrappers
Mads Kiilerich <madski@unity3d.com>
parents:
18153
diff
changeset
|
445 # leave it up to the caller to use repo.wjoin() to get an absolute path. |
15168 | 446 # 2) Join with '/' because that's what dirstate always uses, even on |
447 # Windows. Change existing separator to '/' first in case we are | |
448 # passed filenames from an external source (like the command line). | |
18151
90ad387d9245
largefiles: use constant for '.hglf/'
Mads Kiilerich <madski@unity3d.com>
parents:
18150
diff
changeset
|
449 return shortnameslash + util.pconvert(filename) |
15168 | 450 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
451 |
15168 | 452 def isstandin(filename): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
453 """Return true if filename is a big file standin. filename must be |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
454 in Mercurial's internal form (slash-separated).""" |
18151
90ad387d9245
largefiles: use constant for '.hglf/'
Mads Kiilerich <madski@unity3d.com>
parents:
18150
diff
changeset
|
455 return filename.startswith(shortnameslash) |
15168 | 456 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
457 |
15168 | 458 def splitstandin(filename): |
459 # Split on / because that's what dirstate always uses, even on Windows. | |
460 # Change local separator to / first just in case we are passed filenames | |
461 # from an external source (like the command line). | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
462 bits = util.pconvert(filename).split(b'/', 1) |
15168 | 463 if len(bits) == 2 and bits[0] == shortname: |
464 return bits[1] | |
465 else: | |
466 return None | |
467 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
468 |
31659
0eec36112e58
largefiles: add lfile argument to updatestandin() for efficiency (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31657
diff
changeset
|
469 def updatestandin(repo, lfile, standin): |
0eec36112e58
largefiles: add lfile argument to updatestandin() for efficiency (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31657
diff
changeset
|
470 """Re-calculate hash value of lfile and write it into standin |
0eec36112e58
largefiles: add lfile argument to updatestandin() for efficiency (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31657
diff
changeset
|
471 |
0eec36112e58
largefiles: add lfile argument to updatestandin() for efficiency (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31657
diff
changeset
|
472 This assumes that "lfutil.standin(lfile) == standin", for efficiency. |
0eec36112e58
largefiles: add lfile argument to updatestandin() for efficiency (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31657
diff
changeset
|
473 """ |
31615
f0f316cb8259
largefiles: omit redundant splitstandin() invocations
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31613
diff
changeset
|
474 file = repo.wjoin(lfile) |
f0f316cb8259
largefiles: omit redundant splitstandin() invocations
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31613
diff
changeset
|
475 if repo.wvfs.exists(lfile): |
15168 | 476 hash = hashfile(file) |
477 executable = getexecutable(file) | |
478 writestandin(repo, standin, hash, executable) | |
27947
571ba161f6be
largefiles: prevent committing a missing largefile
Matt Harbison <matt_harbison@yahoo.com>
parents:
27942
diff
changeset
|
479 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
480 raise error.Abort(_(b'%s: file not found!') % lfile) |
15168 | 481 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
482 |
31734
44ff5e4ffc8c
largefiles: introduce readasstandin() to read hex hash from given filectx
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31659
diff
changeset
|
483 def readasstandin(fctx): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
484 """read hex hash from given filectx of standin file |
31734
44ff5e4ffc8c
largefiles: introduce readasstandin() to read hex hash from given filectx
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31659
diff
changeset
|
485 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
486 This encapsulates how "standin" data is stored into storage layer.""" |
31734
44ff5e4ffc8c
largefiles: introduce readasstandin() to read hex hash from given filectx
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31659
diff
changeset
|
487 return fctx.data().strip() |
44ff5e4ffc8c
largefiles: introduce readasstandin() to read hex hash from given filectx
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31659
diff
changeset
|
488 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
489 |
15168 | 490 def writestandin(repo, standin, hash, executable): |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
491 '''write hash to <repo.root>/<standin>''' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
492 repo.wwrite(standin, hash + b'\n', executable and b'x' or b'') |
15168 | 493 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
494 |
15168 | 495 def copyandhash(instream, outfile): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
496 """Read bytes from instream (iterable) and write them to outfile, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
497 computing the SHA-1 hash of the data along the way. Return the hash.""" |
44062
2d49482d0dd4
hgext: replace references to hashlib.sha1 with hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43584
diff
changeset
|
498 hasher = hashutil.sha1(b'') |
15168 | 499 for data in instream: |
500 hasher.update(data) | |
501 outfile.write(data) | |
36112
6426878f7f0f
py3: use hex(hasher.digest())
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35279
diff
changeset
|
502 return hex(hasher.digest()) |
15168 | 503 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
504 |
15168 | 505 def hashfile(file): |
506 if not os.path.exists(file): | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
507 return b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
508 with open(file, b'rb') as fd: |
31652
d5cbbee542eb
largefiles: reuse hexsha1() to centralize hash calculation logic into it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31618
diff
changeset
|
509 return hexsha1(fd) |
15168 | 510 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
511 |
15168 | 512 def getexecutable(filename): |
513 mode = os.stat(filename).st_mode | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
514 return ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
515 (mode & stat.S_IXUSR) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
516 and (mode & stat.S_IXGRP) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
517 and (mode & stat.S_IXOTH) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
518 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
519 |
15168 | 520 |
521 def urljoin(first, second, *arg): | |
522 def join(left, right): | |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
523 if not left.endswith(b'/'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
524 left += b'/' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
525 if right.startswith(b'/'): |
15168 | 526 right = right[1:] |
527 return left + right | |
528 | |
529 url = join(first, second) | |
530 for a in arg: | |
531 url = join(url, a) | |
532 return url | |
533 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
534 |
31652
d5cbbee542eb
largefiles: reuse hexsha1() to centralize hash calculation logic into it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31618
diff
changeset
|
535 def hexsha1(fileobj): |
15168 | 536 """hexsha1 returns the hex-encoded sha1 sum of the data in the file-like |
537 object data""" | |
44062
2d49482d0dd4
hgext: replace references to hashlib.sha1 with hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43584
diff
changeset
|
538 h = hashutil.sha1() |
31652
d5cbbee542eb
largefiles: reuse hexsha1() to centralize hash calculation logic into it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31618
diff
changeset
|
539 for chunk in util.filechunkiter(fileobj): |
15168 | 540 h.update(chunk) |
36112
6426878f7f0f
py3: use hex(hasher.digest())
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35279
diff
changeset
|
541 return hex(h.digest()) |
15168 | 542 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
543 |
15168 | 544 def httpsendfile(ui, filename): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
545 return httpconnection.httpsendfile(ui, filename, b'rb') |
15168 | 546 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
547 |
15168 | 548 def unixpath(path): |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15228
diff
changeset
|
549 '''Return a version of path normalized for use with the lfdirstate.''' |
16066
6a42846cf769
i18n: use util.pconvert() instead of 'str.replace()' for problematic encoding
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15915
diff
changeset
|
550 return util.pconvert(os.path.normpath(path)) |
15168 | 551 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
552 |
15168 | 553 def islfilesrepo(repo): |
28576
33bd95443e7f
largefiles: add some docstrings
Mads Kiilerich <madski@unity3d.com>
parents:
28575
diff
changeset
|
554 '''Return true if the repo is a largefile repo.''' |
50488
b4a9c8f18928
store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50471
diff
changeset
|
555 if b'largefiles' in repo.requirements: |
50504
862e3a13da44
store: rename `datafiles` to `data_entries`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50488
diff
changeset
|
556 for entry in repo.store.data_entries(): |
50488
b4a9c8f18928
store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50471
diff
changeset
|
557 if entry.is_revlog and shortnameslash in entry.target_id: |
b4a9c8f18928
store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50471
diff
changeset
|
558 return True |
17659
ae57920ac188
largefiles: enable islfilesrepo() prior to a commit (issue3541)
Matt Harbison <matt_harbison@yahoo.com>
parents:
17270
diff
changeset
|
559 |
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
24631
diff
changeset
|
560 return any(openlfdirstate(repo.ui, repo, False)) |
15168 | 561 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
562 |
15333
f37b71fec602
largefiles: py2.4 doesn't have BaseException
Matt Mackall <mpm@selenic.com>
parents:
15320
diff
changeset
|
563 class storeprotonotcapable(Exception): |
15168 | 564 def __init__(self, storetypes): |
565 self.storetypes = storetypes | |
16103
3e1efb458e8b
largefiles: only cache largefiles in new heads
Na'Tosha Bard <natosha@unity3d.com>
parents:
16066
diff
changeset
|
566 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
567 |
16120
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
568 def getstandinsstate(repo): |
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
569 standins = [] |
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
570 matcher = getstandinmatcher(repo) |
31735
3e37b479ce2f
largefiles: replace readstandin() by readasstandin()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31734
diff
changeset
|
571 wctx = repo[None] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
572 for standin in repo.dirstate.walk( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
573 matcher, subrepos=[], unknown=False, ignored=False |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
574 ): |
16120
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
575 lfile = splitstandin(standin) |
18300
745bc16ccef2
largefiles: fix update from a merge with removed files
Mads Kiilerich <madski@unity3d.com>
parents:
18299
diff
changeset
|
576 try: |
31735
3e37b479ce2f
largefiles: replace readstandin() by readasstandin()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31734
diff
changeset
|
577 hash = readasstandin(wctx[standin]) |
18300
745bc16ccef2
largefiles: fix update from a merge with removed files
Mads Kiilerich <madski@unity3d.com>
parents:
18299
diff
changeset
|
578 except IOError: |
745bc16ccef2
largefiles: fix update from a merge with removed files
Mads Kiilerich <madski@unity3d.com>
parents:
18299
diff
changeset
|
579 hash = None |
745bc16ccef2
largefiles: fix update from a merge with removed files
Mads Kiilerich <madski@unity3d.com>
parents:
18299
diff
changeset
|
580 standins.append((lfile, hash)) |
16120
47ee41fcf42b
largefiles: optimize update speed by only updating changed largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents:
16103
diff
changeset
|
581 return standins |
16245
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
582 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
583 |
22095
cb62d77c7a01
largefiles: factor out synchronization of lfdirstate for future use
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21917
diff
changeset
|
584 def synclfdirstate(repo, lfdirstate, lfile, normallookup): |
cb62d77c7a01
largefiles: factor out synchronization of lfdirstate for future use
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21917
diff
changeset
|
585 lfstandin = standin(lfile) |
47699
034979d24c7b
largefile: rearrange conditionnal in `synclfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47656
diff
changeset
|
586 if lfstandin not in repo.dirstate: |
50016
c694db2d8876
largefiles: use `hacky_extension_update_file` in `synclfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50015
diff
changeset
|
587 lfdirstate.hacky_extension_update_file( |
c694db2d8876
largefiles: use `hacky_extension_update_file` in `synclfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50015
diff
changeset
|
588 lfile, |
c694db2d8876
largefiles: use `hacky_extension_update_file` in `synclfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50015
diff
changeset
|
589 p1_tracked=False, |
c694db2d8876
largefiles: use `hacky_extension_update_file` in `synclfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50015
diff
changeset
|
590 wc_tracked=False, |
c694db2d8876
largefiles: use `hacky_extension_update_file` in `synclfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50015
diff
changeset
|
591 ) |
47699
034979d24c7b
largefile: rearrange conditionnal in `synclfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47656
diff
changeset
|
592 else: |
48144
6f54afb094bd
dirstate: align the dirstate's API to the lower level ones
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48106
diff
changeset
|
593 entry = repo.dirstate.get_entry(lfstandin) |
50016
c694db2d8876
largefiles: use `hacky_extension_update_file` in `synclfdirstate`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50015
diff
changeset
|
594 lfdirstate.hacky_extension_update_file( |
48144
6f54afb094bd
dirstate: align the dirstate's API to the lower level ones
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48106
diff
changeset
|
595 lfile, |
6f54afb094bd
dirstate: align the dirstate's API to the lower level ones
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48106
diff
changeset
|
596 wc_tracked=entry.tracked, |
6f54afb094bd
dirstate: align the dirstate's API to the lower level ones
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48106
diff
changeset
|
597 p1_tracked=entry.p1_tracked, |
6f54afb094bd
dirstate: align the dirstate's API to the lower level ones
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48106
diff
changeset
|
598 p2_info=entry.p2_info, |
6f54afb094bd
dirstate: align the dirstate's API to the lower level ones
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48106
diff
changeset
|
599 possibly_dirty=True, |
6f54afb094bd
dirstate: align the dirstate's API to the lower level ones
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48106
diff
changeset
|
600 ) |
22095
cb62d77c7a01
largefiles: factor out synchronization of lfdirstate for future use
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21917
diff
changeset
|
601 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
602 |
23184
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23039
diff
changeset
|
603 def markcommitted(orig, ctx, node): |
24336
c9f4ef967a1d
largefiles: replace 'ctx._repo' with 'ctx.repo()'
Matt Harbison <matt_harbison@yahoo.com>
parents:
24158
diff
changeset
|
604 repo = ctx.repo() |
23184
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23039
diff
changeset
|
605 |
50050
22cd517bc6b0
largefiles: rely on main scoping for writing dirstate in `markcommitted`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50027
diff
changeset
|
606 with repo.dirstate.changing_parents(repo): |
47647
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
607 orig(node) |
23184
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23039
diff
changeset
|
608 |
47647
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
609 # ATTENTION: "ctx.files()" may differ from "repo[node].files()" |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
610 # because files coming from the 2nd parent are omitted in the latter. |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
611 # |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
612 # The former should be used to get targets of "synclfdirstate", |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
613 # because such files: |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
614 # - are marked as "a" by "patch.patch()" (e.g. via transplant), and |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
615 # - have to be marked as "n" after commit, but |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
616 # - aren't listed in "repo[node].files()" |
23273
236c978bceca
largefiles: avoid redundant "updatelfiles" invocation in "overridetransplant"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23188
diff
changeset
|
617 |
50050
22cd517bc6b0
largefiles: rely on main scoping for writing dirstate in `markcommitted`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50027
diff
changeset
|
618 lfdirstate = openlfdirstate(repo.ui, repo) |
47647
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
619 for f in ctx.files(): |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
620 lfile = splitstandin(f) |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
621 if lfile is not None: |
f16958beb27b
largefile: synchronise the dirstate within a `parentchange` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47599
diff
changeset
|
622 synclfdirstate(repo, lfdirstate, lfile, False) |
23184
3100d1cbce32
largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23039
diff
changeset
|
623 |
23276
4be754832829
largefiles: move "copyalltostore" invocation into "markcommitted"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23274
diff
changeset
|
624 # As part of committing, copy all of the largefiles into the cache. |
31616
10561eb97c7f
largefiles: call readstandin() with changectx itself instead of rev or node
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31615
diff
changeset
|
625 # |
10561eb97c7f
largefiles: call readstandin() with changectx itself instead of rev or node
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31615
diff
changeset
|
626 # Using "node" instead of "ctx" implies additional "repo[node]" |
10561eb97c7f
largefiles: call readstandin() with changectx itself instead of rev or node
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31615
diff
changeset
|
627 # lookup while copyalltostore(), but can omit redundant check for |
10561eb97c7f
largefiles: call readstandin() with changectx itself instead of rev or node
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31615
diff
changeset
|
628 # files comming from the 2nd parent, which should exist in store |
10561eb97c7f
largefiles: call readstandin() with changectx itself instead of rev or node
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31615
diff
changeset
|
629 # at merging. |
23276
4be754832829
largefiles: move "copyalltostore" invocation into "markcommitted"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23274
diff
changeset
|
630 copyalltostore(repo, node) |
4be754832829
largefiles: move "copyalltostore" invocation into "markcommitted"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23274
diff
changeset
|
631 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
632 |
16245
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
633 def getlfilestoupdate(oldstandins, newstandins): |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
634 changedstandins = set(oldstandins).symmetric_difference(set(newstandins)) |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
635 filelist = [] |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
636 for f in changedstandins: |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
637 if f[0] not in filelist: |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
638 filelist.append(f[0]) |
a18ad914aa21
largefiles: move calculation of largefiles for updating to utility function
Na'Tosha Bard <natosha@unity3d.com>
parents:
16166
diff
changeset
|
639 return filelist |
21042
32b3331f18eb
largefiles: centralize the logic to get outgoing largefiles
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19089
diff
changeset
|
640 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
641 |
21042
32b3331f18eb
largefiles: centralize the logic to get outgoing largefiles
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19089
diff
changeset
|
642 def getlfilestoupload(repo, missing, addfunc): |
39390
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
643 makeprogress = repo.ui.makeprogress |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
644 with makeprogress( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
645 _(b'finding outgoing largefiles'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
646 unit=_(b'revisions'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
647 total=len(missing), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
648 ) as progress: |
39390
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
649 for i, n in enumerate(missing): |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
650 progress.update(i) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46895
diff
changeset
|
651 parents = [p for p in repo[n].parents() if p != repo.nullid] |
23657
95f238cafb32
largefiles: ensure that the standin files are available in getlfilestoupload()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23543
diff
changeset
|
652 |
43584
a02e4c12ae60
largefiles: allow "lfstatus" context manager to set value to False
Martin von Zweigbergk <martinvonz@google.com>
parents:
43583
diff
changeset
|
653 with lfstatus(repo, value=False): |
39390
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
654 ctx = repo[n] |
23657
95f238cafb32
largefiles: ensure that the standin files are available in getlfilestoupload()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23543
diff
changeset
|
655 |
39390
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
656 files = set(ctx.files()) |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
657 if len(parents) == 2: |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
658 mc = ctx.manifest() |
41397
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
39390
diff
changeset
|
659 mp1 = ctx.p1().manifest() |
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
39390
diff
changeset
|
660 mp2 = ctx.p2().manifest() |
39390
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
661 for f in mp1: |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
662 if f not in mc: |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
663 files.add(f) |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
664 for f in mp2: |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
665 if f not in mc: |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
666 files.add(f) |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
667 for f in mc: |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
668 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None): |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
669 files.add(f) |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
670 for fn in files: |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
671 if isstandin(fn) and fn in ctx: |
a65ad9b22a00
largefiles: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
38407
diff
changeset
|
672 addfunc(fn, readasstandin(ctx[fn])) |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
673 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
674 |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
675 def updatestandinsbymatch(repo, match): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
676 """Update standins in the working directory according to specified match |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
677 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
678 This returns (possibly modified) ``match`` object to be used for |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
679 subsequent commit process. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
680 """ |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
681 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
682 ui = repo.ui |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
683 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
684 # Case 1: user calls commit with no specific files or |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
685 # include/exclude patterns: refresh and commit all files that |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
686 # are "dirty". |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
687 if match is None or match.always(): |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
688 # Spend a bit of time here to get a list of files we know |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
689 # are modified so we can compare only against those. |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
690 # It can cost a lot of time (several seconds) |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
691 # otherwise to update all standins if the largefiles are |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
692 # large. |
41676
0531dff73d0b
match: delete unused root and cwd arguments from {always,never,exact}() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41397
diff
changeset
|
693 dirtymatch = matchmod.always() |
50137
302772099ac4
large-files: use `running_status` in `updatestandinsbymatch`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50123
diff
changeset
|
694 with repo.dirstate.running_status(repo): |
302772099ac4
large-files: use `running_status` in `updatestandinsbymatch`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50123
diff
changeset
|
695 lfdirstate = openlfdirstate(ui, repo) |
302772099ac4
large-files: use `running_status` in `updatestandinsbymatch`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50123
diff
changeset
|
696 unsure, s, mtime_boundary = lfdirstate.status( |
302772099ac4
large-files: use `running_status` in `updatestandinsbymatch`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50123
diff
changeset
|
697 dirtymatch, |
302772099ac4
large-files: use `running_status` in `updatestandinsbymatch`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50123
diff
changeset
|
698 subrepos=[], |
302772099ac4
large-files: use `running_status` in `updatestandinsbymatch`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50123
diff
changeset
|
699 ignored=False, |
302772099ac4
large-files: use `running_status` in `updatestandinsbymatch`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50123
diff
changeset
|
700 clean=False, |
302772099ac4
large-files: use `running_status` in `updatestandinsbymatch`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50123
diff
changeset
|
701 unknown=False, |
302772099ac4
large-files: use `running_status` in `updatestandinsbymatch`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50123
diff
changeset
|
702 ) |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
703 modifiedfiles = unsure + s.modified + s.added + s.removed |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
704 lfiles = listlfiles(repo) |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
705 # this only loops through largefiles that exist (not |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
706 # removed/renamed) |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
707 for lfile in lfiles: |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
708 if lfile in modifiedfiles: |
31618
8228bc8fed8c
largefiles: avoid redundant standin() invocations
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31617
diff
changeset
|
709 fstandin = standin(lfile) |
8228bc8fed8c
largefiles: avoid redundant standin() invocations
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31617
diff
changeset
|
710 if repo.wvfs.exists(fstandin): |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
711 # this handles the case where a rebase is being |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
712 # performed and the working copy is not updated |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
713 # yet. |
28560
bfbd3f02b442
largefiles: replace invocation of os.path module by vfs in lfutil.py
liscju <piotr.listkiewicz@gmail.com>
parents:
28464
diff
changeset
|
714 if repo.wvfs.exists(lfile): |
31659
0eec36112e58
largefiles: add lfile argument to updatestandin() for efficiency (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31657
diff
changeset
|
715 updatestandin(repo, lfile, fstandin) |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
716 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
717 return match |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
718 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
719 lfiles = listlfiles(repo) |
51624
e32f23f15623
largefiles: mark more matchers as having been tampered with
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50928
diff
changeset
|
720 match._was_tampered_with = True |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
721 match._files = repo._subdirlfs(match.files(), lfiles) |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
722 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
723 # Case 2: user calls commit with specified patterns: refresh |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
724 # any matching big files. |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
725 smatcher = composestandinmatcher(repo, match) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
726 standins = repo.dirstate.walk( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
727 smatcher, subrepos=[], unknown=False, ignored=False |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
728 ) |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
729 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
730 # No matching big files: get out of the way and pass control to |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
731 # the usual commit() method. |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
732 if not standins: |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
733 return match |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
734 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
735 # Refresh all matching big files. It's possible that the |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
736 # commit will end up failing, in which case the big files will |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
737 # stay refreshed. No harm done: the user modified them and |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
738 # asked to commit them, so sooner or later we're going to |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
739 # refresh the standins. Might as well leave them refreshed. |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
740 lfdirstate = openlfdirstate(ui, repo) |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
741 for fstandin in standins: |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
742 lfile = splitstandin(fstandin) |
48106
82e142b9ad18
dirstate-item: use item's property instead of `state` in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47755
diff
changeset
|
743 if lfdirstate.get_entry(lfile).tracked: |
31659
0eec36112e58
largefiles: add lfile argument to updatestandin() for efficiency (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31657
diff
changeset
|
744 updatestandin(repo, lfile, fstandin) |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
745 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
746 # Cook up a new matcher that only matches regular files or |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
747 # standins corresponding to the big files requested by the |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
748 # user. Have to modify _files to prevent commit() from |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
749 # complaining "not tracked" for big files. |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
750 match = copy.copy(match) |
51624
e32f23f15623
largefiles: mark more matchers as having been tampered with
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
50928
diff
changeset
|
751 match._was_tampered_with = True |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
752 origmatchfn = match.matchfn |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
753 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
754 # Check both the list of largefiles and the list of |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
755 # standins because if a largefile was removed, it |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
756 # won't be in the list of largefiles at this point |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
757 match._files += sorted(standins) |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
758 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
759 actualfiles = [] |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
760 for f in match._files: |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
761 fstandin = standin(f) |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
762 |
26817
b68797f244e4
largefiles: fix explicit commit of normal/largefile switch
Mads Kiilerich <madski@unity3d.com>
parents:
26749
diff
changeset
|
763 # For largefiles, only one of the normal and standin should be |
27942
eb1135d5e688
largefiles: fix an explicit largefile commit after a remove (issue4969)
Matt Harbison <matt_harbison@yahoo.com>
parents:
27903
diff
changeset
|
764 # committed (except if one of them is a remove). In the case of a |
eb1135d5e688
largefiles: fix an explicit largefile commit after a remove (issue4969)
Matt Harbison <matt_harbison@yahoo.com>
parents:
27903
diff
changeset
|
765 # standin removal, drop the normal file if it is unknown to dirstate. |
26817
b68797f244e4
largefiles: fix explicit commit of normal/largefile switch
Mads Kiilerich <madski@unity3d.com>
parents:
26749
diff
changeset
|
766 # Thus, skip plain largefile names but keep the standin. |
27942
eb1135d5e688
largefiles: fix an explicit largefile commit after a remove (issue4969)
Matt Harbison <matt_harbison@yahoo.com>
parents:
27903
diff
changeset
|
767 if f in lfiles or fstandin in standins: |
48106
82e142b9ad18
dirstate-item: use item's property instead of `state` in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47755
diff
changeset
|
768 if not repo.dirstate.get_entry(fstandin).removed: |
82e142b9ad18
dirstate-item: use item's property instead of `state` in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47755
diff
changeset
|
769 if not repo.dirstate.get_entry(f).removed: |
27942
eb1135d5e688
largefiles: fix an explicit largefile commit after a remove (issue4969)
Matt Harbison <matt_harbison@yahoo.com>
parents:
27903
diff
changeset
|
770 continue |
48106
82e142b9ad18
dirstate-item: use item's property instead of `state` in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47755
diff
changeset
|
771 elif not repo.dirstate.get_entry(f).any_tracked: |
27942
eb1135d5e688
largefiles: fix an explicit largefile commit after a remove (issue4969)
Matt Harbison <matt_harbison@yahoo.com>
parents:
27903
diff
changeset
|
772 continue |
23185
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
773 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
774 actualfiles.append(f) |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
775 match._files = actualfiles |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
776 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
777 def matchfn(f): |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
778 if origmatchfn(f): |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
779 return f not in lfiles |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
780 else: |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
781 return f in standins |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
782 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
783 match.matchfn = matchfn |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
784 |
9870173e0b48
largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23184
diff
changeset
|
785 return match |
23187
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
786 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
787 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
788 class automatedcommithook: |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
789 """Stateful hook to update standins at the 1st commit of resuming |
23187
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
790 |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
791 For efficiency, updating standins in the working directory should |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
792 be avoided while automated committing (like rebase, transplant and |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
793 so on), because they should be updated before committing. |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
794 |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
795 But the 1st commit of resuming automated committing (e.g. ``rebase |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
796 --continue``) should update them, because largefiles may be |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
797 modified manually. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
798 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
799 |
23187
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
800 def __init__(self, resuming): |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
801 self.resuming = resuming |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
802 |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
803 def __call__(self, repo, match): |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
804 if self.resuming: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
805 self.resuming = False # avoids updating at subsequent commits |
23187
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
806 return updatestandinsbymatch(repo, match) |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
807 else: |
f726b05ecfe6
largefiles: update standins only at the 1st commit of "hg rebase --continue"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23185
diff
changeset
|
808 return match |
23188
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
809 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
810 |
23188
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
811 def getstatuswriter(ui, repo, forcibly=None): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
812 """Return the function to write largefiles specific status out |
23188
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
813 |
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
814 If ``forcibly`` is ``None``, this returns the last element of |
23543
4dd8a6a1240d
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23276
diff
changeset
|
815 ``repo._lfstatuswriters`` as "default" writer function. |
23188
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
816 |
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
817 Otherwise, this returns the function to always write out (or |
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
818 ignore if ``not forcibly``) status. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
44379
diff
changeset
|
819 """ |
50928
d718eddf01d9
safehasattr: drop usage in favor of hasattr
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50889
diff
changeset
|
820 if forcibly is None and hasattr(repo, '_largefilesenabled'): |
23188
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
821 return repo._lfstatuswriters[-1] |
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
822 else: |
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
823 if forcibly: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
824 return ui.status # forcibly WRITE OUT |
23188
94ac64bcf6fe
largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23187
diff
changeset
|
825 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41759
diff
changeset
|
826 return lambda *msg, **opts: None # forcibly IGNORE |