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.
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.
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.
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
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.
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.
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.
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