Show More
@@ -274,6 +274,6 b' def archive(repo, dest, node, kind, deco' | |||||
274 | if subrepos: |
|
274 | if subrepos: | |
275 | for subpath in ctx.substate: |
|
275 | for subpath in ctx.substate: | |
276 | sub = ctx.sub(subpath) |
|
276 | sub = ctx.sub(subpath) | |
277 | sub.archive(archiver, prefix) |
|
277 | sub.archive(repo.ui, archiver, prefix) | |
278 |
|
278 | |||
279 | archiver.done() |
|
279 | archiver.done() |
@@ -304,13 +304,21 b' class abstractsubrepo(object):' | |||||
304 | """return file flags""" |
|
304 | """return file flags""" | |
305 | return '' |
|
305 | return '' | |
306 |
|
306 | |||
307 | def archive(self, archiver, prefix): |
|
307 | def archive(self, ui, archiver, prefix): | |
308 |
f |
|
308 | files = self.files() | |
|
309 | total = len(files) | |||
|
310 | relpath = subrelpath(self) | |||
|
311 | ui.progress(_('archiving (%s)') % relpath, 0, | |||
|
312 | unit=_('files'), total=total) | |||
|
313 | for i, name in enumerate(files): | |||
309 | flags = self.fileflags(name) |
|
314 | flags = self.fileflags(name) | |
310 | mode = 'x' in flags and 0755 or 0644 |
|
315 | mode = 'x' in flags and 0755 or 0644 | |
311 | symlink = 'l' in flags |
|
316 | symlink = 'l' in flags | |
312 | archiver.addfile(os.path.join(prefix, self._path, name), |
|
317 | archiver.addfile(os.path.join(prefix, self._path, name), | |
313 | mode, symlink, self.filedata(name)) |
|
318 | mode, symlink, self.filedata(name)) | |
|
319 | ui.progress(_('archiving (%s)') % relpath, i + 1, | |||
|
320 | unit=_('files'), total=total) | |||
|
321 | ui.progress(_('archiving (%s)') % relpath, None) | |||
314 |
|
322 | |||
315 |
|
323 | |||
316 | class hgsubrepo(abstractsubrepo): |
|
324 | class hgsubrepo(abstractsubrepo): | |
@@ -373,14 +381,14 b' class hgsubrepo(abstractsubrepo):' | |||||
373 | self._repo.ui.warn(_('warning: error "%s" in subrepository "%s"\n') |
|
381 | self._repo.ui.warn(_('warning: error "%s" in subrepository "%s"\n') | |
374 | % (inst, subrelpath(self))) |
|
382 | % (inst, subrelpath(self))) | |
375 |
|
383 | |||
376 | def archive(self, archiver, prefix): |
|
384 | def archive(self, ui, archiver, prefix): | |
377 | abstractsubrepo.archive(self, archiver, prefix) |
|
385 | abstractsubrepo.archive(self, ui, archiver, prefix) | |
378 |
|
386 | |||
379 | rev = self._state[1] |
|
387 | rev = self._state[1] | |
380 | ctx = self._repo[rev] |
|
388 | ctx = self._repo[rev] | |
381 | for subpath in ctx.substate: |
|
389 | for subpath in ctx.substate: | |
382 | s = subrepo(ctx, subpath) |
|
390 | s = subrepo(ctx, subpath) | |
383 | s.archive(archiver, os.path.join(prefix, self._path)) |
|
391 | s.archive(ui, archiver, os.path.join(prefix, self._path)) | |
384 |
|
392 | |||
385 | def dirty(self): |
|
393 | def dirty(self): | |
386 | r = self._state[1] |
|
394 | r = self._state[1] | |
@@ -860,7 +868,7 b' class gitsubrepo(abstractsubrepo):' | |||||
860 | else: |
|
868 | else: | |
861 | os.remove(path) |
|
869 | os.remove(path) | |
862 |
|
870 | |||
863 | def archive(self, archiver, prefix): |
|
871 | def archive(self, ui, archiver, prefix): | |
864 | source, revision = self._state |
|
872 | source, revision = self._state | |
865 | self._fetch(source, revision) |
|
873 | self._fetch(source, revision) | |
866 |
|
874 | |||
@@ -869,10 +877,16 b' class gitsubrepo(abstractsubrepo):' | |||||
869 | # and objects with many subprocess calls. |
|
877 | # and objects with many subprocess calls. | |
870 | tarstream = self._gitcommand(['archive', revision], stream=True) |
|
878 | tarstream = self._gitcommand(['archive', revision], stream=True) | |
871 | tar = tarfile.open(fileobj=tarstream, mode='r|') |
|
879 | tar = tarfile.open(fileobj=tarstream, mode='r|') | |
872 | for info in tar: |
|
880 | relpath = subrelpath(self) | |
|
881 | ui.progress(_('archiving (%s)') % relpath, 0, unit=_('files')) | |||
|
882 | for i, info in enumerate(tar): | |||
873 | archiver.addfile(os.path.join(prefix, self._relpath, info.name), |
|
883 | archiver.addfile(os.path.join(prefix, self._relpath, info.name), | |
874 | info.mode, info.issym(), |
|
884 | info.mode, info.issym(), | |
875 | tar.extractfile(info).read()) |
|
885 | tar.extractfile(info).read()) | |
|
886 | ui.progress(_('archiving (%s)') % relpath, i + 1, | |||
|
887 | unit=_('files')) | |||
|
888 | ui.progress(_('archiving (%s)') % relpath, None) | |||
|
889 | ||||
876 |
|
890 | |||
877 | types = { |
|
891 | types = { | |
878 | 'hg': hgsubrepo, |
|
892 | 'hg': hgsubrepo, |
@@ -221,9 +221,47 b' Status between revisions:' | |||||
221 | z1 |
|
221 | z1 | |
222 | +z2 |
|
222 | +z2 | |
223 |
|
223 | |||
224 | Test archiving to a directory tree: |
|
224 | Enable progress extension for archive tests: | |
|
225 | ||||
|
226 | $ cp $HGRCPATH $HGRCPATH.no-progress | |||
|
227 | $ cat >> $HGRCPATH <<EOF | |||
|
228 | > [extensions] | |||
|
229 | > progress = | |||
|
230 | > [progress] | |||
|
231 | > assume-tty = 1 | |||
|
232 | > delay = 0 | |||
|
233 | > refresh = 0 | |||
|
234 | > width = 60 | |||
|
235 | > EOF | |||
|
236 | ||||
|
237 | Test archiving to a directory tree (the doubled lines in the output | |||
|
238 | only show up in the test output, not in real usage): | |||
225 |
|
239 | |||
226 | $ hg archive --subrepos ../archive |
|
240 | $ hg archive --subrepos ../archive 2>&1 | $TESTDIR/filtercr.py | |
|
241 | ||||
|
242 | archiving [ ] 0/3 | |||
|
243 | archiving [ ] 0/3 | |||
|
244 | archiving [=============> ] 1/3 | |||
|
245 | archiving [=============> ] 1/3 | |||
|
246 | archiving [===========================> ] 2/3 | |||
|
247 | archiving [===========================> ] 2/3 | |||
|
248 | archiving [==========================================>] 3/3 | |||
|
249 | archiving [==========================================>] 3/3 | |||
|
250 | ||||
|
251 | archiving (foo) [ ] 0/3 | |||
|
252 | archiving (foo) [ ] 0/3 | |||
|
253 | archiving (foo) [===========> ] 1/3 | |||
|
254 | archiving (foo) [===========> ] 1/3 | |||
|
255 | archiving (foo) [=======================> ] 2/3 | |||
|
256 | archiving (foo) [=======================> ] 2/3 | |||
|
257 | archiving (foo) [====================================>] 3/3 | |||
|
258 | archiving (foo) [====================================>] 3/3 | |||
|
259 | ||||
|
260 | archiving (foo/bar) [ ] 0/1 | |||
|
261 | archiving (foo/bar) [ ] 0/1 | |||
|
262 | archiving (foo/bar) [================================>] 1/1 | |||
|
263 | archiving (foo/bar) [================================>] 1/1 | |||
|
264 | \r (esc) | |||
227 | $ find ../archive | sort |
|
265 | $ find ../archive | sort | |
228 | ../archive |
|
266 | ../archive | |
229 | ../archive/.hg_archival.txt |
|
267 | ../archive/.hg_archival.txt | |
@@ -239,7 +277,35 b' Test archiving to a directory tree:' | |||||
239 |
|
277 | |||
240 | Test archiving to zip file (unzip output is unstable): |
|
278 | Test archiving to zip file (unzip output is unstable): | |
241 |
|
279 | |||
242 | $ hg archive --subrepos ../archive.zip |
|
280 | $ hg archive --subrepos ../archive.zip 2>&1 | $TESTDIR/filtercr.py | |
|
281 | ||||
|
282 | archiving [ ] 0/3 | |||
|
283 | archiving [ ] 0/3 | |||
|
284 | archiving [=============> ] 1/3 | |||
|
285 | archiving [=============> ] 1/3 | |||
|
286 | archiving [===========================> ] 2/3 | |||
|
287 | archiving [===========================> ] 2/3 | |||
|
288 | archiving [==========================================>] 3/3 | |||
|
289 | archiving [==========================================>] 3/3 | |||
|
290 | ||||
|
291 | archiving (foo) [ ] 0/3 | |||
|
292 | archiving (foo) [ ] 0/3 | |||
|
293 | archiving (foo) [===========> ] 1/3 | |||
|
294 | archiving (foo) [===========> ] 1/3 | |||
|
295 | archiving (foo) [=======================> ] 2/3 | |||
|
296 | archiving (foo) [=======================> ] 2/3 | |||
|
297 | archiving (foo) [====================================>] 3/3 | |||
|
298 | archiving (foo) [====================================>] 3/3 | |||
|
299 | ||||
|
300 | archiving (foo/bar) [ ] 0/1 | |||
|
301 | archiving (foo/bar) [ ] 0/1 | |||
|
302 | archiving (foo/bar) [================================>] 1/1 | |||
|
303 | archiving (foo/bar) [================================>] 1/1 | |||
|
304 | \r (esc) | |||
|
305 | ||||
|
306 | Disable progress extension and cleanup: | |||
|
307 | ||||
|
308 | $ mv $HGRCPATH.no-progress $HGRCPATH | |||
243 |
|
309 | |||
244 | Clone and test outgoing: |
|
310 | Clone and test outgoing: | |
245 |
|
311 |
General Comments 0
You need to be logged in to leave comments.
Login now