Commit Graph

28342 Commits

Author SHA1 Message Date
liscju
802a1dd151 largefiles: replace invocation of os.path module by vfs in lfutil.py
Replaces invocations os.path functions to methods in vfs. Unfortunately
(in my view) this makes code less readable, because instead of using
clear variable names with path it needs to replace them with vfs(..).
I need guidance how to make such transition look more readable.

For example in this patch there is example with few places with
wvfs.join(standindir), standindir before this patch was absolute
path, in this it is changed to relative because it is used also
in expression wvfs.join(standindir, pat).
2016-03-14 20:20:22 +01:00
liscju
4648b42bff largefiles: replace invocation of os.path module by vfs in lfcommands.py 2016-03-13 23:16:44 +01:00
Mads Kiilerich
a4030fe6b2 cache: rebuild branch cache from scratch when inconsistencies are detected
This should recover automatically from some corruptions that for unknown
reasons are seen in the wild.
2016-03-13 02:06:23 +01:00
Mads Kiilerich
3f4cf91261 cache: safer handling of failing seek when writing revision branch cache
If the seek for some reason fails (perhaps because the file is too short to
search to the requested position), make sure we seek to the start and rewrite
everything.

It is unknown if this fixes a real problem that ever happened.
2016-03-13 02:06:22 +01:00
Mads Kiilerich
de2745150d cache: remove branch revision file before rewriting the branch name file
New branch names are usually appended to the branch name file. If that fails or
the file has been modified by another process, it is rewritten. That left a
small opportunity that there could be references to non-existent entries in the
file while it was rewritten.

To avoid that, remove the revision branch cache file with the references to the
branch name file before rewriting the branch name file. Worst case, when
interrupted at the wrong time, the cache will be lost and rebuilt next time.

It is unknown if this fixes a real problem that ever happened.
2016-03-13 02:06:21 +01:00
Jun Wu
9a62943b10 chg: do not redirect stdout to /dev/null
Redirecting stdout to /dev/null has unwanted side effects, namely ui.write
will stop working. This patch removes the redirection code and helps chg to
pass test-bad-extension.t.
2016-03-14 15:05:25 +00:00
Jun Wu
cbbb576b1c pager: skip uisetup if chg is detected
chg has its own pager implementation that it wants to skip pager's uisetup.
It is currently done by redirecting stdout to /dev/null, which has unintended
side effects. This patch makes pager aware of chg and skip uisetup directly
from pager. We may want to merge chg and pager's pager implementation to
make this unnecessary in the future.
2016-03-14 15:03:19 +00:00
Jun Wu
60655f3e3b chgserver: add an explicit gc to trigger __del__
SocketServer.ForkingMixIn uses os._exit which will skip all cleanup handlers.
We want to run __del__ to make things like transactions, {ssh,http}peer,
atomictempfile, dirstateguard, etc. work.

This patch adds a "gc.collect()" to trigger __del__. It is helpful for chg
to pass some test cases in test-devel-warnings.t.
2016-03-14 23:08:03 +00:00
Jun Wu
d487d6ed63 blackbox: do not assume self._bb{vfs,repo,fp} are set in blackboxui.__init__
It's possible for the blackboxui code to do a "del self._bbvfs", then ui.copy()
or similar attempt will fail. It will also fail when constructing a blackboxui
from a non-blackbox ui.
This patch fixes the issue by not assuming any _bb* attr is set.
2016-03-15 10:36:02 +00:00
Jun Wu
f94ba7eabd chg: downgrade "failed to read channel" from abortmsg to debugmsg
If the server has an uncaught exception, it will exit without being able to
write the channel information. In this case, the client is likely to complain
about "failed to read channel", which looks inconsistent with original hg.
This patch silences the error message and makes uncaught exception behavior
more like original hg. It will help chg to pass test-fileset.t.
2016-03-14 23:28:14 +00:00
Jun Wu
745b527cb7 histedit: do not close stdin
Closing stdin is unexpected by chgserver and is not a good idea generally.
This patch refactors related code a bit and make sure stdin is not closed.
It will make chg much happier on test-histedit*.t.
2016-03-15 00:42:33 +00:00
Jun Wu
463f2aebe1 tests: reorder hg serve commands
chg currently does not support hg serve -d. It has a quick path testing if the
command is hg serve -d and fallbacks to hg if so. But the test only works if
"serve" is the first argument since the test wants to avoid false positives
(for example, "-r serve" is different).
This patch reorders "hg server" commands in tests, making them chg friendly.
2016-03-15 09:51:54 +00:00
Yuya Nishihara
7d5bdcf68d templater: add debugtemplate command
This is useful for debugging template parsing. Several tests are ported to
this command.
2016-02-14 01:06:12 +09:00
Yuya Nishihara
e489dfcaf7 templater: expand list of parsed templates to template node
This patch eliminates a nested data structure other than the parsed tree.

  ('template', [(op, data), ..]) -> ('template', (op, data), ..)

