Commit Graph

18595 Commits

Author SHA1 Message Date
Stanislau Hlebik
aa25365b25 copies: rename m2 to mdst
Small refactoring to rename m2 to more clearer mdst.
2017-05-29 05:52:15 -07:00
Stanislau Hlebik
219c6a051d copies: rename m1 to msrc
Small refactoring that renames `m1` parameter name to a more clearer name
`msrc`.
2017-05-29 05:52:15 -07:00
Gregory Szorc
90a75c9c65 transaction: delete callbacks after use
Before this change, localrepository instances that performed multiple
transactions would leak transaction objects. This could occur when
running `hg convert`. When running `hg convert`, the leak would be
~90 MB per 10,000 changesets as measured with the Mercurial repo itself.

The leak I tracked down involved the "validate" closure from
localrepository.transaction(). It appeared to be keeping a
reference to the original transaction via __closure__. __del__
semantics and a circular reference involving the repo object
may have also come into play.

Attempting to refactor the "validate" closure proved to be
difficult because the "tr" reference in that closure may
reference an object that isn't created until transaction.__init__
is called. And the "validate" closure is passed as an argument to
transaction.__init__. Plus there is a giant warning comment in
"validate" about how hacky it is. I did not want to venture into
the dragon den.

Anyway, we've had problems with transactions causing leaks before.
The solution then (8b23c334b97f) is the same as the solution in this
patch: drop references to callbacks after they are called. This
not only breaks cycles in core Mercurial but can help break cycles
in extensions that accidentally introduce them.

While I only tracked down a leak due to self.validator, since this is
the 2nd time I've tracked down leaks due to transaction callbacks I
figure enough is enough and we should prevent the class of leak from
occurring regardless of the variable. That's why all callback variables
are now nuked.
2017-05-26 13:27:21 -07:00
Martin von Zweigbergk
a00e1e8b0a match: remove special-casing of always-matching patterns in patternmatcher
This moves the optimization for patterns that match everything to the
caller, so we can remove it from patternmatcher.

Note that we need to teach alwaysmatcher to use relative paths now in
cases like "hg files .." from inside mercurial/, because while it
still matches everything, paths should be printed relative to the
working directory.
2017-05-19 13:16:15 -07:00
Martin von Zweigbergk
40160c59ed match: move normalize() call out of matcher constructors
By passing in the result of the normalize() call, we prepare for
moving the special handling of patterns that always match out of the
patternmatcher.

