Commit Graph

101 Commits

Author SHA1 Message Date
Matt Mackall
3da0ef53cd manifest: move pure parsing code out of pure
This lets us transition more smoothly.
2015-03-06 17:00:42 -06:00
Martin von Zweigbergk
199e845f93 copies: move code into new manifestdict.filesnotin() method
copies._computeforwardmissing() finds files in one context that is not
in the other. Let's move this code into a new method on manifestdict,
so m1.filesnotin(m2) can be optimized for various types of manifests
(we expect more types of manifests soon).
2015-02-27 13:57:37 -08:00
Martin von Zweigbergk
9bb31557ba manifest: rename 'mf', 'map', and 'mapping' to 'm'
We mostly call manifest variables 'm', so let's use that in
manifest.py too. This makes it clearer that the variables do, in fact,
contain manifestsdict instances and never a plain dict.
2015-02-24 09:08:54 -08:00
Martin von Zweigbergk
4233d16798 manifest: make copy logic local to copy()
The optional arguments to the manfifestdict constructor are only used
by copy(), so assign the fields from that method instead so it's clear
that the arguments are not used for anything else.
2015-02-23 13:41:02 -08:00
Durham Goode
6d7193bafa manifest: make lru size configurable
On machines with lots of ram, it's beneficial to increase the lru size of the
manifest cache.  On a large repo, configuring the lru to be size 10 can shave a
large rebase (~12 commits) down from 95s to 70s.
2015-01-23 17:06:03 -08:00
Augie Fackler
264b6aaf72 manifest: drop withflags() method, which is now unused 2015-01-07 15:55:02 -05:00
Augie Fackler
78c54eb4c7 manifest: add optional recording of clean entries to diff
This makes manifest slightly easier to use for status code.
2014-12-15 16:04:28 -05:00
Matt Mackall
0826b8e884 merge with stable 2014-12-18 16:41:59 -06:00
Augie Fackler
1a7f98d9da manifest: disallow setting the node id of an entry to None
manifest.diff() uses None as a special value to denote the absence of
a file, so setting a file node to None means you then can't trust
manifest.diff().

This should also make future manifest work slightly easier.
2014-12-12 13:40:44 -05:00
Martin von Zweigbergk
455810026c manifest: add matches() method
Move the code in context._manifestmatches() into a new
manifest.matches(). It's a natural place for the code to live and it
allows other callers to easily use it. It should also make it easier
to optimize the new method in alternative implementations of the
manifest (same reasoning as with manifest.diff()).
2014-10-22 21:38:30 -07:00
Martin von Zweigbergk
9f2b4a3510 manifest: transpose pair of pairs from diff()
It makes more sense for the file nodeids and returned from diff() to
be ((n1,fl1),(n2,fl2)) than ((n1,n2),(fl1,fl2)), so change it to the
former.
2014-10-14 23:18:07 -07:00
Martin von Zweigbergk
a7638ac991 manifest: for diff(), only iterate over files, not flags
From manifest.diff(), we return a dict from filename to pairs of pairs
of file nodeids and flags (values of the form ((n1,n2),(fl1,fl2))). To
create this dict, we currently generate one dict for files (with
(n1,n2) values) and one for flags (with (fl1,fl2) values) and then
join these dicts. Missing files are represented by None and missing
flags by '', but due to the dict joining, the inner pairs themselves
can also be None. The only caller, merge.manifestmerge(), then unpacks
these values while checking for None values.