New expanded tree can be processed by common parser functions. This change
will help implementing template aliases.

Because a (template ..) node should have at least one child node, an empty
template (template []) is mapped to (string ''). Also a trivial string
(template [(string ..)]) node is unwrapped to (string ..) at parsing phase,
instead of compiling phase.
2016-02-13 23:20:47 +09:00
Yuya Nishihara
633de11fa7 templater: relax type of mapped template
Now compiled template fragments are packed into a generic type, (func, data),
a string can be a valid template. This change allows us to unwrap a trivial
string node. See the next patch for details.
2016-02-14 15:42:49 +09:00
Yuya Nishihara
402c2c88bb templater: lift parsed and compiled templates to generic data types
Before this patch, parsed and compiled templates were kept as lists. That
was inconvenient for applying transformation such as alias expansion.

This patch changes the types of the outermost objects as follows:

  stage     old             new
  --------  --------------  ------------------------------
  parsed    [(op, ..)]      ('template', [(op, ..)])
  compiled  [(func, data)]  (runtemplate, [(func, data)])

New templater.parse() function has the same signature as revset.parse()
and fileset.parse().
2016-02-13 23:54:24 +09:00
Danek Duvall
38ac6bfb8a tests: python executable path should always be globbed
Although this is coming in under the guise of consistency, part of the
desire for this is that at least as part of the official Solaris builds,
we build with a versioned python interpreter, such as "python2.7", which
doesn't match "*python".
2016-03-15 15:50:57 -07:00
Simon Farnsworth
4f9fc754b3 crecord: use ui.interface to choose curses interface
use ui.interface to select curses mode, instead of experimental.crecord
2016-03-14 15:01:27 +00:00
Simon Farnsworth
c7b3ee31ad ui: add new config flag for interface selection
This patch introduces a new config flag ui.interface to select the interface
for interactive commands. It currently only applies to chunks selection.
The config can be overridden on a per feature basis with the flag
ui.interface.<feature>.

features for the moment can only be 'chunkselector', moving forward we expect
to have 'histedit' and other commands there.

If an incorrect value is given to ui.interface we print a warning and use the
default interface: text. If HGPLAIN is specified we also use the default
interface: text.

Note that we fail quickly if a feature does not handle all the interfaces
that we permit in ui.interface; in future, we could design a fallback path
(e.g. blackpearl to curses, curses to text), but let's leave that until we
need it.
2016-03-14 15:01:27 +00:00
Pierre-Yves David
5d3d0e1d77 extensions: also search for extension in the 'hgext3rd' package
Mercurial extensions are not meant to be normal python package/module. Yet the
lack of an official location to install them means that a lot of them actually
install as root level python package, polluting the global Python package
namespace and risking collision with more legit packages. As we recently
discovered, core python actually support namespace package. A way for multiples
distinct "distribution" to share a common top level package without fear of
installation headache. (Namespace package allow submodule installed in different
location (of the 'sys.path') to be imported properly. So we are fine as long as
extension includes a proper 'hgext3rd.__init__.py' to declare the namespace
package.)

Therefore we introduce a 'hgext3rd' namespace packages and search for extension
in it. We'll then recommend third extensions to install themselves in it.
Strictly speaking we could just get third party extensions to install in 'hgext'
as it is also a namespace package. However, this would make the integration of
formerly third party extensions in the main distribution more complicated as the third
party install would overwrite the file from the main install. Moreover, having an
explicit split between third party and core extensions seems like a good idea.

The name 'hgext3rd' have been picked because it is short and seems explicit enough.
Other alternative I could think of where:

- hgextcontrib
- hgextother
- hgextunofficial
2016-03-11 10:30:08 +00:00
FUJIWARA Katsunori
1d2fb0ab99 hgext: use templatekeyword to mark a function as template keyword
This patch replaces registration of template keyword function in
bundled extensions by registrar.templatekeyword decorator all at once.
2016-03-13 05:17:06 +09:00
FUJIWARA Katsunori
26097c8fbe templatekw: use templatekeyword to mark a function as template keyword
Using decorator can localize changes for adding (or removing) a
template keyword function in source code.

This patch also removes leading ":KEYWORD:" part in help document of
each keywords, because using templatekeyword makes it useless.

For similarity to decorator introduced by subsequent patches, this
patch uses 'templatekeyword' instead of 'keyword' as a decorator name,
even though the former is a little redundant in 'templatekw.py'.

    file                name              reason
    =================== ================= ==================================
    templatekw.py       templatekeyword   for similarity to others
    templatefilters.py  templatefilter    'filter' hides Python built-in one
    templaters.py       templatefunc      'func' is too generic
