Commit Graph

64 Commits

Author SHA1 Message Date
Angel Ezquerra
9b84fa41a7 archive: raise error.Abort if the file pattern matches no files
Note that we could raise this exception even if no pattern were specified, but
the revision contained no files. However this should not happen in practice
since in that case commands.py/archive would exit earlier with an "no working
directory: please specify a revision" error message instead.
2013-03-21 22:09:15 +01:00
Mads Kiilerich
2d6545f8b6 subrepos: process subrepos in sorted order
Add sorted() in places found by testing with PYTHONHASHSEED=random and code
inspection.

An alternative to sprinkling sorted() all over would be to change substate to a
custom dict with sorted iterators...
2012-12-12 02:38:14 +01:00
Mads Kiilerich
b66ec06f79 archival: tarit should never close the dest passed to it
Some archive types closed the open file passed to it, some didn't.

This could cause either missing or duplicate close and cause problems in hgweb.

The fix in 4f98880c1b4e should only have closed the compressors and archivers -
not the underlying file itself if no compressor is used.
2013-01-15 01:05:12 +01:00
Mads Kiilerich
bd884d9410 archival: avoid touching deprecated gzip name attribute
The existing workaround didn't work when no filename was specified.

If running in a context with warnings enabled and subsecond mtime it gave a
warning:
  DeprecationWarning: use the name attribute
2013-01-03 21:07:04 +01:00
Mads Kiilerich
959c978f9d archival: pass integer to struct.pack int field instead of float
If running in a context with warnings enabled and subsecond mtime it gave a
warning:
  DeprecationWarning: integer argument expected, got float
2013-01-03 21:07:04 +01:00
Bryan O'Sullivan
7a018d3dd7 Merge with crew-stable 2012-09-19 09:38:51 -07:00
FUJIWARA Katsunori
e08cbc5b19 archival: add "extended-timestamp" extra block for zip archives (issue3600)
Before this patch, zip archives created by "hg archive" are extracted
with unexpected timestamp, if TZ is not configured as GMT.

This patch adds "extended-timestamp" extra block to zip archives, and
unzip will extract such archives with timestamp specified in added
extra block, even though TZ is not configured as GMT.

Please see documents below for detail about specification of zip file
format and "extended-timestamp" extra block:

  http://www.pkware.com/documents/casestudies/APPNOTE.TXT
  http://www.opensource.apple.com/source/zip/zip-6/unzip/unzip/proginfo/extra.fld

Original implementation of this patch was suggested by "Jun Omae
<jun66j5@gmail.com>".
2012-09-18 19:46:15 +09:00
Mads Kiilerich
48016eb3fc declare local constants instead of using magic values and comments 2012-08-27 23:16:22 +02:00
Matt Harbison
63a46b018b subrepo: propagate matcher to subrepos when archiving
Add a match object to subrepo.archive(). This will allow the -X and -I
options to be honored inside subrepos when archiving. They formerly
only affect the top level repo.
2012-06-16 22:34:06 -04:00
Thomas Arendsen Hein
0c30f8dca5 archive: make progress only show files that are actually archived
Before this, files that are excluded (or not included) were shown when
using progress bar or --debug.

Reported by Andrew Shadura.
2012-06-12 12:05:52 +02:00
Greg Ward
bc1dfb1ac9 atomictempfile: make close() consistent with other file-like objects.
The usual contract is that close() makes your writes permanent, so
atomictempfile's use of close() to *discard* writes (and rename() to
keep them) is rather unexpected. Thus, change it so close() makes
things permanent and add a new discard() method to throw them away.
discard() is only used internally, in __del__(), to ensure that writes
are discarded when an atomictempfile object goes out of scope.

I audited mercurial.*, hgext.*, and ~80 third-party extensions, and
found no one using the existing semantics of close() to discard
writes, so this should be safe.
2011-08-25 20:21:04 -04:00
Adrian Buehlmann
cf126bb7dd move opener from util to scmutil 2011-04-20 19:54:57 +02:00
Markus F.X.J. Oberhumer
c2ca636151 archive: use hardcoded constants when creating .zip archives
Do not rely on local stat constants, which may differ.
2011-03-16 23:54:55 +01:00
Dan Villiom Podlaski Christiansen
ec590d5cd4 explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
2010-12-24 15:23:01 +01:00
Martin Geisler
290569c6d1 subrepo: add progress bar support to archive 2010-11-29 16:34:10 +01:00
Martin Geisler
70d929229e archive: add support for progress extension 2010-11-29 16:17:05 +01:00
Matt Mackall
6bcc439bb1 merge with stable 2010-12-08 13:12:12 -06:00
Brodie Rao
08a14dad90 archival: don't set gzip filename header when there's no filename
This mainly affects hgweb, which can generate tar.gz archives without
filenames. Without this change, the header would be set to ".gz",
which can confuse Safari into extracting the file and renaming it to
"gz" when "Open 'safe' files after downloading" is enabled.

file(1) before:

hg-crew-439421eab08d.tar.gz: gzip compressed data, was ".gz", last modified: Thu Dec  2 11:46:20 2010, max compression

after:

hg-crew-439421eab08d.tar.gz: gzip compressed data, last modified: Thu Dec  2 11:46:20 2010, max compression
2010-12-07 19:47:53 +11:00
Matt Mackall
8b31da4540 branch: operate on branch names in local string space where possible
Previously, branch names were ideally manipulated as UTF-8 strings,
because they were stored as UTF-8 in the dirstate and the changelog
and could not be safely converted to the local encoding and back.

