Mercurial > hg
comparison mercurial/archival.py @ 40407:3d76a8e627a6
archive: change "matcnfn" argument to a real matcher
All callers seem to be passing a real matcher, not just a function. We
were also passing it into match.subdirmatcher(), which assumes it is a
matcher.
Differential Revision: https://phab.mercurial-scm.org/D5176
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 05 Sep 2017 15:21:21 -0700 |
parents | 844deb408a5b |
children | 997997eb8367 |
comparison
equal
deleted
inserted
replaced
40403:bf249bb60087 | 40407:3d76a8e627a6 |
---|---|
272 'tgz': lambda name, mtime: tarit(name, mtime, 'gz'), | 272 'tgz': lambda name, mtime: tarit(name, mtime, 'gz'), |
273 'uzip': lambda name, mtime: zipit(name, mtime, False), | 273 'uzip': lambda name, mtime: zipit(name, mtime, False), |
274 'zip': zipit, | 274 'zip': zipit, |
275 } | 275 } |
276 | 276 |
277 def archive(repo, dest, node, kind, decode=True, matchfn=None, | 277 def archive(repo, dest, node, kind, decode=True, match=None, |
278 prefix='', mtime=None, subrepos=False): | 278 prefix='', mtime=None, subrepos=False): |
279 '''create archive of repo as it was at node. | 279 '''create archive of repo as it was at node. |
280 | 280 |
281 dest can be name of directory, name of archive file, or file | 281 dest can be name of directory, name of archive file, or file |
282 object to write archive to. | 282 object to write archive to. |
284 kind is type of archive to create. | 284 kind is type of archive to create. |
285 | 285 |
286 decode tells whether to put files through decode filters from | 286 decode tells whether to put files through decode filters from |
287 hgrc. | 287 hgrc. |
288 | 288 |
289 matchfn is function to filter names of files to write to archive. | 289 match is a matcher to filter names of files to write to archive. |
290 | 290 |
291 prefix is name of path to put before every archive member. | 291 prefix is name of path to put before every archive member. |
292 | 292 |
293 mtime is the modified time, in seconds, or None to use the changeset time. | 293 mtime is the modified time, in seconds, or None to use the changeset time. |
294 | 294 |
313 ctx = repo[node] | 313 ctx = repo[node] |
314 archiver = archivers[kind](dest, mtime or ctx.date()[0]) | 314 archiver = archivers[kind](dest, mtime or ctx.date()[0]) |
315 | 315 |
316 if repo.ui.configbool("ui", "archivemeta"): | 316 if repo.ui.configbool("ui", "archivemeta"): |
317 name = '.hg_archival.txt' | 317 name = '.hg_archival.txt' |
318 if not matchfn or matchfn(name): | 318 if not match or match(name): |
319 write(name, 0o644, False, lambda: buildmetadata(ctx)) | 319 write(name, 0o644, False, lambda: buildmetadata(ctx)) |
320 | 320 |
321 if matchfn: | 321 if match: |
322 files = [f for f in ctx.manifest().keys() if matchfn(f)] | 322 files = [f for f in ctx.manifest().keys() if match(f)] |
323 else: | 323 else: |
324 files = ctx.manifest().keys() | 324 files = ctx.manifest().keys() |
325 total = len(files) | 325 total = len(files) |
326 if total: | 326 if total: |
327 files.sort() | 327 files.sort() |
337 progress.complete() | 337 progress.complete() |
338 | 338 |
339 if subrepos: | 339 if subrepos: |
340 for subpath in sorted(ctx.substate): | 340 for subpath in sorted(ctx.substate): |
341 sub = ctx.workingsub(subpath) | 341 sub = ctx.workingsub(subpath) |
342 submatch = matchmod.subdirmatcher(subpath, matchfn) | 342 submatch = matchmod.subdirmatcher(subpath, match) |
343 total += sub.archive(archiver, prefix, submatch, decode) | 343 total += sub.archive(archiver, prefix, submatch, decode) |
344 | 344 |
345 if total == 0: | 345 if total == 0: |
346 raise error.Abort(_('no files match the archive pattern')) | 346 raise error.Abort(_('no files match the archive pattern')) |
347 | 347 |