Show More
@@ -205,7 +205,7 archivers = { | |||
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | def archive(repo, dest, node, kind, decode=True, matchfn=None, |
|
208 | prefix=None, mtime=None): | |
|
208 | prefix=None, mtime=None, subrepos=False): | |
|
209 | 209 | '''create archive of repo as it was at node. |
|
210 | 210 | |
|
211 | 211 | dest can be name of directory, name of archive file, or file |
@@ -263,4 +263,10 def archive(repo, dest, node, kind, deco | |||
|
263 | 263 | for f in ctx: |
|
264 | 264 | ff = ctx.flags(f) |
|
265 | 265 | write(f, 'x' in ff and 0755 or 0644, 'l' in ff, ctx[f].data) |
|
266 | ||
|
267 | if subrepos: | |
|
268 | for subpath in ctx.substate: | |
|
269 | sub = ctx.sub(subpath) | |
|
270 | sub.archive(archiver, prefix) | |
|
271 | ||
|
266 | 272 | archiver.done() |
@@ -199,7 +199,7 def archive(ui, repo, dest, **opts): | |||
|
199 | 199 | prefix = cmdutil.make_filename(repo, prefix, node) |
|
200 | 200 | matchfn = cmdutil.match(repo, [], opts) |
|
201 | 201 | archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
|
202 | matchfn, prefix) | |
|
202 | matchfn, prefix, subrepos=opts.get('subrepos')) | |
|
203 | 203 | |
|
204 | 204 | def backout(ui, repo, node=None, rev=None, **opts): |
|
205 | 205 | '''reverse effect of earlier changeset |
@@ -3963,7 +3963,7 table = { | |||
|
3963 | 3963 | _('revision to distribute'), _('REV')), |
|
3964 | 3964 | ('t', 'type', '', |
|
3965 | 3965 | _('type of distribution to create'), _('TYPE')), |
|
3966 | ] + walkopts, | |
|
3966 | ] + subrepoopts + walkopts, | |
|
3967 | 3967 | _('[OPTION]... DEST')), |
|
3968 | 3968 | "backout": |
|
3969 | 3969 | (backout, |
@@ -282,6 +282,15 class abstractsubrepo(object): | |||
|
282 | 282 | """return file flags""" |
|
283 | 283 | return '' |
|
284 | 284 | |
|
285 | def archive(self, archiver, prefix): | |
|
286 | for name in self.files(): | |
|
287 | flags = self.fileflags(name) | |
|
288 | mode = 'x' in flags and 0755 or 0644 | |
|
289 | symlink = 'l' in flags | |
|
290 | archiver.addfile(os.path.join(prefix, self._path, name), | |
|
291 | mode, symlink, self.filedata(name)) | |
|
292 | ||
|
293 | ||
|
285 | 294 | class hgsubrepo(abstractsubrepo): |
|
286 | 295 | def __init__(self, ctx, path, state): |
|
287 | 296 | self._path = path |
@@ -341,6 +350,15 class hgsubrepo(abstractsubrepo): | |||
|
341 | 350 | self._repo.ui.warn(_("warning: %s in %s\n") |
|
342 | 351 | % (inst, relpath(self))) |
|
343 | 352 | |
|
353 | def archive(self, archiver, prefix): | |
|
354 | abstractsubrepo.archive(self, archiver, prefix) | |
|
355 | ||
|
356 | rev = self._state[1] | |
|
357 | ctx = self._repo[rev] | |
|
358 | for subpath in ctx.substate: | |
|
359 | s = subrepo(ctx, subpath) | |
|
360 | s.archive(archiver, os.path.join(prefix, self._path)) | |
|
361 | ||
|
344 | 362 | def dirty(self): |
|
345 | 363 | r = self._state[1] |
|
346 | 364 | if r == '': |
@@ -227,6 +227,40 Status between revisions: | |||
|
227 | 227 | z1 |
|
228 | 228 | +z2 |
|
229 | 229 | |
|
230 | Test archiving to a directory tree: | |
|
231 | ||
|
232 | $ hg archive --subrepos ../archive | |
|
233 | $ find ../archive | |
|
234 | ../archive | |
|
235 | ../archive/foo | |
|
236 | ../archive/foo/bar | |
|
237 | ../archive/foo/bar/z.txt | |
|
238 | ../archive/foo/.hgsubstate | |
|
239 | ../archive/foo/.hgsub | |
|
240 | ../archive/foo/y.txt | |
|
241 | ../archive/x.txt | |
|
242 | ../archive/.hgsubstate | |
|
243 | ../archive/.hgsub | |
|
244 | ../archive/.hg_archival.txt | |
|
245 | ||
|
246 | Test archiving to zip file: | |
|
247 | ||
|
248 | $ hg archive --subrepos ../archive.zip | |
|
249 | $ unzip -l ../archive.zip | |
|
250 | Archive: ../archive.zip | |
|
251 | Length Date Time Name | |
|
252 | --------- ---------- ----- ---- | |
|
253 | 147 1980-01-01 00:00 archive/.hg_archival.txt | |
|
254 | 10 1980-01-01 00:00 archive/.hgsub | |
|
255 | 45 1980-01-01 00:00 archive/.hgsubstate | |
|
256 | 3 1980-01-01 00:00 archive/x.txt | |
|
257 | 9 1980-01-01 00:00 archive/foo/y.txt | |
|
258 | 10 1980-01-01 00:00 archive/foo/.hgsub | |
|
259 | 45 1980-01-01 00:00 archive/foo/.hgsubstate | |
|
260 | 9 1980-01-01 00:00 archive/foo/bar/z.txt | |
|
261 | --------- ------- | |
|
262 | 278 8 files | |
|
263 | ||
|
230 | 264 | Clone and test outgoing: |
|
231 | 265 | |
|
232 | 266 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now