Commit Graph

85 Commits

Author SHA1 Message Date
timeless
f77cdcd3b1 pycompat: switch to util.stringio for py3 compat 2016-04-10 20:55:37 +00:00
Martin von Zweigbergk
c84bb33a89 match: rename "narrowmatcher" to "subdirmatcher" (API)
I keep mistaking "narrowmatcher" for narrowhg's
narrowmatcher. "subdirmatcher" seems more to the point anyway.
2016-02-05 21:09:32 -08:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
timeless@mozdev.org
521ee1e86c archival: drop self.filename - deprecated in py2.6 2015-09-04 05:54:35 -04:00
Gregory Szorc
d30eb7e23d archival: use absolute_import 2015-08-07 19:47:49 -07:00
Matt Harbison
0d9eba99eb archive: use {changessincelatesttag} to build the metadata file
This isolates the current magic when dealing with wdir() and only().
2015-06-30 23:56:49 -04:00
Matt Mackall
b050378961 merge with stable 2015-07-01 16:33:31 -05:00
Matt Mackall
174e090e10 archive: fix changesincelatesttag with wdir() 2015-07-01 15:12:45 -05:00
Matt Mackall
2173cc3777 merge with stable 2015-06-29 16:38:22 -05:00
Matt Harbison
d4e8d4f13c archive: don't assume '.' is being archived for changessincelatesttag
Hardcoding '.' is wrong, and yielded strange results when archiving old
revisions.  For example, when archiving the cset that adds the signature to 3.4
(a4f6d198e7df), the resulting value was previously 51 (the number of commits on
stable between 3.4 and today), even though it was a direct descendant of a tag,
with a {latesttagdistance} of 2.  This still includes all other _ancestor_ paths
not included in {latesttag}.

Note that archiving wdir() currently blows up several lines above this when
building the 'base' variable.  Since wdir() isn't documented, ignore that it
needs work to handle wdir() here for now.
2015-06-25 21:16:47 -04:00
Gregory Szorc
3aa1c73868 global: mass rewrite to use modern octal syntax
Python 2.6 introduced a new octal syntax: "0oXXX", replacing "0XXX". The
old syntax is not recognized in Python 3 and will result in a parse
error.

Mass rewrite all instances of the old octal syntax to the new syntax.

This patch was generated by `2to3 -f numliterals -w -n .` and the diff
was selectively recorded to exclude changes to "<N>l" syntax conversion,
which will be handled separately.
2015-06-23 22:30:33 -07:00
Yuya Nishihara
7de01412a9 archive: look for first visible revision to build repo identity (issue4591)
No test for the case where all revisions are hidden because "archive" command
aborts if the target revision is null.
2015-04-08 23:30:02 +09:00
Yuya Nishihara
d2b9482bcd archive: extract metadata() closure to module-level function
This function will be reused in largefiles.
2015-04-08 22:37:03 +09:00
Yuya Nishihara
553dc1006c archive: use ctx object consistently to build meta data 2015-04-08 22:31:04 +09:00
Matt Harbison
abed66c145 archive: report the node as "{p1node}+" when archiving a dirty wdir()
This is more useful than reporting all 'f's, allowing the archive to be diffed
against a specific revision to see what changed.
2015-06-16 23:14:45 -04:00
Matt Harbison
0dc20be5d4 archive: support 'wdir()'
This is a step toward replacing the extdiff internals with archive, in order to
support 'extdiff -S'.  Only Mercurial subrepos are supported for now.

If a file is missing from the filesystem, it is silently skipped.  Perhaps it
should warn, but it cannot abort when working with extdiff because deleting a
file is a legitimate diff.
2015-06-16 23:06:57 -04:00
Matt Harbison
d3aeafb647 archive: change the default prefix to '' from None
All current callers supply some sort of prefix, so the issue was hidden.  But if
no parameter was specified, a crash occurred in the write() closure when
concatenating 'prefix' and 'name'.
2015-02-15 17:21:48 -05:00
Siddharth Agarwal
94be18d96c archive: store number of changes since latest tag as well
This is different from latesttagdistance in that while latesttagdistance is
defined to be the length of the longest path to the latest tag,
changessincelatesttag is the number of changes contained in @ that aren't
contained in the latest tag. So, if 't' is the latest tag in the repository
below:

      t
      |
      v
 --o--o----o
    \       \
     ..o..o..@

then latesttagdistance is 2, but changessincelatesttag is 4.

Note that changessincelatesttag is always greater than or equal to the
latesttagdistance -- that's because changessincelatesttag counts all the
changes in the longest path since the latest tag, and possibly others. This is
an important fact that we'll take advantage of in upcoming patches.
2014-12-12 15:27:13 -08:00
Matt Harbison
7624013ead subrepo: drop the 'ui' parameter to archive()
The current state of subrepo methods is to pass a 'ui' object to some methods,
which has the effect of overriding the subrepo configuration since it is the
root repo's 'ui' that is passed along as deep as there are subrepos.  Other
subrepo method are *not* passed the root 'ui', and instead delegate to their
repo object's 'ui'.  Even in the former case where the root 'ui' is available,
some methods are inconsistent in their use of both the root 'ui' and the local
repo's 'ui'.  (Consider hg._incoming() uses the root 'ui' for path expansion
and some status messages, but also calls bundlerepo.getremotechanges(), which
eventually calls discovery.findcommonincoming(), which calls
setdiscovery.findcommonheads(), which calls status() on the local repo 'ui'.)

This inconsistency with respect to the configured output level is probably
always hidden, because --verbose, --debug and --quiet, along with their 'ui.xxx'
equivalents in the global and user level hgrc files are propagated from the
parent repo to the subrepo via 'baseui'.  The 'ui.xxx' settings in the parent
repo hgrc file are not propagated, but that seems like an unusual thing to set
on a per repo config file.  Any 'ui.xxx' options changed by --config are also
not propagated, because they are set on repo.ui by dispatch.py, not repo.baseui.

The goal here is to cleanup the subrepo methods by dropping the 'ui' parameter,
which in turn prevents mixing subtly different 'ui' instances on a given subrepo
level.  Some methods use more than just the output level settings in 'ui' (add
for example ends up calling scmutil.checkportabilityalert() with both the root
and local repo's 'ui' at different points).  This series just goes for the low
hanging fruit and switches methods that only use the output level.

If we really care about not letting a subrepo config override the root repo's
output level, we can propagate the verbose, debug and quiet settings to the
subrepo in the same way 'ui.commitsubrepos' is in hgsubrepo.__init__.

Archive only uses the 'ui' object to call its progress() method, and gitsubrepo
calls status().
2014-12-13 14:53:46 -05:00
Augie Fackler
a5b17bd9d1 cleanup: use __builtins__.any instead of util.any
any() is available in all Python versions we support now.
2015-05-16 14:30:07 -04:00
Matt Harbison
9fe8bb732e archive: drop the leading '.' path component from the prefix (issue4634)
Unix utilities like tar will happily prefix the files it packs with './', but
annoyingly, Windows Explorer will not show these packed files when it opens the
archive.  Since there doesn't seem to be a point in including './' in the path
names, just drop it.  The default 'hg archive' prefix is the basename of the
archive, so specifying '.' allows for that default to be disabled completely.
2015-05-05 20:52:38 -04:00
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