Commit Graph

29583 Commits

Author SHA1 Message Date
Gábor Stefanik
71039079d7 revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
v2: fixes from review
2016-08-18 17:25:10 +02:00
Matt Mackall
f6bd7a4c39 coal: use inheritance to derive from paper
This illustrates how much simpler this approach is, in particular the
effect of map-relative paths.
2016-08-17 13:43:13 -05:00
Matt Mackall
60e14951ba templater: add inheritance support to style maps
We can now specify a base map file:

__base__ = path/to/map/file

That map file will be read and used to populate unset elements of the
current map. Unlike using %include, elements in the inherited class
will be read relative to that path.

This makes it much easier to make custom local tweaks to a style.
2016-08-17 13:40:27 -05:00
Yuya Nishihara
a6fdd0b148 killdaemons: prevent killing all user processes by bad pid file
When I was fixing the test-gpg issue, I noticed gpg-connect-agent could print
"-1" as a server pid if command was wrong. I'm not pretty sure but nobody
would want to kill their running applications by mistake.
2016-08-18 18:43:48 +09:00
Yuya Nishihara
a869725d2d py3: automatically glob out line numbers from check-py3-compat output
It was boring task to update the result manually.
2016-08-17 20:56:12 +09:00
Yuya Nishihara
41507deea4 py3: have check-py3-compat require pygments to get stable result 2016-08-17 20:52:50 +09:00
Pierre-Yves David
7775b9bfe7 computeoutgoing: move the function from 'changegroup' to 'exchange'
Now that all users are in exchange, we can safely move the code in the
'exchange' module. This function is really about processing the argument of a
'getbundle' call, so it even makes senses to do so.
2016-08-09 17:06:35 +02:00
Pierre-Yves David
1b40b7e1c5 getchangegroup: take an 'outgoing' object as argument (API)
There is various version of this function that differ mostly by the way they
define the bundled set. The flexibility is now available in the outgoing object
itself so we move the complexity into the caller themself. This will allow use
to remove a good share of the similar function to obtains a changegroup in the
'changegroup.py' module.

An important side effect is that we stop calling 'computeoutgoing' in
'getchangegroup'. This is fine as code that needs such argument processing
is actually going through the 'exchange' module which already all this function
itself.
2016-08-09 17:00:38 +02:00
Pierre-Yves David
cca37f1814 outgoing: add a 'missingroots' argument
This argument can be used instead of 'commonheads' to determine the 'outgoing'
set. We remove the outgoingbetween function as its role can now be handled by
'outgoing' itself.

I've thought of using an external function instead of making the constructor
more complicated. However, there is low hanging fruit to improve the current
code flow by storing some side products of the processing of 'missingroots'. So
in my opinion it make senses to add all this to the class.
2016-08-09 22:31:38 +02:00
Pierre-Yves David
a9e69178e3 outgoing: adds some default value for argument
We are about to introduce a third option to create an outgoing object:
'missingroots'. This argument will be mutually exclusive with 'commonheads' so
we implement some default value handling in preparation.

This will also help use to make more use of outgoing creation around the code
base.
2016-08-09 15:55:44 +02:00
Pierre-Yves David
f460bb8823 outgoing: pass a repo object to the constructor
We are to introduce more code constructing such object in the code base. It will
be more convenient to pass a repository object, all current users already
operate at the repository level anyway. More changes to the contructor argument
are coming in later changeset.
2016-08-09 15:26:53 +02:00
Hannes Oldenburg
cca2fb75c5 match: remove matchessubrepo method (API)
Since it is no more used in cmdutil.{files,remove} and scmutil.addremove
we remove this method.
2016-08-16 08:21:16 +00:00
Hannes Oldenburg
38a18d3489 subrepo: cleanup of subrepo filematcher logic
Previously in the worst case we iterated the files in matcher twice and
had a method only for this, which reimplemented logic in subdirmatchers
constructor. So we replaced the method with a subdirmatcher.files() call.
2016-08-16 08:15:12 +00:00
Yuya Nishihara
69789d265a pycompat: delay loading modules registered to stub
Replacement _pycompatstub designed to be compatible with our demandimporter.
try-except is replaced by version comparison because ImportError will no longer
be raised immediately.
2016-08-14 14:46:24 +09:00
Yuya Nishihara
12eca1889e py3: import builtin wrappers automagically by code transformer
This should be less invasive than mucking builtins.

Since tokenize.untokenize() looks start/end positions of tokens, we calculates
them from the NEWLINE token of the future import.
2016-08-16 12:35:15 +09:00
Yuya Nishihara
29c5e8dc21 py3: provide (del|get|has|set)attr wrappers that accepts bytes
These functions will be imported automagically by our code transformer.

