Commit Graph

54 Commits

Author SHA1 Message Date
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
Brendan Cully
c779d79c71 Work around python 2.5.1 tarfile regression 2007-04-24 10:44:13 -07:00
Matt Mackall
8ed93098b6 replace filehandle version of wwrite with wwritedata 2006-12-29 20:04:31 -06:00
Benoit Boissinot
56d04add11 archival.py: use contexts 2006-12-26 00:40:28 +01:00
Matt Mackall
296d6a7cb8 Simplify i18n imports 2006-12-14 20:25:19 -06:00
Matt Mackall
f17a4e1934 Replace demandload with new demandimport 2006-12-13 13:27:09 -06:00
Thomas Arendsen Hein
d5d0b90730 Fixed directory name having an extra dot on "hg archive -t tbz2 foo.tbz2".
Problem reported by Rob Landley.
2006-11-02 19:23:55 +01:00
Alexis S. L. Carvalho
219803f060 Fix some bugs introduced during the manifest refactoring 2006-08-12 08:53:23 -03:00
Matt Mackall
44b96c96eb Change remaining users of manifest flags 2006-08-11 10:57:42 -05:00
Matt Mackall
4e6cb39019 Start using manifestflags methods 2006-07-16 03:14:17 -05:00
Vadim Gelfer
b2be07e448 use commit time as mtime for file archives.
now output from two run of "hg archive -t zip" is same.
2006-06-21 15:31:23 -07:00