2016-03-13 05:17:06 +09:00
FUJIWARA Katsunori
adbb470b46 registrar: add templatekeyword to mark a function as template keyword (API)
_templateregistrarbase is defined as a super class of templatekeyword,
for ease of adding template common features between "keyword",
"filter" and "function".

This patch also adds loadkeyword() to templatekw, because this
combination helps to figure out how they cooperate with each other.

Listing up loadkeyword() in dispatch.extraloaders causes implicit
loading template keyword functions at loading (3rd party) extension.

This change requires that "templatekeyword" attribute of (3rd party)
extension is registrar.templatekeyword or so.
2016-03-13 05:17:06 +09:00
Jun Wu
b50f59de5d chgserver: do not keep repo object
The current chgserver design is to use one server to handle multiple repos
which has same [extensions] config. Previously the client uses --cwd / to
avoid creating a repo object. Now we need to set repo to None before we
have code to make "serve" command norepo when it's chg.
2016-03-16 11:57:09 +00:00
Jun Wu
6193936a7f chgserver: invalidate the server if extensions fail to load
Previously, if extensions fail to load, chg server will just keep working
without those extensions. It will print a warning message but only if a new
server starts.

This patch invalidates the server if any extension failed to load, but still
serve the client (hopefully just) once. It will help chg pass some test cases
of test-bad-extension.t.
2016-03-12 04:24:11 +00:00
Jun Wu
80fd75af3b chgserver: add an explicit "reconnect" instruction to validate
In some rare cases (next patch), we may want validate to do "unlink" without
forcing the client reconnect. This patch addes a new "reconnect" instruction
and makes "unlink" not to reconnect by default.
2016-03-14 13:48:33 +00:00
Jun Wu
75b4a0eb75 dispatch: flush ui before returning from dispatch
A chg client may exit after received the result from runcommand. It is
necessary to do a flush to make sure the warning message is printed out
and the process waiting for the chg client will actually see the output.

This helps chg to pass test-alias.t.
2016-03-14 11:06:34 +00:00
FUJIWARA Katsunori
3af8e0ba8c tests: make tests for convert with svn portable
svn 1.6.x (at least, 1.6.12 or 1.6.17) might display empty lines, even
though svn 1.9.x (at least, 1.9.3) doesn't.

To make tests for convert with svn portable, this patch adds "|(^$)"
regexp to egrep in filter_svn_output.

To avoid similar future issue, this patch adds "|(^$)" regexp to all
filter_svn_output (and adjusts test-subrepo-svn.t), even though only
test-convert-svn-source.t fails with svn 1.6.x, AFAIK.
2016-03-15 00:14:53 +09:00
Matt Mackall
97d8dbf685 merge with stable 2016-03-15 14:10:46 -07:00
Mads Kiilerich
39acd325e0 streamclone: fix error when store files grow while stream cloning
Effectively a backout of d573a437d564, but updated to using 'with'.
2016-03-13 02:29:11 +01:00
Mads Kiilerich
6372bd0ae3 tests: add test of stream clone of repo that is changing
This reveals an error introduced by d573a437d564.
2016-03-13 02:28:46 +01:00
Augie Fackler
db4881fa4f test-pager: add a test for pager with color enabled 2016-03-11 20:34:49 -05:00
Augie Fackler
b3f8347d29 http: support sending hgargs via POST body instead of in GET or headers
narrowhg (for its narrow spec) and remotefilelog (for its large batch
requests) would like to be able to make requests with argument sets so
absurdly large that they blow out total request size limit on some
http servers. As a workaround, support stuffing args at the start
of the POST body.

We will probably want to leave this behavior off by default in servers
forever, because it makes the old "POSTs are only for writes"
assumption wrong, which might break some of the simpler authentication
configurations.
2016-03-11 11:37:00 -05:00
Augie Fackler
b569044317 fsmonitor: flag msc_stdint as no-check-code
I'd rather not modify code that we're vendoring, so I'm just marking
it this way.
2016-03-14 21:15:59 -04:00
Sune Foldager
1e39bee49b fsmonitor: use custom stdint.h file when compiling with Visual C
Visual C/C++ 9, which Python 2.7 is compatible with, doesn't have C99
support and thus doesn't contain a stdint.h file.

This changeset adds a custom version of stdint.h, created specifically
for Visual C, and uses it when building with that compiler.
2016-03-14 17:53:47 +01:00
Mads Kiilerich
f304a26569 tests: handle getaddrinfo reporting "No address associated with hostname"
This has been seen on some Fedora 23 systems.
2016-03-13 02:36:03 +01:00
Martin von Zweigbergk
ede6d3a6dd httpconnection: remove obsolete comment about open()
When httpsendfile was moved from url.py into httpconnection.py in
aec6dba8c673 (url: use new http support if requested by the user,
2011-05-06), the comment about not being able to just call open()
became obsolete.
2016-03-14 14:08:28 -07:00
Gregory Szorc
ab086daadb sslutil: allow multiple fingerprints per host
Certificate pinning via [hostfingerprints] is a useful security
feature. Currently, we only support one fingerprint per hostname.
This is simple but it fails in the real world:

* Switching certificates breaks clients until they change the
  pinned certificate fingerprint. This incurs client downtime
  and can require massive amounts of coordination to perform
  certificate changes.
* Some servers operate with multiple certificates on the same
  hostname.

This patch adds support for defining multiple certificate
fingerprints per host. This overcomes the deficiencies listed
above. I anticipate the primary use case of this feature will
be to define both the old and new certificate so a certificate
transition can occur with minimal interruption, so this scenario
has been called out in the help documentation.
2016-03-13 14:03:58 -07:00
Gregory Szorc
63ccfcc36f help: add empty lines to hostfingerprints section
I think this is now much easier to read.
2016-03-13 13:51:01 -07:00
Gregory Szorc
891be7d008 help: document requirements
We didn't have unified documentation of the various repository
requirements. This patch changes that.
2016-03-12 18:51:07 -08:00
Pulkit Goyal
37b8e88ad9 showstack: use absolute_import 2016-03-13 01:59:18 +05:30
Pulkit Goyal
edde19dc54 contrib: use absolute_import in win32/hgwebdir_wsgi.py 2016-03-14 14:12:13 +05:30
Durham Goode
58ee8fb13a obsolete: fix n^2 marker computation behavior
Previously, if you ran obsolete.createmarkers with a bunch of markers that did
not have successors (like when you do a prune), it encountered a n^2 computation
behavior because the loop would read the changelog (to get ctx.parents()), then
add a marker, in a loop.  Adding a marker invalidated the computehidden cache,
and reading the changelog recomputed it.

This resulted in pruning 150 commits taking 150+ seconds in a large repo.

The fix is to break the reading part of the loop to be separate from the writing
part.
2016-02-04 15:38:04 -08:00
timeless
156f8d111d bdiff: (pure) support array.array arrays (issue5130) 2016-03-08 17:26:12 +00:00
Pierre-Yves David
a74c6e1e14 mq: restrict generated patch name to 75 characters (issue5117)
Super long first line in description lead to very long file name that
windows is unhappy about. We restrict the name to 75 char to avoid the
issue.

75 seems fine and leave some extra room for '__#' suffix in case of conflict.

I does not seems worthwhile to add a dedicated config option to configure the
length. It can be done in the future if there is an actual user demand for it.
2016-03-09 22:21:08 +00:00
Matt Harbison
3fb00b6ab7 files: don't recurse into subrepos without a path or -S (issue5127)
The 'm.always()' check was needed for when a path to 'sub1' is given, and 'sub1'
contains a subrepo itself.  But that also caused the automatic recursion when no
path was given.  Instead, force -S when printing a subrepo if the subpath is an
exact match (which will unconditionally recurse once in the nested subrepo).
2016-03-06 14:30:34 -05:00
Yuya Nishihara
92b8c590a0 tests: adjust for code move in Hypothesis 2.0.0
It appears that the Settings class was renamed to settings, and because
of this, the settings module was renamed to configuration.

https://github.com/DRMacIver/hypothesis/commit/a0e663b
2016-01-26 22:44:29 +09:00
Matt Mackall
1e9175d814 Added signature for changeset 6a934a7b8d54 2016-03-01 18:03:49 -06:00
Gregory Szorc
5b47f5a7bd hg: obtain lock when creating share from pooled repo (issue5104)
There are race conditions between clients performing a shared clone
to pooled storage:

1) Clients race to create the new shared repo in the pool directory
2) 1 client is seeding the repo in the pool directory and another goes
   to share it before it is fully cloned

We prevent these race conditions by obtaining a lock in the pool
directory that is derived from the name of the repo we will be
accessing.

To test this, a simple generic "lockdelay" extension has been added.
The extension inserts an optional, configurable delay before or after
lock acquisition. In the test, we delay 2 seconds after lock acquisition
in the first process and 1 second before lock acquisition in the 2nd
process. This means the first process has 1s to obtain the lock. There
is a race condition here. If we encounter it in the wild, we could
change the dummy extension to wait on the lock file to appear instead
of relying on timing. But that's more complicated. Let's see what
happens first.
2016-02-27 18:22:49 -08:00
FUJIWARA Katsunori
4a0bc54a73 doc: remove deprecated option from synopsis of command help
Before this patch, deprecated options below are used in synopsis of
command help, even though they aren't listed up as available options
by default. These might confuse readers.

  - -n (no-op, now) of strip
  - -a/--active of branches
  - -f/--force of merge
2016-03-01 03:28:46 +09:00