Commit Graph

19 Commits

Author SHA1 Message Date
Pulkit Goyal
3a8bb7b3ef tests: make test-manifest use absolute_import 2016-04-16 03:08:16 +05:30
timeless
ebb1d48658 cleanup: remove superfluous space after space after equals (python) 2015-12-31 08:16:59 +00:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Drew Gottlieb
503f226d39 test-manifest: add some test coverage for treemanifest
Similar to the testmanifest test case, testtreemanifest extends the base test
case but uses treemanifests instead of manifestdicts. Adding this test provides
some basic test coverage of treemanifest within the standard test suite.
2015-04-07 15:16:19 -07:00
Drew Gottlieb
923e5328ab test-manifest: make manifesttest a base class that is extended
The implementation of the testmanifest test case is moved to a new base class,
which is then extended to make the testmanifest. And instead of testmanifest,
the subclass is named testmanifestdict because, well, that's what it's testing.

This refactoring makes it possible to create alternate versions of what was
formerly testmanifest, improving test coverage of different manifestdict
implementations.
2015-04-07 15:16:19 -07:00
Drew Gottlieb
575a958d63 test-manifest: move parsemanifest() to be a testmanifest class method
This refactoring lets testmanifest subclasses override this method to
return different manifestdict implementations, such as treemanifest.

It is useful for later commits where the testmanifest class is moved into a
base class, and test cases that extend the base class can provide their own
parsemanifest() implementation.
2015-04-07 15:16:19 -07:00
Martin von Zweigbergk
ebd2a39ab3 manifestv2: add support for writing new manifest format
If .hg/requires has 'manifestv2', the manifest will be written using
the new format.
2015-03-31 14:01:33 -07:00
Martin von Zweigbergk
c5433d6da0 manifestv2: add support for reading new manifest format
The new manifest format is designed to be smaller, in particular to
produce smaller deltas. It stores hashes in binary and puts the hash
on a new line (for smaller deltas). It also uses stem compression to
save space for long paths. The format has room for metadata, but
that's there only for future-proofing. The parser thus accepts any
metadata and throws it away. For more information, see
http://mercurial.selenic.com/wiki/ManifestV2Plan.

The current manifest format doesn't allow an empty filename, so we use
an empty filename on the first line to tell a manifest of the new
format from the old. Since we still never write manifests in the new
format, the added code is unused, but it is tested by
test-manifest.py.
2015-03-27 22:26:41 -07:00
Martin von Zweigbergk
e12d2d5528 test-manifest: extract constants for binary hashes
The binary hashes are used quite frequently, so let's extract
constants for them so we don't have to repeat binascii.unhexlify() so
often.
2015-03-31 15:06:55 -07:00
Martin von Zweigbergk
578f7b252d test-manifest: create constant for empty manifest
For symmetry with manifest v2, once we add that, let's extract a
constant for the empty v1 manifest.
2015-03-31 14:46:05 -07:00
Drew Gottlieb
f6dc5a186e manifest: add some tests for manifest.matches()
There were no tests for the various code paths in manifestdict.matches(), so I
added some. This also adds a more complex testing manifest so that any bugs
relating to traversal of directories are more likely to be caught.
2015-03-30 11:58:39 -07:00
Drew Gottlieb
d2ab66f723 manifest: make manifest.intersectfiles() internal
manifest.intersectfiles() is just a utility used by manifest.matches(), and
a future commit removes intersectfiles for treemanifest for optimization
purposes.

This commit makes the intersectfiles methods on manifestdict and treemanifest
internal, and converts its test to a more generic testMatches(), which has the
exact same coverage.
2015-03-30 10:43:52 -07:00
Martin von Zweigbergk
f6215c3b43 test-manifest.py: don't test .text() with present node suffix
When m.text() is called after setting a nodeid with a suffix (such as
'+'), manifestdict uses the suffix-less nodeid for the text, while
treemanifest includes the suffix. It would perhaps make most sense to
raise an exception so the bug is found, but since the two
implementations behave differently, let's just not test the behavior
for now.
2015-03-25 17:18:48 -07:00
Martin von Zweigbergk
0bb02e37be test-manifest.py: rewrite tests in terms of manifestdict
By rewriting test-manifest.py in terms of manifestdict instead of
_lazymanifest, the tests can be run on treemanifests too. There are
still a few tests that fail on treemanifests. They will be addressed
in the next few patches.
2015-03-25 14:13:46 -07:00
Martin von Zweigbergk
a8758e2b6a test-manifest.py: separate out test for double-free after copy()
The test that we don't double-free anything after creating a copy is
currently mixed with the __setitem__ test. Let's separate them.
2015-03-25 14:21:34 -07:00
Martin von Zweigbergk
ce0723ee16 lazymanifest: make __iter__ generate filenames, not 3-tuples
The _lazymanifest type(s) behave very much like a sorted dict with
filenames as keys and (nodeid, flags) as values. It therefore seems
surprising that its __iter__ generates 3-tuples of (path, nodeid,
flags). Let's make it match dict's behavior of generating the keys
instead, and add a new iterentries method for the 3-tuples. With this
change, the "x" in "if x in lm" and "for x in lm" now have the same
type (a filename string).
2015-03-12 18:18:29 -07:00
Augie Fackler
608c4b91f7 lazymanifest: use a binary search to do an insertion
This makes insertions log(n) plus some memmove() overhead, rather than
doing an append followed by an n*log(n) sort. There's probably a lot
of performance to be gained by adding a batch-add method, which could
be smarter about the memmove()s performed.

Includes a couple of extra tests that should help prevent bugs.

Thanks to Martin for some significant pre-mail cleanup of this change.
2015-01-30 21:30:40 -08:00
Augie Fackler
d1ec34adfe manifest: split manifestdict into high-level and low-level logic
The low-level logic type (_lazymanifest) matches the behavior of the C
implementation introduced in a5f1bccd. A future patch will use that
when available.
2015-03-07 12:04:39 -05:00
Augie Fackler
b619fe8004 manifest.c: new extension code to lazily parse manifests
This lets us iterate manifests in order, but do a _lot_ less work in
the common case when we only care about a few manifest entries.

Many thanks to Mike Edgar for reviewing this in advance of it going
out to the list, which caught many things I missed.

This version of the patch includes C89 fixes from Sean Farley and
many correctness/efficiency cleanups from Martin von
Zweigbergk. Thanks to both!
2015-01-13 14:31:38 -08:00