By inlining the calls to dicthelpers and simplifying it to only
iterate over files (ignoring flags-only differences), we can simplify
life for our caller.
2014-10-14 22:48:44 -07:00
Martin von Zweigbergk
3ccf5a82f8 manifest: repurpose flagsdiff() into (node-and-flag)diff()
The manifestdict class already has a method for diff flags between two
manifests (presumably because there is no full access to the private
_flags field). The only caller is merge.manifestmerge(), which also
wants a diff of files between the same manifests. Let's combine the
code for diffing files and flags into a single method on
manifestdict. This puts all the manifest diffing in one place and will
allow for further simplification. It might also be useful for it to be
encapsulated in manifestdict if we later decide to to shard
manifests. The docstring is intentionally unclear about missing
entries for now.
2014-10-14 17:09:16 -07:00
Augie Fackler
351b53f5d8 manifest: add docstring to text() method 2014-10-14 14:42:25 -04:00
Augie Fackler
9afa9a909c manifest: rename ambiguously-named set to setflag
Just makes it a little clearer what this method does.
2014-10-10 14:09:37 -04:00
Augie Fackler
d6a88c8e25 manifest: add fastdelta method to manifestdict
This is another step closer to alternate manifest implementations that
can offer different hashing algorithms.
2014-10-08 15:20:14 -04:00
Augie Fackler
6e25316a67 manifest: move _search to module level and rename to _msearch
The rename is intended to provide a slight hint that it is
manifest-specific.
2014-10-08 15:21:59 -04:00
Augie Fackler
6d53ff9d24 manifest: move manifestdict-to-text encoding to manifest class
A future patch will introduce a new format, with a new class.
2014-10-08 14:47:30 -04:00
Augie Fackler
541b5c0392 manifest: rearrange add() method and add comments for clarity
Omit the check of bool(p1) since it's always true in practice: it will
either be nullid or some valid manifest sha, and we know nullid won't
ever be in the cache so we can simplify understanding of this code.
2014-10-08 12:59:11 -04:00
Augie Fackler
d3360906bf manifest: simplify manifest.add() by making args required
I verified that changed was never false (it was always a 2-tuple) by
adding

@@ -220,6 +225,8 @@ class manifest(revlog.revlog):

     def add(self, map, transaction, link, p1=None, p2=None,
             changed=None):
+        if not changed:
+            assert False, 'changed was %r' % changed
         # if we're using the cache, make sure it is valid and
         # parented by the same node we're diffing against
         if not (changed and p1 and (p1 in self._mancache)):

and observing that the test suite still passed. Making all the
arguments required should help future readers understand what's going
on here.
2014-10-08 11:52:30 -04:00
Augie Fackler
43d13e71a7 manifest: move manifest parsing to module-level
We'll need this in the sharded manifest hashing routine, and I need to
tweak it anyway, so make it module-level now.
2014-09-25 14:13:31 -04:00
Augie Fackler
1a68be1d21 manifest: mark addlistdelta and checkforbidden as module-private 2014-09-11 10:14:34 -04:00
Augie Fackler
e5850be295 manifest: move addlistdelta to module-level
Again, there's no reason for this to be inside manifest.add, so we'll
define it only once.
2014-08-07 12:47:20 -04:00
Augie Fackler
7d3a829f20 manifest: move checkforbidden to module-level
There's no need for this function to be nested, so let's just define
it once instead of every time manifest.add() gets called.
2014-08-07 09:46:05 -04:00
Siddharth Agarwal
021a1bd81c manifestdict: add a new method to intersect with a set of files
This is meant to be used when the set of files is known in advance, e.g. with a
match object with no patterns.
2014-07-12 17:57:25 -07:00
Durham Goode
01ed192faf manifest: increase lrucache from 3 to 4
During a commit amend there are 4 manifests being handled:

- original commit
- temporary commit
- amended commit
- merge base

This causes a manifest cache miss which hurts perf on large repos. On a large
repo, this fix causes amend to go from 6 seconds to 5.5 seconds.
2013-11-11 16:35:12 -08:00
Siddharth Agarwal
81b84a1325 manifestdict: add a method to diff _flags
This will be used in an upcoming patch.
2013-03-24 17:17:38 -07:00
Siddharth Agarwal
d7fd97bac5 manifest: use a size 3 LRU cache to store parsed manifests
Previously, the manifest cache would store the last manifest parsed. We could
run into situations with operations like update where we would try parsing the
manifest for a revision r1, then r2, then r1 again. This increases the cache
size to 3 to avoid that bit of performance fragility.
2013-02-09 15:43:02 +00:00
Durham Goode
d2d598be6c commit: increase perf by building a new addlist instead of editing the old one
When commiting to a repo with lots of files (>170000),
manifest.py:addlistdelta takes some time because it's editing a large
array many times. Changing it to build a new array instead of editing
the old one saves around 0.04 seconds on a 1.64 second commit. A 2.5%
gain.