getattr() and setattr() are widely used in our code. We wouldn't probably
want to rewrite every single call of getattr/setattr. delattr() and hasattr()
aren't that important, but they are functions of the same kind.
2016-08-14 12:51:21 +09:00
Yuya Nishihara
df4c2c74a3 py3: check python version to enable builtins hack
Future patches will add (del|get|has|set)attr wrappers.
2016-08-14 12:44:13 +09:00
Yuya Nishihara
1532480b48 py3: move xrange alias next to import lines
Builtin functions should be available in compatibility code.
2016-08-14 12:41:54 +09:00
Yuya Nishihara
065c8a0e60 check-code: allow assignment to hasattr variable 2016-08-16 17:15:54 +09:00
Yuya Nishihara
7105924c83 debugobsolete: add formatter support (issue5134)
It appears that computing index isn't cheap if --rev is specified. That's
why "index" field is available only if --index is specified.

I've named marker.flags() as "flag" because "flags" implies a list or dict
in template world.

Thanks to Piotr Listkiewicz for the initial implementation of this patch.
2016-08-15 16:07:55 +09:00
Yuya Nishihara
d586657c81 formatter: add function to convert dict to appropriate format
This will be used to process key-value pairs by formatter. The default
field names and format are derived from the {extras} template keyword.

Tests will be added later.
2016-08-15 12:58:33 +09:00
Yuya Nishihara
9a45df1ce7 check-code: make dict() pattern less invasive
'foodict(x=y)' should be allowed.
2016-08-15 17:17:39 +09:00
Gregory Szorc
312f42b6e4 hgweb: tweak zlib chunking behavior
When doing streaming compression with zlib, zlib appears to emit chunks
with data after ~20-30kb on average is available. In other words, most
calls to compress() return an empty string. On the mozilla-unified repo,
only 48,433 of 921,167 (5.26%) of calls to compress() returned data.
In other words, we were sending hundreds of thousands of empty chunks
via a generator where they touched who knows how many frames (my guess
is millions). Filtering out the empty chunks from the generator
cuts down on overhead.

In addition, we were previously feeding 8kb chunks into zlib
compression. Since this function tends to emit *compressed* data after
20-30kb is available, it would take several calls before data was
produced. We increase the amount of data fed in at a time to 32kb.
This reduces the number of calls to compress() from 921,167 to
115,146. It also reduces the number of output chunks from 48,433 to
31,377. This does increase the average output chunk size by a little.
But I don't think this will matter in most scenarios.

The combination of these 2 changes appears to shave ~6s CPU time
or ~3% from a server serving the mozilla-unified repo.
2016-08-14 21:29:46 -07:00
Yuya Nishihara
ff77597ab7 test-gpg: run migration of v1 secret keys beforehand
This suppresses unwanted output at "hg sign".
2016-08-14 17:07:05 +09:00
Yuya Nishihara
7f925d7d30 test-gpg: start gpg-agent under control of the test runner
GnuPG v2 automatically starts gpg-agent. We should kill the daemon process.
2016-08-14 17:01:33 +09:00
Yuya Nishihara
f267bd6462 test-gpg: make temporary copy of GNUPGHOME
GnuPG v2 will convert v1 secret keys and create a socket under $GNUPGHOME.
This patch makes sure no state would persist.

We no longer need to verify trustdb.gpg, which was added by b3c5e4ecf912.
2016-08-14 16:49:47 +09:00
Gregory Szorc
118980f02b hgweb: document why we don't allow untrusted settings to control zlib
Added comment per discussion on mercurial-devel.
2016-08-15 20:39:33 -07:00
Gregory Szorc
4cfd8623b8 hgweb: profile HTTP requests
Currently, running `hg serve --profile` doesn't yield anything useful:
when the process is terminated the profiling output displays results
from the main thread, which typically spends most of its time in
select.select(). Furthermore, it has no meaningful results from
mercurial.* modules because the threads serving HTTP requests don't
actually get profiled.

This patch teaches the hgweb wsgi applications to profile individual
requests. If profiling is enabled, the profiler kicks in after
HTTP/WSGI environment processing but before Mercurial's main request
processing.

The profile results are printed to the configured profiling output.
If running `hg serve` from a shell, they will be printed to stderr,
just before the HTTP request line is logged. If profiling to a file,
we only write a single profile to the file because the file is not
opened in append mode. We could add support for appending to files
in a future patch if someone wants it.

Per request profiling doesn't work with the statprof profiler because
internally that profiler collects samples from the thread that
*initially* requested profiling be enabled. I have plans to address
this by vendoring Facebook's customized statprof and then improving
it.
2016-08-14 18:37:24 -07:00
Gregory Szorc
2ed4e485bc hgweb: abstract call to hgwebdir wsgi function
The function names and behavior now matches hgweb. The reason for this
will be obvious in the next patch.
2016-08-14 16:03:30 -07:00
Gregory Szorc
e6e0818daa profiling: don't error with statprof when profiling has already started
statprof.reset() asserts if profiling has already started. So don't
call if it profiling is already running.
2016-08-14 18:28:43 -07:00
Gregory Szorc
9ac5776ef7 profiling: add a context manager that no-ops if profiling isn't enabled
And refactor dispatch.py to use it. As you can see, the resulting code
is much simpler.

