Commit Graph

29214 Commits

Author SHA1 Message Date
Yuya Nishihara
ba3291048d revset: check invalid function syntax "func-name"() explicitly
Before the error was caught at func() as an unknown identifier, and the
optimizer failed to detect the syntax error. This patch introduces getsymbol()
helper to ensure that a string is not allowed as a function name.
2016-06-27 20:44:14 +09:00
Yuya Nishihara
5bae87a105 chg: silence warning of unused parameter 'sig' 2016-06-28 22:39:06 +09:00
Anton Shestakov
230d011cdc hgweb: reindent atom/changelogentry.tmpl
It was mixing tabs and spaces, and not in a good way.

Indent style of other atom entries seems to be 1 space per level, so let's
apply it here as well.
2016-06-29 22:48:32 +08:00
Anton Shestakov
e5788a6e8c hgweb: remove unused/nonexistent filelogentry from atom/map
filelog in atom style uses changelogentry to show commits, and
atom/filelogentry.tmpl doesn't even exist.
2016-06-29 21:07:59 +08:00
Anton Shestakov
385d153e4e hgweb: remove unnecessary CDATA markup in atom/branchentry.tmpl
Since content is of type "text" (and is already escaped), using a CDATA section
is not required.

Looks like this was just an artifact of copying things from rss style in
529b23a26574, because other entries in atom style don't use CDATA in such
places.
2016-06-29 20:58:09 +08:00
Anton Shestakov
b11305ab3e hgweb: reindent rss/changelogentry.tmpl
It was mixing tabs and spaces, and not in a good way.

Indent style of other rss entries seems to be 4 spaces per level, so let's
apply it here as well.
2016-06-29 20:19:04 +08:00
Anton Shestakov
71ef725f83 hgweb: remove a couple of superfluous spaces in rss style 2016-06-29 19:40:04 +08:00
Pulkit Goyal
c74034c936 py3: add tests in check-code to load modules from util.py
The conditionalize imports are added in util.py and now we import modules from
there. So adding tests so that someone in future can use that.
2016-06-27 19:10:30 +05:30
Pulkit Goyal
38a359ce5c py3: conditionalize SocketServer import
The SocketServer is renamed to socketserver in python 3
2016-06-27 16:48:54 +05:30
Pulkit Goyal
fdc0861e35 py3: conditionalize xmlrpclib import
The xmlrpclib library is renamed to xmlrpc.client in python 3
2016-06-27 16:37:37 +05:30
Pulkit Goyal
5fcc6a2628 py3: conditionalize the urlparse import
The urlparse library is renamed to urllib.parse in python 3
2016-06-27 16:16:10 +05:30
Pulkit Goyal
175e976a5b py3: update tests/test-check-py3-compat.t
The lower part of the test runs with python 3 and hence remain unchanged.
2016-06-27 15:53:38 +05:30
Jun Wu
dfebfdbf56 chg: send SIGPIPE to server immediately when pager exits (issue5278)
If the user press 'q' to leave the 'less' pager, it is expected to end the
hg process immediately. We currently rely on SIGPIPE for this behavior. But
SIGPIPE won't arrive if we don't write anything (like doing heavy
computation, reading from network etc). If that happens, the user will feel
that the hg process just hangs.

The patch address the issue by adding a SIGCHLD signal handler and sends
SIGPIPE to the server as soon as the pager exits.