It also lets us remove many of the arguments from the matcher, because
they were passed only the the normalize function (we could have
removed the arguments by binding them to the function instead of
moving the normalize() call out).
2017-05-19 12:47:45 -07:00
Martin von Zweigbergk
cc35e8cc47 match: drop support for empty pattern list in patternmatcher
Since the caller now deals with empty pattern lists, we can drop that
support in the patternmatcher. It now gets the more logical behavior
of matching nothing when no patterns are given (although there is no
in-core caller that will pass no patterns).
2017-05-19 11:58:16 -07:00
Martin von Zweigbergk
b0d04b4dc4 match: optimize visitdir() for when no explicit files are listed
In patternmatcher, we used to say that all directories should be
visited if no explicit files were listed, because the case of empty
_files usually implied that no patterns were given (which in turns
meant that everything should match). However, this made e.g. "hg files
-r .  rootfilesin:."  slower than necessary, because that also ended
up with an empty list in _files. Now that patternmatcher does not
handle includes, the only remaining case where its _files/_fileset
fields will be empty is when it's matching everything. We can
therefore treat the always-case specially and stop treating the empty
_files case specially. This makes the case mentioned above faster on
treemanifest repos.
2017-05-20 23:49:14 -07:00
Martin von Zweigbergk
57f17ff9f2 match: handle everything-matching using new alwaysmatcher
Having a special matcher that always matches seems to make more sense
than making one of the other matchers handle the case. For now, we
just use this new matcher when no patterns were provided.
2017-05-19 11:50:01 -07:00
Martin von Zweigbergk
e63330c2d2 match: add __repr__ for subdirmatcher
Should at least be useful for debugging. Would matter for correctness
too if fsmonitor or Facebook's sparse extension worked with subrepos
(which I don't know if they do).
2017-05-26 13:08:30 -07:00
Augie Fackler
47e0320f8b cleanup: rename all iteritems methods to items and add iteritems alias
Due to a quirk of our module importer setup on Python 3, all calls and
definitions of methods named iteritems() get rewritten at import
time. Unfortunately, this means there's not a good portable way to
access these methods from non-module-loader'ed code like our unit
tests. This change fixes that, which also unblocks test-manifest.py
from passing under Python 3.

We don't presently define any itervalues methods, or we'd need to give
those similar treatment.
2017-05-29 00:00:02 -04:00
Augie Fackler
4e659930fc help: work around textwrap.dedent() only working on strings 2017-05-28 15:51:07 -04:00
Augie Fackler
ac1808c4a0 server: write out pid using bytes IO instead of str IO 2017-05-28 15:43:06 -04:00
Augie Fackler
dad740cf16 help: convert dict to strkwargs 2017-05-28 13:28:41 -04:00
Augie Fackler
2f5077fef1 util: use sysstr.join instead of bytes.join in textwrap wrapper 2017-05-28 13:42:16 -04:00
Yuya Nishihara
477ffb0437 match: define exactmatcher.matchfn statically
This should eliminate the reference cycle, self.matchfn -> self.exact -> self.
2017-05-28 23:54:31 +09:00
Yuya Nishihara
b7251d7b93 match: remove override of prefix() from differencematcher
It's exactly the same as basematcher.prefix().
2017-05-28 23:51:30 +09:00
Yuya Nishihara
4a4dca2dbc cat: do not start pager if output will be written to file 2017-05-27 18:52:46 +09:00
Yuya Nishihara
1d54e26edc cat: pass filename template as explicit argument
I'll move the handling of the '-' filename to commands.cat().
2017-05-27 18:50:05 +09:00
Yuya Nishihara
3070054965 cmdutil: extract function checking if pattern should be taken as stdin/out
This will be used in commands.cat().
2017-05-25 21:28:08 +09:00
Yuya Nishihara
c171e2c0bc cmdutil: drop deprecated hack to pass file object to makefileobj() (API)
All callers pass a string 'pat' or None.
2017-05-25 21:25:49 +09:00
Yuya Nishihara
97a0e41896 encoding: make sure "wide" variable never be referenced from other modules
Better to not expose (maybe-) unicode objects.
2017-05-29 21:57:51 +09:00
Augie Fackler
cdf974c00c manifest: use itertools.chain() instead of + for Python 3 compat
This is all pure-Python code, so I'm not too worried about perf here,
but we can come back and fix it should it be a problem.

With this change, the manifest code passes most unit tests on Python 3
(once the tests are corrected with many b prefixes. I've got a little
more to sort out there and then I'll mail that change too.
2017-05-28 21:29:58 -04:00
Augie Fackler
83192b065a manifest: fix some pure-Python parser bits to work on Python 3 2017-05-28 21:29:15 -04:00
Augie Fackler
e49ffa58a6 server: use pycompat to get argv 2017-05-28 15:43:26 -04:00
Augie Fackler
0d4ce4ae60 encoding: make wide character class list a sysstr
That's what east_asian_width returns, so just match it.
2017-05-28 13:27:29 -04:00
Augie Fackler
fa101cc823 cmdutil: use sorted(dict) instead of x = dict.keys(); x.sort()
The former both does less work and has the virtue of working on Python 3.
2017-05-28 14:02:14 -04:00
Augie Fackler
544ce9f54d util: look for empty-sysstr instead of empty-bytesstr in textwrap code
Fixes behavior on Python 3.
2017-05-28 16:17:43 -04:00
Augie Fackler
a2d8d347df minirst: look for column delimiters using slices instead of indicies
This works on both Python 2 and 3.
2017-05-28 15:47:43 -04:00
Augie Fackler
daa802d908 minirst: grab a byte, not an int, for the underline style 2017-05-28 13:36:02 -04:00
Augie Fackler
6fdf576b44 minirst: use bytes.strip instead of str.strip 2017-05-28 13:41:42 -04:00
Pulkit Goyal
9b6f1eb5d7 py3: use pycompat.bytestr so that we don't get ascii values
This fixes `hg files 'set:(**.py)'` which makes test-check-py3-compat.t able to
run on Python 3. So if you now do `python3 ./run-tests.py
test-check-py3-compat`, the test will actually run.
2017-05-29 16:21:15 +05:30
Augie Fackler
9b41371db4 loader: pywatchman appears to already be py3 compatible
Our loader was doing some confusing things in pywatchman, but it looks
like we shouldn't be using it there anyway.
2017-05-28 15:45:47 -04:00
Jun Wu
f7e72658ec context: do not cache manifestctx
This will make sure when ctx.repo.manifestlog changes, a correct new
manifestctx is returned. repo.manifestlog takes care of caching so the
manifestctx won't be reconstructed every time.
2017-05-25 17:20:43 -07:00
Pierre-Yves David
b594eddde5 debugbundle: display the content of obsmarkers parts
We parse and display the markers in the part when possible.
2017-05-25 16:50:46 +02:00
Pierre-Yves David
8873a232c1 bundle: add an experimental knob to include obsmarkers in bundle
The "hg bundle" command is a good place to test if the inclusion of obsmarkers
within a bundle is working well (part exists, content is correct etc). So we
add a way to have them included.

Ideally, this would be controlled by a change around bundlespec (bundlespec
"v3" + arguments). However, my main goal is to have obsmarkers included in
bundle created by the 'hg strip' command, not the 'hg bundle' so for now I'm
avoiding the detour through bundlespec rework territory.

Better debug output for obsmarkers in 'debugbundle' will be added in later
changesets. The 'test-obsolete-bundle-strip.t' test will also get updated in a
later changeset to keep the current changeset smaller.
2017-05-28 11:50:43 -07:00
Pierre-Yves David
ffd8983573 bundle2: move function building obsmarker-part in the bundle2 module
We move it next to similar part building functions. We will need it for the
"writenewbundle" logic. This will allow us to easily include obsmarkers in
on-disk bundle, a necessary step before having `hg strip` also operate on
markers.

(Yes, the bundle2 module was already too large, but there any many
interdependencies between its components so it is non-trivial to split, this is
a quest for another adventure.)
2017-05-28 11:48:18 -07:00
Yuya Nishihara
c52484bc8a policy: remove unused policynoc and policynocffi constants 2017-05-02 21:45:48 +09:00
Yuya Nishihara
ec67ed9553 cffi: remove superfluous "if True" blocks 2017-05-02 21:45:10 +09:00
Yuya Nishihara
720bf3b0d8 cffi: split modules from pure
The copyright lines are updated per change history.

cffi/osutil.py isn't tested since I have no access to OS X machine right now,
sorry.
2017-05-02 21:15:31 +09:00
Yuya Nishihara
9fb4289a5c policy: extend API version checks for cffi
This is just a stub for future extension. I could add a version constant to
CFFI modules by putting it to both ffi.set_source() and ffi.cdef(), but that
doesn't seem right. So for now, cffi modules will be explicitly unversioned
(i.e. version constant must be undefined or set to None.) We can revisit it
later when we need to consider CFFI support more seriously.
2017-05-28 15:45:52 +09:00
Yuya Nishihara
fa3c51ef73 cffi: put compiled modules into mercurial.cffi package
Don't pollute the top-level namespace.
2017-05-02 21:08:38 +09:00
Yuya Nishihara
5cccfd11fb cffi: rename build scripts
This frees up cffi package for modules to be split from pure.
2017-05-02 21:04:40 +09:00
Martin von Zweigbergk
882acf90e8 match: remove support for includes from patternmatcher
Includes (and excludes) are now delegated to the includematcher.
2017-05-19 11:44:05 -07:00
Martin von Zweigbergk
19566696b9 match: simplify includematcher a bit
The "include" we have in symbols is redundant and the double negative
in visitdir() can be removed.
2017-05-22 23:31:15 -07:00
Martin von Zweigbergk
66dd6b9e1c match: remove support for non-include patterns from includematcher
The includematcher will always get at least one include pattern and
will never get any non-include patterns, so we can remove most of the
code in it. This patch does mostly straight-forward deletions of
code. We will clean up further later.
2017-05-19 13:36:34 -07:00
Martin von Zweigbergk
1ba59afc49 match: split up main matcher into patternmatcher and includematcher
At this point the includematcher is an exact copy of the main matcher
class. We will specialize and simplify both classes in the following
patches. This initial unmodified copy is just to make the differences
clearer. We also rename the main matcher to "patternmatcher" for
consistency.

I may eventually merge this new includematcher back into the main
matcher, but I think doing it this way makes the intermediate steps
clearer regardless.
2017-05-19 22:36:14 -07:00
Martin von Zweigbergk
ce94f073cb match: remove support for exact matching from main matcher class
Exact matching is now handled by the exactmatcher class.

We can safely remove _files from the __repr__() implementation,
because even though the field is set, the patternspat field is enough
for the representation to be unambiguous (which was not the case when
the matcher could handle exact matches).
2017-05-18 23:39:39 -07:00
Martin von Zweigbergk
6cc2daf5d6 match: handle exact matching using new exactmatcher 2017-05-17 09:26:15 -07:00
Martin von Zweigbergk
5e8aba2103 merge: use intersectmatchers() in "m2-vs-ma optimization"
It doesn't seem like this can actually happen, but seems like cleaner
anyway.
2017-05-12 16:33:33 -07:00
Martin von Zweigbergk
7767620115 match: handle includes using new intersectionmatcher 2017-05-12 23:12:05 -07:00