##// END OF EJS Templates
lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs...
Matt Harbison -
r35520:6bb940de default
parent child Browse files
Show More
@@ -43,6 +43,7 b' from mercurial import ('
43 filelog,
43 filelog,
44 hg,
44 hg,
45 localrepo,
45 localrepo,
46 node,
46 registrar,
47 registrar,
47 revlog,
48 revlog,
48 scmutil,
49 scmutil,
@@ -122,13 +123,21 b' def reposetup(ui, repo):'
122 if 'lfs' not in repo.requirements:
123 if 'lfs' not in repo.requirements:
123 def checkrequireslfs(ui, repo, **kwargs):
124 def checkrequireslfs(ui, repo, **kwargs):
124 if 'lfs' not in repo.requirements:
125 if 'lfs' not in repo.requirements:
125 ctx = repo[kwargs['node']]
126 last = kwargs.get('node_last')
127 _bin = node.bin
128 if last:
129 s = repo.set('%n:%n', _bin(kwargs['node']), _bin(last))
130 else:
131 s = repo.set('%n', _bin(kwargs['node']))
132 for ctx in s:
126 # TODO: is there a way to just walk the files in the commit?
133 # TODO: is there a way to just walk the files in the commit?
127 if any(ctx[f].islfs() for f in ctx.files() if f in ctx):
134 if any(ctx[f].islfs() for f in ctx.files() if f in ctx):
128 repo.requirements.add('lfs')
135 repo.requirements.add('lfs')
129 repo._writerequirements()
136 repo._writerequirements()
137 break
130
138
131 ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs')
139 ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs')
140 ui.setconfig('hooks', 'pretxnchangegroup.lfs', checkrequireslfs, 'lfs')
132
141
133 def wrapfilelog(filelog):
142 def wrapfilelog(filelog):
134 wrapfunction = extensions.wrapfunction
143 wrapfunction = extensions.wrapfunction
@@ -130,9 +130,9 b' consistently added before that can be ra'
130
130
131 --------------------------------------------------------------------------------
131 --------------------------------------------------------------------------------
132 Case #3: client with lfs content and the extension enabled; server with
132 Case #3: client with lfs content and the extension enabled; server with
133 non-lfs content, and the extension state controlled by #testcases.
133 non-lfs content, and the extension state controlled by #testcases. The server
134 should have an 'lfs' requirement after it picks up its first commit with a blob.
134
135
135 TODO: add the 'lfs' requirement on the server for each test in lfsremote-on
136 $ echo 'this is a big lfs file' > lfs.bin
136 $ echo 'this is a big lfs file' > lfs.bin
137 $ hg ci -Aqm 'lfs'
137 $ hg ci -Aqm 'lfs'
138 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
138 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
@@ -144,15 +144,18 b' TODO: fail more gracefully here'
144 ValueError: no common changegroup version (lfsremote-off !)
144 ValueError: no common changegroup version (lfsremote-off !)
145 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
145 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
146 .hg/requires:lfs
146 .hg/requires:lfs
147 $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
147
148
148 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client3_clone
149 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client3_clone
149 $ grep 'lfs' $TESTTMP/client3_clone/.hg/requires $SERVER_REQUIRES
150 $ grep 'lfs' $TESTTMP/client3_clone/.hg/requires $SERVER_REQUIRES || true
150 [1]
151 $TESTTMP/client3_clone/.hg/requires:lfs (lfsremote-on !)
152 $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
151
153
152 $ hg init $TESTTMP/client3_pull
154 $ hg init $TESTTMP/client3_pull
153 $ hg -R $TESTTMP/client3_pull pull -q http://localhost:$HGPORT
155 $ hg -R $TESTTMP/client3_pull pull -q http://localhost:$HGPORT
154 $ grep 'lfs' $TESTTMP/client3_pull/.hg/requires $SERVER_REQUIRES
156 $ grep 'lfs' $TESTTMP/client3_pull/.hg/requires $SERVER_REQUIRES || true
155 [1]
157 $TESTTMP/client3_pull/.hg/requires:lfs (lfsremote-on !)
158 $TESTTMP/server/.hg/requires:lfs (lfsremote-on !)
156
159
157 XXX: The difference here is the push failed above when the extension isn't
160 XXX: The difference here is the push failed above when the extension isn't
158 enabled on the server. The extension shouldn't need to mess with changegroup
161 enabled on the server. The extension shouldn't need to mess with changegroup
@@ -185,12 +188,12 b' lfs content, and the extension enabled.'
185 $ echo 'non-lfs' > nonlfs2.txt
188 $ echo 'non-lfs' > nonlfs2.txt
186 $ hg ci -Aqm 'non-lfs'
189 $ hg ci -Aqm 'non-lfs'
187 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
190 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
188 [1]
191 $TESTTMP/server/.hg/requires:lfs
189
192
190 $ hg push -q --force
193 $ hg push -q --force
191 warning: repository is unrelated
194 warning: repository is unrelated
192 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
195 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
193 [1]
196 $TESTTMP/server/.hg/requires:lfs
194
197
195 TODO: fail more gracefully.
198 TODO: fail more gracefully.
196
199
@@ -199,6 +202,7 b' TODO: fail more gracefully.'
199 [255]
202 [255]
200 $ grep 'lfs' $TESTTMP/client4_clone/.hg/requires $SERVER_REQUIRES
203 $ grep 'lfs' $TESTTMP/client4_clone/.hg/requires $SERVER_REQUIRES
201 grep: $TESTTMP/client4_clone/.hg/requires: $ENOENT$
204 grep: $TESTTMP/client4_clone/.hg/requires: $ENOENT$
205 $TESTTMP/server/.hg/requires:lfs
202 [2]
206 [2]
203
207
204 TODO: fail more gracefully.
208 TODO: fail more gracefully.
@@ -208,7 +212,7 b' TODO: fail more gracefully.'
208 abort: HTTP Error 500: Internal Server Error
212 abort: HTTP Error 500: Internal Server Error
209 [255]
213 [255]
210 $ grep 'lfs' $TESTTMP/client4_pull/.hg/requires $SERVER_REQUIRES
214 $ grep 'lfs' $TESTTMP/client4_pull/.hg/requires $SERVER_REQUIRES
211 [1]
215 $TESTTMP/server/.hg/requires:lfs
212
216
213 $ hg identify http://localhost:$HGPORT
217 $ hg identify http://localhost:$HGPORT
214 03b080fa9d93
218 03b080fa9d93
@@ -226,16 +230,18 b' lfs content, and the extension enabled.'
226
230
227 $ hg push -q
231 $ hg push -q
228 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
232 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
229 [1]
233 $TESTTMP/server/.hg/requires:lfs
230
234
231 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client5_clone
235 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client5_clone
232 $ grep 'lfs' $TESTTMP/client5_clone/.hg/requires $SERVER_REQUIRES
236 $ grep 'lfs' $TESTTMP/client5_clone/.hg/requires $SERVER_REQUIRES
233 [1]
237 $TESTTMP/client5_clone/.hg/requires:lfs
238 $TESTTMP/server/.hg/requires:lfs
234
239
235 $ hg init $TESTTMP/client5_pull
240 $ hg init $TESTTMP/client5_pull
236 $ hg -R $TESTTMP/client5_pull pull -q http://localhost:$HGPORT
241 $ hg -R $TESTTMP/client5_pull pull -q http://localhost:$HGPORT
237 $ grep 'lfs' $TESTTMP/client5_pull/.hg/requires $SERVER_REQUIRES
242 $ grep 'lfs' $TESTTMP/client5_pull/.hg/requires $SERVER_REQUIRES
238 [1]
243 $TESTTMP/client5_pull/.hg/requires:lfs
244 $TESTTMP/server/.hg/requires:lfs
239
245
240 $ hg identify http://localhost:$HGPORT
246 $ hg identify http://localhost:$HGPORT
241 c729025cc5e3
247 c729025cc5e3
@@ -244,23 +250,24 b' lfs content, and the extension enabled.'
244 Case #6: client with lfs content and the extension enabled; server with
250 Case #6: client with lfs content and the extension enabled; server with
245 lfs content, and the extension enabled.
251 lfs content, and the extension enabled.
246
252
247 TODO: add the 'lfs' requirement on the server for each test
248
249 $ echo 'this is another lfs file' > lfs2.txt
253 $ echo 'this is another lfs file' > lfs2.txt
250 $ hg ci -Aqm 'lfs file with lfs client'
254 $ hg ci -Aqm 'lfs file with lfs client'
251
255
252 $ hg push -q
256 $ hg push -q
253 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
257 $ grep 'lfs' .hg/requires $SERVER_REQUIRES
254 .hg/requires:lfs
258 .hg/requires:lfs
259 $TESTTMP/server/.hg/requires:lfs
255
260
256 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client6_clone
261 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client6_clone
257 $ grep 'lfs' $TESTTMP/client6_clone/.hg/requires $SERVER_REQUIRES
262 $ grep 'lfs' $TESTTMP/client6_clone/.hg/requires $SERVER_REQUIRES
258 [1]
263 $TESTTMP/client6_clone/.hg/requires:lfs
264 $TESTTMP/server/.hg/requires:lfs
259
265
260 $ hg init $TESTTMP/client6_pull
266 $ hg init $TESTTMP/client6_pull
261 $ hg -R $TESTTMP/client6_pull pull -q http://localhost:$HGPORT
267 $ hg -R $TESTTMP/client6_pull pull -q http://localhost:$HGPORT
262 $ grep 'lfs' $TESTTMP/client6_pull/.hg/requires $SERVER_REQUIRES
268 $ grep 'lfs' $TESTTMP/client6_pull/.hg/requires $SERVER_REQUIRES
263 [1]
269 $TESTTMP/client6_pull/.hg/requires:lfs
270 $TESTTMP/server/.hg/requires:lfs
264
271
265 $ hg identify http://localhost:$HGPORT
272 $ hg identify http://localhost:$HGPORT
266 d3b84d50eacb
273 d3b84d50eacb
@@ -53,6 +53,7 b''
53 adding manifests
53 adding manifests
54 adding file changes
54 adding file changes
55 added 1 changesets with 1 changes to 1 files
55 added 1 changesets with 1 changes to 1 files
56 calling hook pretxnchangegroup.lfs: hgext.lfs.checkrequireslfs
56
57
57 Clear the cache to force a download
58 Clear the cache to force a download
58 $ rm -rf `hg config lfs.usercache`
59 $ rm -rf `hg config lfs.usercache`
@@ -56,7 +56,7 b''
56 > url=file:$TESTTMP/dummy-remote/
56 > url=file:$TESTTMP/dummy-remote/
57 > EOF
57 > EOF
58
58
59 TODO: Push to a local non-lfs repo with the extension enabled should add the
59 Push to a local non-lfs repo with the extension enabled will add the
60 lfs requirement
60 lfs requirement
61
61
62 $ grep lfs $TESTTMP/server/.hg/requires
62 $ grep lfs $TESTTMP/server/.hg/requires
@@ -70,8 +70,9 b' lfs requirement'
70 adding manifests
70 adding manifests
71 adding file changes
71 adding file changes
72 added 2 changesets with 2 changes to 2 files
72 added 2 changesets with 2 changes to 2 files
73 calling hook pretxnchangegroup.lfs: hgext.lfs.checkrequireslfs
73 $ grep lfs $TESTTMP/server/.hg/requires
74 $ grep lfs $TESTTMP/server/.hg/requires
74 [1]
75 lfs
75
76
76 # Unknown URL scheme
77 # Unknown URL scheme
77
78
@@ -91,11 +92,11 b' lfs requirement'
91
92
92 # Pull from server
93 # Pull from server
93
94
94 TODO: Pulling a local lfs repo into a local non-lfs repo with the extension
95 Pulling a local lfs repo into a local non-lfs repo with the extension
95 enabled should add the lfs requirement
96 enabled adds the lfs requirement
96
97
97 $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
98 $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
98 [1]
99 $TESTTMP/server/.hg/requires:lfs
99 $ hg pull default
100 $ hg pull default
100 pulling from $TESTTMP/server
101 pulling from $TESTTMP/server
101 requesting all changes
102 requesting all changes
@@ -106,7 +107,8 b' enabled should add the lfs requirement'
106 new changesets b29ba743f89d:00c137947d30
107 new changesets b29ba743f89d:00c137947d30
107 (run 'hg update' to get a working copy)
108 (run 'hg update' to get a working copy)
108 $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
109 $ grep lfs .hg/requires $TESTTMP/server/.hg/requires
109 [1]
110 .hg/requires:lfs
111 $TESTTMP/server/.hg/requires:lfs
110
112
111 # Check the blobstore is not yet populated
113 # Check the blobstore is not yet populated
112 $ [ -d .hg/store/lfs/objects ]
114 $ [ -d .hg/store/lfs/objects ]
@@ -872,7 +874,7 b' Committing deleted files works:'
872 $ hg commit -m 'rm A'
874 $ hg commit -m 'rm A'
873 $ cd ..
875 $ cd ..
874
876
875 TODO: Unbundling adds a requirement to a non-lfs repo, if necessary.
877 Unbundling adds a requirement to a non-lfs repo, if necessary.
876
878
877 $ hg bundle -R $TESTTMP/repo-del -qr 0 --base null nolfs.hg
879 $ hg bundle -R $TESTTMP/repo-del -qr 0 --base null nolfs.hg
878 $ hg bundle -R convert_lfs2 -qr tip --base null lfs.hg
880 $ hg bundle -R convert_lfs2 -qr tip --base null lfs.hg
@@ -882,7 +884,7 b' TODO: Unbundling adds a requirement to a'
882 [1]
884 [1]
883 $ hg pull -R unbundle -q lfs.hg
885 $ hg pull -R unbundle -q lfs.hg
884 $ grep lfs unbundle/.hg/requires
886 $ grep lfs unbundle/.hg/requires
885 [1]
887 lfs
886
888
887 $ hg init no_lfs
889 $ hg init no_lfs
888 $ cat >> no_lfs/.hg/hgrc <<EOF
890 $ cat >> no_lfs/.hg/hgrc <<EOF
General Comments 0
You need to be logged in to leave comments. Login now