However, only about 80% of branch name code was actually using the
right encoding conventions. This patch uses the localstr addition to
allow working on branch names as local strings, which simplifies
handling so that the previously incorrect code becomes correct.
2010-11-24 15:56:32 -06:00
Martin Geisler
34af0cf109 subrepo: add support for 'hg archive' 2010-09-20 15:46:17 +02:00
Martin Geisler
989dda555a merge with stable 2010-09-20 15:42:58 +02:00
Martin Geisler
4152cae060 archive: set date to 1980 for very old zip files
The zip file format stores the date using "MS-DOS format" which
apparently means that they use 1980 as their epoch. Python's zipfile
module emits deprecation warnings of this form

  /usr/lib/python2.6/zipfile.py:1108: DeprecationWarning: struct
  integer overflow masking is deprecated
    self.fp.write(zinfo.FileHeader())
  /usr/lib/python2.6/zipfile.py:1108: DeprecationWarning: 'H' format
  requires 0 <= number <= 65535
    self.fp.write(zinfo.FileHeader())
  /home/mg/src/mercurial-crew/mercurial/archival.py:169:
  DeprecationWarning: struct integer overflow masking is deprecated
    self.z.close()
  /home/mg/src/mercurial-crew/mercurial/archival.py:169:
  DeprecationWarning: 'H' format requires 0 <= number <= 65535
    self.z.close()

when it is given such old timestamps. This fixes this by silently
clamping the date to 1980.
2010-09-20 15:33:39 +02:00
Patrick Mezard
4a10f62e93 archival: do not use repo.changelog directly 2010-08-26 23:38:13 +02:00
Martin Geisler
4d43304dcc archival: remove prefix argument from archivers
When the archivers work on the full we can reuse the same archiver
with different prefixes (for different subrepositories).
2010-07-14 20:25:31 +02:00
Martin Geisler
138130c348 archival: move commands.archive.guess_type to archival.guesskind
The list of suffixes for each kind of archive belongs in archival.
Renamed function to fit with out code style.
2010-07-14 20:25:31 +02:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Gilles Moris
15a6625324 archive: add branch and tag informations to the .hg_archival.txt file
Up to this changeset, only the repo (first node) and current node hash were
included. This adds also the named branch and tags.

So the additional lines to .hg_archival.txt are
branch: the named branch
tag: the global tags of this revision, one per line in case of multiple tags
latesttag: if the revision is untagged, the latest tag (most recent in
           ancestors), again one per line if this ancestor has multiple tags.
latestagdistance: the longest distance (changesets) to this latest ancestor.
2009-08-11 09:04:02 +02:00
Benoit Boissinot
125a85ec87 use new style classes 2009-06-10 15:10:21 +02:00
Martin Geisler
0a365d5ca2 use 'x is None' instead of 'x == None'
The built-in None object is a singleton and it is therefore safe to
compare memory addresses with is. It is also faster, how much depends
on the object being compared. For a simple type like str I get:

            | s = "foo" | s = None
  ----------+-----------+----------
  s == None | 0.25 usec | 0.21 usec
  s is None | 0.17 usec | 0.17 usec
2009-05-20 00:52:46 +02:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Peter van Dijk
f1e34ebcb9 fix disappearing symlinks [issue1509] 2009-02-15 11:14:20 -06:00
Martin Geisler
8c1d48c66f move % out of translatable strings
The translators need to see the raw format string, not the result of
using the format string.
2008-08-16 14:46:56 +02:00
Matt Mackall
dcacfb3161 manifest: remove execf/linkf methods 2008-06-26 14:35:50 -05:00
Matt Mackall
fbb5127472 use repo[changeid] to get a changectx 2008-06-26 14:35:46 -05:00
Thomas Arendsen Hein
75583cedf3 Remove trailing space 2008-04-08 18:40:11 +02:00
Dirkjan Ochtman
23bb4b3d3f python-2.6: deprecation of GzipFile.filename 2008-04-08 15:42:43 +02:00
Joel Rosdahl
5dae3059a0 Expand import * to allow Pyflakes to find problems 2008-03-06 22:23:26 +01:00
Thomas Arendsen Hein
da3b50be51 Add config option to disable putting .hg_archival.txt inside archives. 2008-02-28 22:39:59 +01:00
Thomas Arendsen Hein
347cc1cda8 merge with crew-stable 2008-02-05 15:59:10 +01:00
Dirkjan Ochtman
c185787ac3 cleanly abort on unknown archive type (issue966) 2008-02-05 15:54:42 +01:00
Shun-ichi GOTO
478c0b9176 Use util.normpath() instead of direct path string operation.
This change is intended to allow hooking normpath() by win32mbcs
extension for MBCS support.
2008-01-09 21:30:13 +09:00
Alexis S. L. Carvalho
563893de20 archive: delay extraction of file revisions
This allows us to look only at the filelogs we're interested in,
providing a nice speedup if we're archiving only part of a repository.
2007-07-19 19:43:25 -03:00
Alexis S. L. Carvalho
c2a8afba01 archive: add symlink support 2007-07-11 17:40:41 -03:00
Alexis S. L. Carvalho
ecefa1684a archive: use util.opener when archiving files.
This simplifies the code a bit and makes it easier to support symlinks.
2007-07-11 17:40:41 -03:00
csaba.henk@creo.hu
b3d7f22dba Fix tgz archival on Windows.
Making tgz's on Windows has been broken by 4183b5f64f62
due to not being careful enough about binary mode opens.
2007-06-27 08:35:26 -07:00
Matt Mackall
aff448fc36 archive: remove spurious flag_bits setting
This makes zip -T on resulting archives work. File permissions are
still retained.
2007-06-23 14:02:41 -05:00
csaba.henk@creo.hu
e069b7ea12 timestamp of gzip archives taken from changeset context 2007-06-11 19:09:01 +02:00
Brendan Cully
33f64bb34f Merge with crew-stable 2007-04-24 10:47:41 -07:00