Mercurial > hg
annotate hgext/lfs/wrapper.py @ 43138:f9dc98a97cdb
sidedatacopies: teach upgrade about the new requirement
The `debugformat` and `debugupgraderepo` command now detect the requirement.
(upgrade to and from are not currently possible).
Differential Revision: https://phab.mercurial-scm.org/D6946
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 06 Oct 2019 23:36:51 -0400 |
parents | 649d3ac37a12 |
children | 26cf356ae772 |
rev | line source |
---|---|
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
1 # wrapper.py - methods wrapping core mercurial logic |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
2 # |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
3 # Copyright 2017 Facebook, Inc. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
4 # |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
7 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
8 from __future__ import absolute_import |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
9 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
10 import hashlib |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
11 |
35099
b8e5fb8d2389
lfs: quiesce check-module-import warnings
Matt Harbison <matt_harbison@yahoo.com>
parents:
35098
diff
changeset
|
12 from mercurial.i18n import _ |
36604
f6b9f9ddd0de
lfs: convert hexdigest to bytes using sysbytes
Augie Fackler <augie@google.com>
parents:
36603
diff
changeset
|
13 from mercurial.node import bin, hex, nullid, short |
43089
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43087
diff
changeset
|
14 from mercurial.pycompat import ( |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43087
diff
changeset
|
15 getattr, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43087
diff
changeset
|
16 setattr, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43087
diff
changeset
|
17 ) |
35099
b8e5fb8d2389
lfs: quiesce check-module-import warnings
Matt Harbison <matt_harbison@yahoo.com>
parents:
35098
diff
changeset
|
18 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
19 from mercurial import ( |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
20 bundle2, |
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
21 changegroup, |
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
22 cmdutil, |
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
23 context, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
24 error, |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
25 exchange, |
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
26 exthelper, |
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
27 localrepo, |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
28 pycompat, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
29 revlog, |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
30 scmutil, |
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
31 upgrade, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
32 util, |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
33 vfs as vfsmod, |
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
34 wireprotov1server, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
35 ) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
36 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
37 from mercurial.interfaces import repository |
42813
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42775
diff
changeset
|
38 |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36604
diff
changeset
|
39 from mercurial.utils import ( |
39878
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39856
diff
changeset
|
40 storageutil, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36604
diff
changeset
|
41 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36604
diff
changeset
|
42 ) |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36604
diff
changeset
|
43 |
35363
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
44 from ..largefiles import lfutil |
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
45 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
46 from . import ( |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
47 blobstore, |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
48 pointer, |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
49 ) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
50 |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
51 eh = exthelper.exthelper() |
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
52 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
53 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
54 @eh.wrapfunction(localrepo, b'makefilestorage') |
39851
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39849
diff
changeset
|
55 def localrepomakefilestorage(orig, requirements, features, **kwargs): |
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39849
diff
changeset
|
56 if b'lfs' in requirements: |
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39849
diff
changeset
|
57 features.add(repository.REPO_FEATURE_LFS) |
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39849
diff
changeset
|
58 |
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39849
diff
changeset
|
59 return orig(requirements=requirements, features=features, **kwargs) |
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39849
diff
changeset
|
60 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
61 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
62 @eh.wrapfunction(changegroup, b'allsupportedversions') |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
63 def allsupportedversions(orig, ui): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
64 versions = orig(ui) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
65 versions.add(b'03') |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
66 return versions |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
67 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
68 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
69 @eh.wrapfunction(wireprotov1server, b'_capabilities') |
35506
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
70 def _capabilities(orig, repo, proto): |
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
71 '''Wrap server command to announce lfs server capability''' |
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
72 caps = orig(repo, proto) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
73 if util.safehasattr(repo.svfs, b'lfslocalblobstore'): |
40324
6637b079ae45
lfs: autoload the extension when cloning from repo with lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
39949
diff
changeset
|
74 # Advertise a slightly different capability when lfs is *required*, so |
6637b079ae45
lfs: autoload the extension when cloning from repo with lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
39949
diff
changeset
|
75 # that the client knows it MUST load the extension. If lfs is not |
6637b079ae45
lfs: autoload the extension when cloning from repo with lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
39949
diff
changeset
|
76 # required on the server, there's no reason to autoload the extension |
6637b079ae45
lfs: autoload the extension when cloning from repo with lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
39949
diff
changeset
|
77 # on the client. |
6637b079ae45
lfs: autoload the extension when cloning from repo with lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
39949
diff
changeset
|
78 if b'lfs' in repo.requirements: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
79 caps.append(b'lfs-serve') |
40324
6637b079ae45
lfs: autoload the extension when cloning from repo with lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
39949
diff
changeset
|
80 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
81 caps.append(b'lfs') |
35506
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
82 return caps |
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
83 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
84 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
85 def bypasscheckhash(self, text): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
86 return False |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
87 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
88 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
89 def readfromstore(self, text): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
90 """Read filelog content from local blobstore transform for flagprocessor. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
91 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
92 Default tranform for flagprocessor, returning contents from blobstore. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
93 Returns a 2-typle (text, validatehash) where validatehash is True as the |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
94 contents of the blobstore should be checked using checkhash. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
95 """ |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
96 p = pointer.deserialize(text) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
97 oid = p.oid() |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
98 store = self.opener.lfslocalblobstore |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
99 if not store.has(oid): |
35568
ebf14075a5c1
lfs: improve the error message for a missing remote blob
Matt Harbison <matt_harbison@yahoo.com>
parents:
35553
diff
changeset
|
100 p.filename = self.filename |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
101 self.opener.lfsremoteblobstore.readbatch([p], store) |
35476
417e8e040102
lfs: verify lfs object content when transferring to and from the remote store
Matt Harbison <matt_harbison@yahoo.com>
parents:
35473
diff
changeset
|
102 |
417e8e040102
lfs: verify lfs object content when transferring to and from the remote store
Matt Harbison <matt_harbison@yahoo.com>
parents:
35473
diff
changeset
|
103 # The caller will validate the content |
417e8e040102
lfs: verify lfs object content when transferring to and from the remote store
Matt Harbison <matt_harbison@yahoo.com>
parents:
35473
diff
changeset
|
104 text = store.read(oid, verify=False) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
105 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
106 # pack hg filelog metadata |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
107 hgmeta = {} |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
108 for k in p.keys(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
109 if k.startswith(b'x-hg-'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
110 name = k[len(b'x-hg-') :] |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
111 hgmeta[name] = p[k] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
112 if hgmeta or text.startswith(b'\1\n'): |
39878
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39856
diff
changeset
|
113 text = storageutil.packmeta(hgmeta, text) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
114 |
42985
bd5858c28bbe
flagprocessors: have the read transform function return side data (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42813
diff
changeset
|
115 return (text, True, {}) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
116 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
117 |
42988
f4caf910669e
flagprocessors: writetransform function take side data as parameter (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42985
diff
changeset
|
118 def writetostore(self, text, sidedata): |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
119 # hg filelog metadata (includes rename, etc) |
39878
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39856
diff
changeset
|
120 hgmeta, offset = storageutil.parsemeta(text) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
121 if offset and offset > 0: |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
122 # lfs blob does not contain hg filelog metadata |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
123 text = text[offset:] |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
124 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
125 # git-lfs only supports sha256 |
36604
f6b9f9ddd0de
lfs: convert hexdigest to bytes using sysbytes
Augie Fackler <augie@google.com>
parents:
36603
diff
changeset
|
126 oid = hex(hashlib.sha256(text).digest()) |
35553
a77418095530
lfs: remove the verification option when writing to the local store
Matt Harbison <matt_harbison@yahoo.com>
parents:
35506
diff
changeset
|
127 self.opener.lfslocalblobstore.write(oid, text) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
128 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
129 # replace contents with metadata |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
130 longoid = b'sha256:%s' % oid |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
131 metadata = pointer.gitlfspointer(oid=longoid, size=b'%d' % len(text)) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
132 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
133 # by default, we expect the content to be binary. however, LFS could also |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
134 # be used for non-binary content. add a special entry for non-binary data. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
135 # this will be used by filectx.isbinary(). |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36604
diff
changeset
|
136 if not stringutil.binary(text): |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
137 # not hg filelog metadata (affecting commit hash), no "x-hg-" prefix |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
138 metadata[b'x-is-binary'] = b'0' |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
139 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
140 # translate hg filelog metadata to lfs metadata with "x-hg-" prefix |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
141 if hgmeta is not None: |
43105
649d3ac37a12
py3: define and use pycompat.iteritems() for hgext/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
142 for k, v in pycompat.iteritems(hgmeta): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
143 metadata[b'x-hg-%s' % k] = v |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
144 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
145 rawtext = metadata.serialize() |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
146 return (rawtext, False) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
147 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
148 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
149 def _islfs(rlog, node=None, rev=None): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
150 if rev is None: |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
151 if node is None: |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
152 # both None - likely working copy content where node is not ready |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
153 return False |
39855
62a532045e71
lfs: access revlog directly
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39853
diff
changeset
|
154 rev = rlog._revlog.rev(node) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
155 else: |
39855
62a532045e71
lfs: access revlog directly
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39853
diff
changeset
|
156 node = rlog._revlog.node(rev) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
157 if node == nullid: |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
158 return False |
39855
62a532045e71
lfs: access revlog directly
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39853
diff
changeset
|
159 flags = rlog._revlog.flags(rev) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
160 return bool(flags & revlog.REVIDX_EXTSTORED) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
161 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
162 |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
163 # Wrapping may also be applied by remotefilelog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
164 def filelogaddrevision( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
165 orig, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
166 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
167 text, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
168 transaction, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
169 link, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
170 p1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
171 p2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
172 cachedelta=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
173 node=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
174 flags=revlog.REVIDX_DEFAULT_FLAGS, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
175 **kwds |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
176 ): |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
177 # The matcher isn't available if reposetup() wasn't called. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
178 lfstrack = self._revlog.opener.options.get(b'lfstrack') |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
179 |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
180 if lfstrack: |
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
181 textlen = len(text) |
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
182 # exclude hg rename meta from file size |
39878
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39856
diff
changeset
|
183 meta, offset = storageutil.parsemeta(text) |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
184 if offset: |
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
185 textlen -= offset |
35648
588d02d9208a
lfs: always exclude '.hg*' text files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35624
diff
changeset
|
186 |
39856
96838b620b9c
filelog: store filename directly on revlog instance
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39855
diff
changeset
|
187 if lfstrack(self._revlog.filename, textlen): |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
188 flags |= revlog.REVIDX_EXTSTORED |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
189 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
190 return orig( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
191 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
192 text, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
193 transaction, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
194 link, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
195 p1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
196 p2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
197 cachedelta=cachedelta, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
198 node=node, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
199 flags=flags, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
200 **kwds |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
201 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
202 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
203 |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
204 # Wrapping may also be applied by remotefilelog |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
205 def filelogrenamed(orig, self, node): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
206 if _islfs(self, node): |
42775
f972f43badb3
rawdata: update callers in lfs' wrapper
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41279
diff
changeset
|
207 rawtext = self._revlog.rawdata(node) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
208 if not rawtext: |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
209 return False |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
210 metadata = pointer.deserialize(rawtext) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
211 if b'x-hg-copy' in metadata and b'x-hg-copyrev' in metadata: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
212 return metadata[b'x-hg-copy'], bin(metadata[b'x-hg-copyrev']) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
213 else: |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
214 return False |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
215 return orig(self, node) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
216 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
217 |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
218 # Wrapping may also be applied by remotefilelog |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
219 def filelogsize(orig, self, rev): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
220 if _islfs(self, rev=rev): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
221 # fast path: use lfs metadata to answer size |
42775
f972f43badb3
rawdata: update callers in lfs' wrapper
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41279
diff
changeset
|
222 rawtext = self._revlog.rawdata(rev) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
223 metadata = pointer.deserialize(rawtext) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
224 return int(metadata[b'size']) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
225 return orig(self, rev) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
226 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
227 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
228 @eh.wrapfunction(context.basefilectx, b'cmp') |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
229 def filectxcmp(orig, self, fctx): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
230 """returns True if text is different than fctx""" |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
231 # some fctx (ex. hg-git) is not based on basefilectx and do not have islfs |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
232 if self.islfs() and getattr(fctx, 'islfs', lambda: False)(): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
233 # fast path: check LFS oid |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
234 p1 = pointer.deserialize(self.rawdata()) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
235 p2 = pointer.deserialize(fctx.rawdata()) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
236 return p1.oid() != p2.oid() |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
237 return orig(self, fctx) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
238 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
239 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
240 @eh.wrapfunction(context.basefilectx, b'isbinary') |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
241 def filectxisbinary(orig, self): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
242 if self.islfs(): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
243 # fast path: use lfs metadata to answer isbinary |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
244 metadata = pointer.deserialize(self.rawdata()) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
245 # if lfs metadata says nothing, assume it's binary by default |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
246 return bool(int(metadata.get(b'x-is-binary', 1))) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
247 return orig(self) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
248 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
249 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
250 def filectxislfs(self): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
251 return _islfs(self.filelog(), self.filenode()) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
252 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
253 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
254 @eh.wrapfunction(cmdutil, b'_updatecatformatter') |
35663
a985834961f7
lfs: allow the pointer file to be viewed with `hg cat -T '{rawdata}'`
Matt Harbison <matt_harbison@yahoo.com>
parents:
35648
diff
changeset
|
255 def _updatecatformatter(orig, fm, ctx, matcher, path, decode): |
a985834961f7
lfs: allow the pointer file to be viewed with `hg cat -T '{rawdata}'`
Matt Harbison <matt_harbison@yahoo.com>
parents:
35648
diff
changeset
|
256 orig(fm, ctx, matcher, path, decode) |
a985834961f7
lfs: allow the pointer file to be viewed with `hg cat -T '{rawdata}'`
Matt Harbison <matt_harbison@yahoo.com>
parents:
35648
diff
changeset
|
257 fm.data(rawdata=ctx[path].rawdata()) |
a985834961f7
lfs: allow the pointer file to be viewed with `hg cat -T '{rawdata}'`
Matt Harbison <matt_harbison@yahoo.com>
parents:
35648
diff
changeset
|
258 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
259 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
260 @eh.wrapfunction(scmutil, b'wrapconvertsink') |
35178
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
261 def convertsink(orig, sink): |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
262 sink = orig(sink) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
263 if sink.repotype == b'hg': |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
264 |
35178
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
265 class lfssink(sink.__class__): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
266 def putcommit( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
267 self, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
268 files, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
269 copies, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
270 parents, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
271 commit, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
272 source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
273 revmap, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
274 full, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
275 cleanp2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
276 ): |
35178
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
277 pc = super(lfssink, self).putcommit |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
278 node = pc( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
279 files, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
280 copies, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
281 parents, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
282 commit, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
283 source, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
284 revmap, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
285 full, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
286 cleanp2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
287 ) |
35178
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
288 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
289 if b'lfs' not in self.repo.requirements: |
35178
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
290 ctx = self.repo[node] |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
291 |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
292 # The file list may contain removed files, so check for |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
293 # membership before assuming it is in the context. |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
294 if any(f in ctx and ctx[f].islfs() for f, n in files): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
295 self.repo.requirements.add(b'lfs') |
35178
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
296 self.repo._writerequirements() |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
297 |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
298 return node |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
299 |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
300 sink.__class__ = lfssink |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
301 |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
302 return sink |
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
303 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
304 |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
305 # bundlerepo uses "vfsmod.readonlyvfs(othervfs)", we need to make sure lfs |
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
306 # options and blob stores are passed from othervfs to the new readonlyvfs. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
307 @eh.wrapfunction(vfsmod.readonlyvfs, b'__init__') |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
308 def vfsinit(orig, self, othervfs): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
309 orig(self, othervfs) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
310 # copy lfs related options |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
311 for k, v in othervfs.options.items(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
312 if k.startswith(b'lfs'): |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
313 self.options[k] = v |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
314 # also copy lfs blobstores. note: this can run before reposetup, so lfs |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
315 # blobstore attributes are not always ready at this time. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
316 for name in [b'lfslocalblobstore', b'lfsremoteblobstore']: |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
317 if util.safehasattr(othervfs, name): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
318 setattr(self, name, getattr(othervfs, name)) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
319 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
320 |
37762
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
321 def _prefetchfiles(repo, revs, match): |
35922
0b79f99fd7b0
lfs: prefetch lfs blobs when applying merge updates
Matt Harbison <matt_harbison@yahoo.com>
parents:
35921
diff
changeset
|
322 """Ensure that required LFS blobs are present, fetching them as a group if |
36142
60dd840a7fdb
merge: invoke scmutil.fileprefetchhooks() prior to applying updates
Matt Harbison <matt_harbison@yahoo.com>
parents:
36138
diff
changeset
|
323 needed.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
324 if not util.safehasattr(repo.svfs, b'lfslocalblobstore'): |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
325 return |
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
326 |
35922
0b79f99fd7b0
lfs: prefetch lfs blobs when applying merge updates
Matt Harbison <matt_harbison@yahoo.com>
parents:
35921
diff
changeset
|
327 pointers = [] |
37762
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
328 oids = set() |
35922
0b79f99fd7b0
lfs: prefetch lfs blobs when applying merge updates
Matt Harbison <matt_harbison@yahoo.com>
parents:
35921
diff
changeset
|
329 localstore = repo.svfs.lfslocalblobstore |
0b79f99fd7b0
lfs: prefetch lfs blobs when applying merge updates
Matt Harbison <matt_harbison@yahoo.com>
parents:
35921
diff
changeset
|
330 |
37762
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
331 for rev in revs: |
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
332 ctx = repo[rev] |
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
333 for f in ctx.walk(match): |
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
334 p = pointerfromctx(ctx, f) |
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
335 if p and p.oid() not in oids and not localstore.has(p.oid()): |
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
336 p.filename = f |
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
337 pointers.append(p) |
7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
Matt Harbison <matt_harbison@yahoo.com>
parents:
37564
diff
changeset
|
338 oids.add(p.oid()) |
35922
0b79f99fd7b0
lfs: prefetch lfs blobs when applying merge updates
Matt Harbison <matt_harbison@yahoo.com>
parents:
35921
diff
changeset
|
339 |
0b79f99fd7b0
lfs: prefetch lfs blobs when applying merge updates
Matt Harbison <matt_harbison@yahoo.com>
parents:
35921
diff
changeset
|
340 if pointers: |
37518
092eff6833a7
lfs: infer the blob store URL from paths.default
Matt Harbison <matt_harbison@yahoo.com>
parents:
37442
diff
changeset
|
341 # Recalculating the repo store here allows 'paths.default' that is set |
092eff6833a7
lfs: infer the blob store URL from paths.default
Matt Harbison <matt_harbison@yahoo.com>
parents:
37442
diff
changeset
|
342 # on the repo by a clone command to be used for the update. |
092eff6833a7
lfs: infer the blob store URL from paths.default
Matt Harbison <matt_harbison@yahoo.com>
parents:
37442
diff
changeset
|
343 blobstore.remote(repo).readbatch(pointers, localstore) |
35922
0b79f99fd7b0
lfs: prefetch lfs blobs when applying merge updates
Matt Harbison <matt_harbison@yahoo.com>
parents:
35921
diff
changeset
|
344 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
345 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
346 def _canskipupload(repo): |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
347 # Skip if this hasn't been passed to reposetup() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
348 if not util.safehasattr(repo.svfs, b'lfsremoteblobstore'): |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
349 return True |
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
350 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
351 # if remotestore is a null store, upload is a no-op and can be skipped |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
352 return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
353 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
354 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
355 def candownload(repo): |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
356 # Skip if this hasn't been passed to reposetup() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
357 if not util.safehasattr(repo.svfs, b'lfsremoteblobstore'): |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
358 return False |
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
359 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
360 # if remotestore is a null store, downloads will lead to nothing |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
361 return not isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
362 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
363 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
364 def uploadblobsfromrevs(repo, revs): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
365 '''upload lfs blobs introduced by revs |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
366 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
367 Note: also used by other extensions e. g. infinitepush. avoid renaming. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
368 ''' |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
369 if _canskipupload(repo): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
370 return |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
371 pointers = extractpointers(repo, revs) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
372 uploadblobs(repo, pointers) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
373 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
374 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
375 def prepush(pushop): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
376 """Prepush hook. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
377 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
378 Read through the revisions to push, looking for filelog entries that can be |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
379 deserialized into metadata so that we can block the push on their upload to |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
380 the remote blobstore. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
381 """ |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
382 return uploadblobsfromrevs(pushop.repo, pushop.outgoing.missing) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
383 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
384 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
385 @eh.wrapfunction(exchange, b'push') |
35506
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
386 def push(orig, repo, remote, *args, **kwargs): |
37564
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
387 """bail on push if the extension isn't enabled on remote when needed, and |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
388 update the remote store based on the destination path.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
389 if b'lfs' in repo.requirements: |
35506
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
390 # If the remote peer is for a local repo, the requirement tests in the |
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
391 # base class method enforce lfs support. Otherwise, some revisions in |
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
392 # this repo use lfs, and the remote repo needs the extension loaded. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
393 if not remote.local() and not remote.capable(b'lfs'): |
35506
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
394 # This is a copy of the message in exchange.push() when requirements |
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
395 # are missing between local repos. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
396 m = _(b"required features are not supported in the destination: %s") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
397 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
398 m % b'lfs', hint=_(b'enable the lfs extension on the server') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
399 ) |
37564
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
400 |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
401 # Repositories where this extension is disabled won't have the field. |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
402 # But if there's a requirement, then the extension must be loaded AND |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
403 # there may be blobs to push. |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
404 remotestore = repo.svfs.lfsremoteblobstore |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
405 try: |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
406 repo.svfs.lfsremoteblobstore = blobstore.remote(repo, remote.url()) |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
407 return orig(repo, remote, *args, **kwargs) |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
408 finally: |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
409 repo.svfs.lfsremoteblobstore = remotestore |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
410 else: |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
411 return orig(repo, remote, *args, **kwargs) |
35506
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35505
diff
changeset
|
412 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
413 |
41048
84d61fdcefa5
lfs: convert to using exthelper to wrap functions
Matt Harbison <matt_harbison@yahoo.com>
parents:
40386
diff
changeset
|
414 # when writing a bundle via "hg bundle" command, upload related LFS blobs |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 @eh.wrapfunction(bundle2, b'writenewbundle') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
416 def writenewbundle( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
417 orig, ui, repo, source, filename, bundletype, outgoing, *args, **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
418 ): |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
419 """upload LFS blobs added by outgoing revisions on 'hg bundle'""" |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
420 uploadblobsfromrevs(repo, outgoing.missing) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
421 return orig( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
422 ui, repo, source, filename, bundletype, outgoing, *args, **kwargs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
423 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
424 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
425 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
426 def extractpointers(repo, revs): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
427 """return a list of lfs pointers added by given revs""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
428 repo.ui.debug(b'lfs: computing set of blobs to upload\n') |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
429 pointers = {} |
39270
37e56607cbb9
lfs: add a progress bar when searching for blobs to upload
Matt Harbison <matt_harbison@yahoo.com>
parents:
38178
diff
changeset
|
430 |
39389
b26350d9d7b5
lfs: use a context manager to control the progress bar lifetime
Matt Harbison <matt_harbison@yahoo.com>
parents:
39270
diff
changeset
|
431 makeprogress = repo.ui.makeprogress |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
432 with makeprogress( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
433 _(b'lfs search'), _(b'changesets'), len(revs) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
434 ) as progress: |
39270
37e56607cbb9
lfs: add a progress bar when searching for blobs to upload
Matt Harbison <matt_harbison@yahoo.com>
parents:
38178
diff
changeset
|
435 for r in revs: |
37e56607cbb9
lfs: add a progress bar when searching for blobs to upload
Matt Harbison <matt_harbison@yahoo.com>
parents:
38178
diff
changeset
|
436 ctx = repo[r] |
37e56607cbb9
lfs: add a progress bar when searching for blobs to upload
Matt Harbison <matt_harbison@yahoo.com>
parents:
38178
diff
changeset
|
437 for p in pointersfromctx(ctx).values(): |
37e56607cbb9
lfs: add a progress bar when searching for blobs to upload
Matt Harbison <matt_harbison@yahoo.com>
parents:
38178
diff
changeset
|
438 pointers[p.oid()] = p |
37e56607cbb9
lfs: add a progress bar when searching for blobs to upload
Matt Harbison <matt_harbison@yahoo.com>
parents:
38178
diff
changeset
|
439 progress.increment() |
39949
e1f97179a3f5
lfs: explicitly name a key when sorting blob pointers
Matt Harbison <matt_harbison@yahoo.com>
parents:
39878
diff
changeset
|
440 return sorted(pointers.values(), key=lambda p: p.oid()) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
441 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
442 |
35998
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
443 def pointerfromctx(ctx, f, removed=False): |
35921
47e737d27e01
lfs: factor out a method for extracting the pointer of a single file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35799
diff
changeset
|
444 """return a pointer for the named file from the given changectx, or None if |
35998
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
445 the file isn't LFS. |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
446 |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
447 Optionally, the pointer for a file deleted from the context can be returned. |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
448 Since no such pointer is actually stored, and to distinguish from a non LFS |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
449 file, this pointer is represented by an empty dict. |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
450 """ |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
451 _ctx = ctx |
35921
47e737d27e01
lfs: factor out a method for extracting the pointer of a single file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35799
diff
changeset
|
452 if f not in ctx: |
35998
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
453 if not removed: |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
454 return None |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
455 if f in ctx.p1(): |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
456 _ctx = ctx.p1() |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
457 elif f in ctx.p2(): |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
458 _ctx = ctx.p2() |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
459 else: |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
460 return None |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
461 fctx = _ctx[f] |
35921
47e737d27e01
lfs: factor out a method for extracting the pointer of a single file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35799
diff
changeset
|
462 if not _islfs(fctx.filelog(), fctx.filenode()): |
47e737d27e01
lfs: factor out a method for extracting the pointer of a single file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35799
diff
changeset
|
463 return None |
47e737d27e01
lfs: factor out a method for extracting the pointer of a single file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35799
diff
changeset
|
464 try: |
35998
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
465 p = pointer.deserialize(fctx.rawdata()) |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
466 if ctx == _ctx: |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
467 return p |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
468 return {} |
35921
47e737d27e01
lfs: factor out a method for extracting the pointer of a single file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35799
diff
changeset
|
469 except pointer.InvalidPointer as ex: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
470 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
471 _(b'lfs: corrupted pointer (%s@%s): %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
472 % (f, short(_ctx.node()), ex) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
473 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
474 |
35921
47e737d27e01
lfs: factor out a method for extracting the pointer of a single file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35799
diff
changeset
|
475 |
35998
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
476 def pointersfromctx(ctx, removed=False): |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
477 """return a dict {path: pointer} for given single changectx. |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
478 |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
479 If ``removed`` == True and the LFS file was removed from ``ctx``, the value |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
480 stored for the path is an empty dict. |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
481 """ |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
482 result = {} |
40386
4a81d82474e9
lfs: consult the narrow matcher when extracting pointers from ctx (issue5794)
Matt Harbison <matt_harbison@yahoo.com>
parents:
40368
diff
changeset
|
483 m = ctx.repo().narrowmatch() |
4a81d82474e9
lfs: consult the narrow matcher when extracting pointers from ctx (issue5794)
Matt Harbison <matt_harbison@yahoo.com>
parents:
40368
diff
changeset
|
484 |
4a81d82474e9
lfs: consult the narrow matcher when extracting pointers from ctx (issue5794)
Matt Harbison <matt_harbison@yahoo.com>
parents:
40368
diff
changeset
|
485 # TODO: consider manifest.fastread() instead |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
486 for f in ctx.files(): |
40386
4a81d82474e9
lfs: consult the narrow matcher when extracting pointers from ctx (issue5794)
Matt Harbison <matt_harbison@yahoo.com>
parents:
40368
diff
changeset
|
487 if not m(f): |
4a81d82474e9
lfs: consult the narrow matcher when extracting pointers from ctx (issue5794)
Matt Harbison <matt_harbison@yahoo.com>
parents:
40368
diff
changeset
|
488 continue |
35998
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
489 p = pointerfromctx(ctx, f, removed=removed) |
dce43aaaf209
lfs: allow a pointer to be extracted from a context that removes the file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
490 if p is not None: |
35921
47e737d27e01
lfs: factor out a method for extracting the pointer of a single file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35799
diff
changeset
|
491 result[f] = p |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
492 return result |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
493 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
494 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
495 def uploadblobs(repo, pointers): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
496 """upload given pointers from local blobstore""" |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
497 if not pointers: |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
498 return |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
499 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
500 remoteblob = repo.svfs.lfsremoteblobstore |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
501 remoteblob.writebatch(pointers, repo.svfs.lfslocalblobstore) |
35346
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35215
diff
changeset
|
502 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
503 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
504 @eh.wrapfunction(upgrade, b'_finishdatamigration') |
35363
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
505 def upgradefinishdatamigration(orig, ui, srcrepo, dstrepo, requirements): |
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
506 orig(ui, srcrepo, dstrepo, requirements) |
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
507 |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
508 # Skip if this hasn't been passed to reposetup() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
509 if util.safehasattr( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
510 srcrepo.svfs, b'lfslocalblobstore' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
511 ) and util.safehasattr(dstrepo.svfs, b'lfslocalblobstore'): |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
512 srclfsvfs = srcrepo.svfs.lfslocalblobstore.vfs |
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
513 dstlfsvfs = dstrepo.svfs.lfslocalblobstore.vfs |
35363
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
514 |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
515 for dirpath, dirs, files in srclfsvfs.walk(): |
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
516 for oid in files: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
517 ui.write(_(b'copying lfs blob %s\n') % oid) |
38178
3790efb388ca
lfs: bypass wrapped functions when reposetup() hasn't been called (issue5902)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37762
diff
changeset
|
518 lfutil.link(srclfsvfs.join(oid), dstlfsvfs.join(oid)) |
35363
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
519 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42988
diff
changeset
|
520 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
521 @eh.wrapfunction(upgrade, b'preservedrequirements') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
522 @eh.wrapfunction(upgrade, b'supporteddestrequirements') |
35346
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35215
diff
changeset
|
523 def upgraderequirements(orig, repo): |
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35215
diff
changeset
|
524 reqs = orig(repo) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
525 if b'lfs' in repo.requirements: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
526 reqs.add(b'lfs') |
35346
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35215
diff
changeset
|
527 return reqs |