This is also an issue with hg's pager implementation.
2016-06-24 15:21:10 +01:00
Jun Wu
9579ecf5f2 chgserver: do not ignore SIGPIPE if pager is used
We rely on SIGPIPE to exit when the pager exits. And Python ignores SIGPIPE
by default. Explicitly set SIGPIPE handler to SIG_DFL (terminate) just like
pager.py.
2016-06-24 17:06:41 +01:00
Martin von Zweigbergk
5dcec73439 debug: make debug{revlog,index,data} --dir not just a flag
The directory argument (for tree manifests) should belong to to the
--dir argument. I had mistakenly made --dir a flag. One effect of this
was that I had meant for "-m" to be optional, but instead it changed
the behavior of --dir, so with "hg debugdata -m --dir dir1 0", the -m
took over and the "dir1" got treated as a revision in the root
manifest log.
2016-06-24 11:12:41 -07:00
Martin von Zweigbergk
a785632cca debugdata: disallow trailing option with -c/-m
Before this change, "hg debugdata -c 0 foo" was allowed.
2016-06-24 11:25:55 -07:00
Yuya Nishihara
7323118189 revset: get rid of redundant error checking from match()
Actually there was no additional error checking. It should be caught by
"not all(specs)".
2016-06-26 17:16:57 +09:00
Martijn Pieters
a8afdea978 share: move magic string to a constant 2016-06-24 10:32:38 +01:00
Gregory Szorc
c98d59c36a branchmap: remove unused exception variable 2016-03-12 16:08:19 -08:00
Henrik Stuart
40c8c53428 patch: allow copy information to be passed in
When displaying patches from graphical tools where you can browse through
individual files, with diff being called separately on each, recomputing the
limits of file copy history can become rather expensive on large repositories.
Instead, we can compute it once and pass it in for subsequent calls.
2016-06-27 12:11:18 +02:00
liscju
347bb0767e largefiles: check file in the repo store before checking remotely (issue5257)
Problem was files to check were gathered in the repository where
the verify was launched but verification was done on the remote
store. It was observed when user committed in cloned repository
and ran verify before pushing - committed files were marked
as non existing.

This commit fixes this by checking in the remote store only files
that are not existing in the repository store where verify was launched.

Solution is similiar to 909b9d8f9ae7
2016-06-23 22:37:17 +02:00
liscju
36f41df99d largefiles: remove additional blank lines
It does not conform to the coding style.
2016-06-27 10:33:33 +02:00
liscju
a37f11d3d7 largefiles: fix misleading comments in lfutil instore and storepath
Problem in both cases is cache in largefiles has assigned
meaning - user cache which is additional place to get/put
files. Those two function works on store - the main place
to store largefiles in the repository - .hg/largefiles and
using "cache" to describe it is misleading.
2016-06-24 09:08:16 +02:00
Gregory Szorc
aa5486b692 revset: implement match() in terms of matchany()
match() is the special case of a single element list being passed
to matchany() with the additional error checking that the revset
spec is defined. Change the implementation to remove the redundant
code and have match() call matchany().
2016-06-25 19:10:46 -07:00
Gregory Szorc
159c164568 scmutil: improve documentation of revset APIs
I can never remember the differences between the various revset
APIs. I can never remember that scmutil.revrange() is the one I
want to use from user-facing commands.

Add some documentation to clarify this.

While we're here, the argument name for revrange() is changed to
"specs" because that's what it actually is.
2016-06-25 19:12:20 -07:00
Gregory Szorc
fac475dd90 mdiff: remove use of __slots__
The use of __slots__ was added way back in 2006 in ce444c810fcf.
__slots__ isn't necessary for this class.
2016-06-25 13:52:46 -07:00
Gregory Szorc
9d12ac43cc i18n: use unicode literal
Other parts of this expression are already using unicode literals.
We need this to make Python 3 happy and to avoid an implicit
conversion in Python 2.
2016-06-25 17:40:53 -07:00
Gregory Szorc
54aabad0ba pycompat: add HTTPPasswordMgrWithDefaultRealm to Python 3 block
Looks like we missed this in 46280bc1ec69.
2016-06-25 17:22:06 -07:00
Gregory Szorc
9c6bc630a3 ui: path option to declare which revisions to push by default
Now that we have a mechanism for declaring path sub-options, we can
start to pile on features!

Many power users have expressed frustration that bare `hg push`
attempts to push all local revisions to the remote. This patch
introduces the "pushrev" path sub-option to control which revisions
are pushed when no "-r" argument is specified.

The value of this sub-option is a revset, naturally.

A future feature addition could potentially introduce a "pushnames"
sub-options that declares the list of names (branches, bookmarks,
topics, etc) to push by default. The entire "what to push by default"
feature should probably be considered before this patch lands.
2016-06-26 07:59:02 -07:00
Gregory Szorc
bbde62ff9f ui: don't fixup [paths] sub-options
As part of developing a subsequent patch I discovered that sub-option
values like "." were getting converted to paths. This is because the
[paths] section is treated specially during config loading.

