Show More
@@ -37,10 +37,10 class tarit: | |||||
37 | '''write archive to tar file or stream. can write uncompressed, |
|
37 | '''write archive to tar file or stream. can write uncompressed, | |
38 | or compress with gzip or bzip2.''' |
|
38 | or compress with gzip or bzip2.''' | |
39 |
|
39 | |||
40 | def __init__(self, dest, prefix, kind=''): |
|
40 | def __init__(self, dest, prefix, mtime, kind=''): | |
41 | self.prefix = tidyprefix(dest, prefix, ['.tar', '.tar.bz2', '.tar.gz', |
|
41 | self.prefix = tidyprefix(dest, prefix, ['.tar', '.tar.bz2', '.tar.gz', | |
42 | '.tgz', 'tbz2']) |
|
42 | '.tgz', 'tbz2']) | |
43 |
self.mtime = |
|
43 | self.mtime = mtime | |
44 | if isinstance(dest, str): |
|
44 | if isinstance(dest, str): | |
45 | self.z = tarfile.open(dest, mode='w:'+kind) |
|
45 | self.z = tarfile.open(dest, mode='w:'+kind) | |
46 | else: |
|
46 | else: | |
@@ -78,7 +78,7 class zipit: | |||||
78 | '''write archive to zip file or stream. can write uncompressed, |
|
78 | '''write archive to zip file or stream. can write uncompressed, | |
79 | or compressed with deflate.''' |
|
79 | or compressed with deflate.''' | |
80 |
|
80 | |||
81 | def __init__(self, dest, prefix, compress=True): |
|
81 | def __init__(self, dest, prefix, mtime, compress=True): | |
82 | self.prefix = tidyprefix(dest, prefix, ('.zip',)) |
|
82 | self.prefix = tidyprefix(dest, prefix, ('.zip',)) | |
83 | if not isinstance(dest, str): |
|
83 | if not isinstance(dest, str): | |
84 | try: |
|
84 | try: | |
@@ -88,7 +88,7 class zipit: | |||||
88 | self.z = zipfile.ZipFile(dest, 'w', |
|
88 | self.z = zipfile.ZipFile(dest, 'w', | |
89 | compress and zipfile.ZIP_DEFLATED or |
|
89 | compress and zipfile.ZIP_DEFLATED or | |
90 | zipfile.ZIP_STORED) |
|
90 | zipfile.ZIP_STORED) | |
91 |
self.date_time = time.gmtime( |
|
91 | self.date_time = time.gmtime(mtime)[:6] | |
92 |
|
92 | |||
93 | def addfile(self, name, mode, data): |
|
93 | def addfile(self, name, mode, data): | |
94 | i = zipfile.ZipInfo(self.prefix + name, self.date_time) |
|
94 | i = zipfile.ZipInfo(self.prefix + name, self.date_time) | |
@@ -106,7 +106,7 class zipit: | |||||
106 | class fileit: |
|
106 | class fileit: | |
107 | '''write archive as files in directory.''' |
|
107 | '''write archive as files in directory.''' | |
108 |
|
108 | |||
109 | def __init__(self, name, prefix): |
|
109 | def __init__(self, name, prefix, mtime): | |
110 | if prefix: |
|
110 | if prefix: | |
111 | raise util.Abort(_('cannot give prefix when archiving to files')) |
|
111 | raise util.Abort(_('cannot give prefix when archiving to files')) | |
112 | self.basedir = name |
|
112 | self.basedir = name | |
@@ -130,14 +130,14 class fileit: | |||||
130 | archivers = { |
|
130 | archivers = { | |
131 | 'files': fileit, |
|
131 | 'files': fileit, | |
132 | 'tar': tarit, |
|
132 | 'tar': tarit, | |
133 | 'tbz2': lambda name, prefix: tarit(name, prefix, 'bz2'), |
|
133 | 'tbz2': lambda name, prefix, mtime: tarit(name, prefix, mtime, 'bz2'), | |
134 | 'tgz': lambda name, prefix: tarit(name, prefix, 'gz'), |
|
134 | 'tgz': lambda name, prefix, mtime: tarit(name, prefix, mtime, 'gz'), | |
135 | 'uzip': lambda name, prefix: zipit(name, prefix, False), |
|
135 | 'uzip': lambda name, prefix, mtime: zipit(name, prefix, mtime, False), | |
136 | 'zip': zipit, |
|
136 | 'zip': zipit, | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | def archive(repo, dest, node, kind, decode=True, matchfn=None, |
|
139 | def archive(repo, dest, node, kind, decode=True, matchfn=None, | |
140 | prefix=None): |
|
140 | prefix=None, mtime=None): | |
141 | '''create archive of repo as it was at node. |
|
141 | '''create archive of repo as it was at node. | |
142 |
|
142 | |||
143 | dest can be name of directory, name of archive file, or file |
|
143 | dest can be name of directory, name of archive file, or file | |
@@ -160,8 +160,9 def archive(repo, dest, node, kind, deco | |||||
160 | data = fp.getvalue() |
|
160 | data = fp.getvalue() | |
161 | archiver.addfile(name, mode, data) |
|
161 | archiver.addfile(name, mode, data) | |
162 |
|
162 | |||
163 | archiver = archivers[kind](dest, prefix) |
|
163 | change = repo.changelog.read(node) | |
164 |
mn = |
|
164 | mn = change[0] | |
|
165 | archiver = archivers[kind](dest, prefix, mtime or change[2][0]) | |||
165 | mf = repo.manifest.read(mn).items() |
|
166 | mf = repo.manifest.read(mn).items() | |
166 | mff = repo.manifest.readflags(mn) |
|
167 | mff = repo.manifest.readflags(mn) | |
167 | mf.sort() |
|
168 | mf.sort() |
General Comments 0
You need to be logged in to leave comments.
Login now