I was tempted to inline _runcommand as part of writing this series.
However, a number of extensions wrap _runcommand. So keeping it around
is necessary (extensions can't easily wrap runcommand because it calls
hooks before and after command execution).
2016-08-14 17:51:12 -07:00
Gregory Szorc
fbd4d1a639 profiling: make profiling functions context managers (API)
This makes profiling more flexible since we can now call multiple
functions when a profiler is active. But the real reason for this
is to enable a future consumer to profile a function that returns
a generator. We can't do this from the profiling function itself
because functions can either be generators or have return values:
they can't be both. So therefore it isn't possible to have a generic
profiling function that can both consume and re-emit a generator
and return a value.
2016-08-14 18:25:22 -07:00
Gregory Szorc
1aca3f1e38 dispatch: set profiling.enabled when profiling is enabled
We do this for other global command arguments. We don't for --profile
for reasons that are unknown to me. Probably because nobody has needed
it.

An upcoming patch will introduce a new consumer of the profiling
code. It doesn't have access to command line arguments. So let's
set the config option during argument processing.

We also remove a check for "options['profile']" because it is now
redundant.
2016-08-14 16:35:58 -07:00
Gregory Szorc
bdb3786ca0 profiling: move profiling code from dispatch.py (API)
Currently, profiling code lives in dispatch.py, which is a low-level
module centered around command dispatch. Furthermore, dispatch.py
imports a lot of other modules, meaning that importing dispatch.py
to get at profiling functionality would often result in a module import
cycle.

Profiling is a generic activity. It shouldn't be limited to command
dispatch. This patch moves profiling code from dispatch.py to the
new profiling.py. The low-level "run a profiler against a function"
functions have been moved verbatim. The code for determining how to
invoke the profiler has been extracted to its own function.

I decided to create a new module rather than stick this code
elsewhere (such as util.py) because util.py is already quite large.
And, I foresee this file growing larger once Facebook's profiling
enhancements get added to it.
2016-08-14 16:30:44 -07:00
Augie Fackler
cb268cbd2f merge with stable 2016-08-15 12:26:02 -04:00
Pulkit Goyal
0ce0d571e7 pycompat: avoid using an extra function
We have a single line function which just lowercase the letters and replaces
"_" with "". Its better to avoid that function call. Moreover we calling this
 function around 33 times.
2016-08-13 04:21:42 +05:30
Pulkit Goyal
1eb9840e42 pycompat: remove multiple occurences of urlencode
By mistake we had two occurences of urlencode.
2016-08-13 03:03:01 +05:30
Augie Fackler
6cbd7d8973 osx: stamp the hg version into the version field in the pkg
This is required for tools like https://github.com/munki/munki, and is
also more semantically correct.
2016-08-12 17:51:48 -04:00
Yuya Nishihara
320973b5ef revset: fix keyword arguments to go through optimization process
Before, a keyvalue node was processed by the last catch-all condition of
_optimize(). Therefore, topo.firstbranch=expr would bypass tree rewriting
and would crash if an expr wasn't trivial.
2016-08-07 14:58:49 +09:00
Mathias De Maré
e736d31e70 help: add example of '[templates]' usage
V2:
- move from shortest() with minlength 8 to minlength 4
- mention [templates] in config.txt
- better describe the difference between [templatealias] and [templates]

V3:
- choose a better example template
2016-08-08 16:47:42 +02:00
Augie Fackler
97b8f423b9 exchange: correctly specify url to unbundle (issue5145)
This parameter is slightly confusingly named in wireproto, so it got
mis-specified from the start as 'push' instead of the URL to which we
are pushing. Sigh. I've got a patch for that which I'll mail
separately since it's not really appropriate for stable.

Fixes a regression in bundle2 from bundle1.
2016-08-05 16:25:15 -04:00
Durham Goode
769d2595c4 convert: move svn config initializer out of the module level
The svn_config_get_config config call was being called at the module level, but
had the potential to throw permission denied errors if ~/.subversion/servers was
not readable. This could happen in certain test environments where the user
permissions were very particular.

This prevented the remotenames extension from loading, since it imports
convert's hg module, which imports convert's subversion module, which calls
this. The config is only ever used from this one constructor, so let's just move
it in to there.
2016-08-01 17:38:01 -07:00
Anton Shestakov
f42d0025b8 osx: update bugzilla link in readme 2016-08-04 19:53:46 +08:00
Anton Shestakov
7f3760e482 win32: update link to mailing list in readme 2016-08-04 19:50:25 +08:00
Anton Shestakov
c30efef3cd win32: update wiki link in mercurial.ini 2016-08-04 19:50:06 +08:00
Anton Shestakov
2ffd028d67 debian: update source URL in copyright file 2016-08-04 19:49:07 +08:00
Anton Shestakov
9573c5450e help: update link to wiki/CommandServer 2016-08-04 10:42:03 +08:00
Augie Fackler
defd77b437 Added signature for changeset f19241339f58 2016-08-01 12:37:25 -04:00
Augie Fackler
de2b5133ca merge with i18n 2016-08-01 12:11:56 -04:00
FUJIWARA Katsunori
8d71526776 i18n-ja: synchronized with 9b5b7cc2faf0 2016-08-01 08:27:22 +09:00