This patch prevents post-processing sub-options from the [paths]
section.
2016-06-25 18:35:14 -07:00
Gregory Szorc
aa33fbc73f sslutil: abort when unable to verify peer connection (BC)
Previously, when we connected to a server and were unable to verify
its certificate against a trusted certificate authority we would
issue a warning and continue to connect. This is obviously not
great behavior because the x509 certificate model is based upon
trust of specific CAs. Failure to enforce that trust erodes security.
This behavior was defined several years ago when Python did not
support loading the system trusted CA store (Python 2.7.9's
backports of Python 3's improvements to the "ssl" module enabled
this).

This commit changes behavior when connecting to abort if the peer
certificate can't be validated. With an empty/default Mercurial
configuration, the peer certificate can be validated if Python is
able to load the system trusted CA store. Environments able to load
the system trusted CA store include:

* Python 2.7.9+ on most platforms and installations
* Python 2.7 distributions with a modern ssl module (e.g. RHEL7's
  patched 2.7.5 package)
* Python shipped on OS X

Environments unable to load the system trusted CA store include:

* Python 2.6
* Python 2.7 on many existing Linux installs (because they don't
  ship 2.7.9+ or haven't backported modern ssl module)
* Python 2.7.9+ on some installs where Python is unable to locate
  the system CA store (this is hopefully rare)

Users of these Pythongs will need to configure Mercurial to load the
system CA store using web.cacerts. This should ideally be performed
by packagers (by setting web.cacerts in the global/system hgrc file).
Where Mercurial packagers aren't setting this, the linked URL in the
new abort message can contain instructions for users.

In the future, we may want to add more code for finding the system
CA store. For example, many Linux distributions have the CA store
at well-known locations (such as /etc/ssl/certs/ca-certificates.crt
in the case of Ubuntu). This will enable CA loading to "just work"
on more Python configurations and will be best for our users since
they won't have to change anything after upgrading to a Mercurial
with this patch.

We may also want to consider distributing a trusted CA store with
Mercurial. Although we should think long and hard about that because
most systems have a global CA store and Mercurial should almost
certainly use the same store used by everything else on the system.
2016-06-25 07:26:43 -07:00
Gregory Szorc
a838b9492a sslutil: remove out of place comment
This comment likely got orphaned as a result of refactoring in this
file. It isn't providing any useful value. So delete it.
2016-06-25 07:32:02 -07:00
liscju
7e9f22c475 largefiles: remove additional blank line between methods in localstore
According to the coding style it should be a single blank line
between functions.
2016-06-24 11:51:00 +02:00
Martin von Zweigbergk
59e258644a revset: make head() honor order of subset
The ordering of 'x & head()' was broken in 329d82866742 (revset:
improve head revset performance, 2014-03-13). Presumably due to other
optimizations since then, undoing that change to fix the order does
not slow down the simple case of "hg log -r 'head()'" mentioned in
that commit. I see a small slowdown from ~0.16s to about ~0.19s with
'not 0 & head()', but I'd say it's worth it for the correct output.
2016-06-23 12:37:09 -07:00
Martin von Zweigbergk
f44cccc475 revsets: use itervalues() where only values are needed
I don't think there will be a noticeable speedup, but it removes an
unused variable.
2016-06-23 13:08:10 -07:00
Martin von Zweigbergk
792eb4d1ec revsets: passing a set to baseset() is not wrong
Since 303be3afebae (revset: force ascending order for baseset
initialized from a set, 2016-04-04), it is safe to pass a revset to a
baseset.
2016-06-23 12:39:05 -07:00
Pierre-Yves David
c915441bc6 pyflakes: use pycompat.pickles to prevent error
The pyflakes in my test box complain about pickle in pycompat.

  mercurial/pycompat.py:17: 'pickle' imported but unused
2016-06-24 02:04:43 +02:00
Kostia Balytskyi
a7adcda5dc rebase: move local variable 'obsoletenotrebased' to the RR class 2016-06-21 06:29:23 -07:00
Kostia Balytskyi
c0f90a3ffa rebase: move restorestestatus function to be a method of the RR class 2016-06-21 06:29:23 -07:00
Kostia Balytskyi
b5102baa59 rebase: move local variables related to keeping things unchanged to the RR
This commit moves the following variables, local to the rebase function to be
fields of the rebaseruntime:
 -keepf
 -keepbranchesf
 -keepopen
2016-06-21 06:29:23 -07:00
Kostia Balytskyi
7ea5cc73ed rebase: move local variables 'date' and 'extrafns' to the RR class
This commit moves the following variables, local to the rebase function to be
fields of the rebaseruntime:
 -date
 -extrafns
2016-06-21 06:29:23 -07:00
Kostia Balytskyi
66b3ef340b rebase: move collapse-related local variables to the RR class
This commit moves the following variables local to the 'rebase' function
to be fields of the rebaseruntime class:
 -collapsef
 -collapsemsg
2016-06-21 06:29:23 -07:00
Kostia Balytskyi
d75ec97b9b rebase: pass repo, ui and opts objects to the RR class constructor 2016-06-21 07:22:49 -07:00
FUJIWARA Katsunori
8329fc9bdf check-code: build translation table for repquote in global for efficiency
Rebuilding translation table (256 size) at each repquote() invocations
is redundant.

For example, this patch decreases user time of command invocation
below from 18.297s to 13.445s (about -27%) on a Linux box. This
command is main part of test-check-code.t.

    hg locate | xargs python contrib/check-code.py --warnings --per-file=0

This patch adds "_repquote" prefix to functions and variables factored
out from repquote() to avoid conflict of name in the future.
2016-06-21 00:50:39 +09:00
FUJIWARA Katsunori
f46b49a0e3 check-code: detect "missing _() in ui message" more exactly
Before this patch, "missing _() in ui message" rule overlooks
translatable message, which starts with other than alphabet.

To detect "missing _() in ui message" more exactly, this patch
improves the regexp with assumptions below.

  - sequence consisting of below might precede "translatable message"
    in same string token

    - formatting string, which starts with '%'
    - escaped character, which starts with 'b' (as replacement of '\\'), or
    - characters other than '%', 'b' and 'x' (as replacement of alphabet)

  - any string tokens might precede a string token, which contains
    "translatable message"

This patch builds an input file, which is used to examine "missing _()
in ui message" detection, before '"$check_code" stringjoin.py' in
test-contrib-check-code.t, because this reduces amount of change churn
in subsequent patch.

This patch also applies "()" instead of "_()" on messages below to
hide false-positives:

  - messages for ui.debug() or debug commands/tools
    - contrib/debugshell.py
    - hgext/win32mbcs.py (ui.write() is used, though)
    - mercurial/commands.py
      - _debugchangegroup
      - debugindex
      - debuglocks
      - debugrevlog
      - debugrevspec
      - debugtemplate

  - untranslatable messages
    - doc/gendoc.py (ReST specific text)
    - hgext/hgk.py (permission string)
    - hgext/keyword.py (text written into configuration file)
    - mercurial/cmdutil.py (formatting strings for JSON)
2016-06-21 00:50:39 +09:00
Jun Wu
03c27804a3 revlog: add a fast path for "ambiguous identifier"
Before fd1bb7c, if the C index.partialmatch raises RevlogError, the Python
code raises "ambiguous identifier" error immediately, which is efficient.

fd1bb7c took hidden revisions into consideration and forced the slow path
enumerating the changelog to double-check hidden revisions. But it's not
necessary if we know the revlog has no hidden revisions.

This patch adds back the fast path for unfiltered revlogs.
2016-06-22 21:30:49 +01:00
Augie Fackler
cfab112ddc import-checker: ensure cffi is always a system module
I've had reports that this is not always happening, so whitelist it
the way we whitelist other problem cases.
2016-06-23 20:45:37 -04:00
Martijn Pieters
5b87e45011 atomictempfile: add context manager support
Close the file (moving it in place) on clean context exit, discard when there
has been an exception.
2016-06-23 18:21:25 +01:00
Martijn Pieters
0b92f0a888 atomictempfile: add read to the supported file operations 2016-06-23 18:20:58 +01:00
Martijn Pieters
3ae09f6f7e atomictempfile: remove test ordering
These tests are independent and numbering only makes it harder to add more and
logically group them.
2016-06-23 18:18:33 +01:00