The gain here is pretty minor, but it was blatantly at the top of the
profiler report and the fix is straight forward.

I tested it by comparing the arrays produced by the new and old logic
while running all of the tests.
2012-11-19 16:05:40 -08:00
Mads Kiilerich
5e3dc3e383 avoid using abbreviations that look like spelling errors 2012-08-27 23:14:27 +02:00
Mads Kiilerich
520076e707 delete some dead comments and docstrings 2012-08-21 02:41:20 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Jesse Glick
a1ec63bdbc localrepo: optimize internode status calls using withflags
Introduce manifestdict.withflags() to get a set of all files which have any
flags set, since these are likely to be a minority. Otherwise checking .flags()
for every file is a lot of dictionary lookups and is quite slow.
2012-05-04 15:56:45 -04:00
Matt Mackall
9f8ee10163 util: don't mess with builtins to emulate buffer() 2011-12-15 15:27:11 -06:00
Martin Geisler
213ba1f97d manifest: use "\0" instead of "\000"
Though both give the same result (a NUL byte), I found that I tend to
read "\000" as "\0" + "00", which is something completely different.

I did not change the occurance of "\000" in archival.py since there
are other octal constants in that file.
2011-06-16 08:49:26 +02:00
Sune Foldager
750dcd7b48 revlog: compute correct deltaparent in the deltaparent function
It now returns nullrev for chain base revisions, since they are conceptually
deltas against nullrev. The revdiff function was updated accordingly.
2011-05-05 18:05:24 +02:00
Matt Mackall
5be0491c06 manifest: add readfast method 2011-03-20 19:43:28 -05:00
Martin Geisler
6a3d9310ab code style: prefer 'is' and 'is not' tests with singletons 2010-11-22 18:15:58 +01:00
Benoit Boissinot
70194e7582 deltaparent(): don't return nullrev for a revision containing a full snapshot
this allows us to simplify manifest.readdelta and revlog.revdiff
2010-08-21 19:30:42 +02:00
Benoit Boissinot
cbd0c9fbc1 revlog._addrevision(): make the parent of the cached delta explicit 2010-08-18 19:45:52 +02:00
Pradeepkumar Gayam
fb9106e388 manifest: correct readdelta() according to parentdeltas 2010-08-10 22:28:52 +05:30
Renato Cunha
5790eb1140 manifest: removed usage of the global cmp function
Py3k doesn't have a global cmp() function, making this call problematic in the
py3k port. Also, calling cmp() here is not necessary, since we only want to
know if the two values are equal. A check for equality perfect in this case and
this patch does that.
2010-08-07 16:12:51 -03: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
Benoit Boissinot
a98dab4110 manifest/revlog: do not let the revlog cache mutable objects
If a buffer of an mutable object is passed to revlog.addrevision(), the revlog
will happily store it in its cache. Later when the revlog reuses the cached
entry, if the manifest modified the object in-between, all kind of bugs
appears.

We fix it by:
- passing immutable objects to addrevision() if they are already available
- only storing the text in the cache if it's of str type

Then we can remove the conversion of the cache entry to str() during
retrieval. That was probably just there hiding the bug for the common cases
but not really fixing it.
2009-09-04 10:47:55 +02:00
Benoit Boissinot
68e9caf50f manifestdict: remove unnecessary dictionary copy
No need to copy the dict, dict.__init__() will do that for us.
It was responsible for a non-negligeable waste of time during a qpush of an
-mm queue on the kernel repo.
2009-09-03 02:42:56 +02:00
Benoit Boissinot
1b0af4b591 manifest.add(): cleanup worklist construction and iteration 2009-09-02 21:05:43 +02:00
Benoit Boissinot
ef4ae33a57 manifest: simplify cache handling, use a unique cache 2009-09-02 21:05:01 +02:00
Benoit Boissinot
79eb77ecc4 manifest.add(): simplify with iterators and generator expressions 2009-09-02 20:18:35 +02:00
Peter Arrenbrecht
a75765cf7f drop unused imports 2009-05-14 15:35:46 +02:00