Commit Graph

17746 Commits

Author SHA1 Message Date
Pierre-Yves David
98f81e8c4f merge: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:53:32 -08:00
Pierre-Yves David
de20776881 hg-mod: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:53:24 -08:00
Pierre-Yves David
d47e9585d6 commands: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:53:17 -08:00
Pierre-Yves David
80b1f7c309 cmdutil: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:53:09 -08:00
Pierre-Yves David
b71c55108c localrepo: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2016-08-05 14:29:22 +02:00
Pulkit Goyal
077cba9952 minirst: make encoding.encoding unicodes to pass into encode() and decode() 2017-03-12 07:09:18 +05:30
Pulkit Goyal
bd7d2c3f64 minirst: make regular expressions bytes 2017-03-12 06:59:37 +05:30
Mads Kiilerich
6cbae57046 util: add debugstacktrace depth limit
Useful when you don't care about the start of the stack, but only want to see
the last entries.
2015-01-14 01:15:26 +01:00
Mads Kiilerich
97ac40d793 util: strip trailing newline from debugstacktrace message
This makes the function more convenient to use as drop-in replacement for
ui.write & co.
2015-01-16 04:26:40 +01:00
Mads Kiilerich
975c19c195 vfs: use repo.vfs.unlinkpath 2017-03-11 11:02:25 -08:00
Mads Kiilerich
01ac38526d merge: use repo.wvfs.unlinkpath 2015-01-14 01:15:26 +01:00
Mads Kiilerich
a936a7f3a7 vfs: use repo.wvfs.unlinkpath 2015-01-14 01:15:26 +01:00
Augie Fackler
f3d54c952b policy: try and always have a bytes for module policy
debuginstall now runs cleanly in Python 3.
2017-03-08 18:11:41 -05:00
Augie Fackler
afdb0af8d1 init: zstd is already python3-ready, so don't run it through our importer 2017-03-08 18:11:19 -05:00
Augie Fackler
db877f58df config: guard against setconfig specifying unicode values on py3
This was leading to some difficult to trace problems because the
values were set in one place, but then blew up much later in the
program. Exploding violently with an assertion seems reasonable here.
2017-03-03 14:42:56 -05:00
Augie Fackler
5759889c58 dispatch: enforce bytes when converting boolean flags to config items
This fixes --verbose on Python 3.
2017-03-03 14:43:27 -05:00
Augie Fackler
4d06a903c5 extensions: tapdance to get reasonable import error formatting
I'm not thrilled with this, but it seems to work.
2017-03-03 14:08:02 -05:00
Augie Fackler
00b54d28ff merge with stable 2017-03-11 13:53:14 -05:00
Gregory Szorc
97e218b123 httpconnection: rename config to groups
Because that is what it is.
2017-03-09 20:53:14 -08:00
Gregory Szorc
6ef9cb88f5 httpconnection: don't use dict()
Not sure the history here. But we don't do this elsewhere.
2017-03-09 20:51:57 -08:00
Martin von Zweigbergk
09677e4708 formatter: set _first on formatter, not ui
The _first field is used for tracking when to emit a separator between
items. It seems like it's clearly formatter state, not ui state, so
let's move it there.
2017-03-09 15:38:00 -08:00
Augie Fackler
5811358454 pycompat: verify sys.argv exists before forwarding it (issue5493)
ISAPI_WSGI doesn't set up sys.argv, so we have to look for the
attribute before assuming it exists.
2017-03-07 13:24:24 -05:00
Yuya Nishihara
ee998576d8 worker: flush messages written by child processes before exit
I found some child outputs were lost while testing the previous patch. Since
os._exit() does nothing special, we need to do that explicitly.
2017-02-25 12:48:50 +09:00
Rishabh Madan
d0ac5a9dcb ui: replace obsolete default-push with default:pushurl (issue5485)
Default-push has been deprecated in favour of default:pushurl. But "hg clone" still
inserts this in every hgrc file it creates. This patch updates the message by replacing
default-push with default:pushurl and also makes the necessary changes to test files.
2017-02-25 16:57:21 +05:30
FUJIWARA Katsunori
47ba9fae77 worker: ignore meaningless exit status indication returned by os.waitpid()
Before this patch, worker implementation assumes that os.waitpid()
with os.WNOHANG returns '(0, 0)' for still running child process. This
is explicitly specified as below in Python API document.

    os.WNOHANG
        The option for waitpid() to return immediately if no child
        process status is available immediately. The function returns
        (0, 0) in this case.

On the other hand, POSIX specification doesn't define the "stat_loc"
value returned by waitpid() with WNOHANG for such child process.

    http://pubs.opengroup.org/onlinepubs/9699919799/functions/waitpid.html

CPython implementation for os.waitpid() on POSIX doesn't take any care
of this gap, and this may cause unexpected "exit status indication"
even on POSIX conformance platform.

For example, os.waitpid() with os.WNOHANG returns non-zero "exit
status indication" on FreeBSD. This implies os.kill() with own pid or
sys.exit() with non-zero exit code, even if no child process fails.

To ignore meaningless exit status indication returned by os.waitpid(),
this patch skips subsequent steps forcibly, if os.waitpid() returns 0
as pid.

This patch also arranges examination of 'p' value for readability.

FYI, there are some issues below about this behavior reported for
CPython.

    https://bugs.python.org/issue21791
    https://bugs.python.org/issue27808
2017-02-25 01:07:52 +09:00
Siddharth Agarwal
7d1a6f9777 bundle2: fix assertion that 'compression' hasn't been set
`n.lower()` will return `compression`, not `Compression`.
2017-02-13 11:43:12 -08:00
Pierre-Yves David
43b1ef004c wireproto: properly report server Abort during 'getbundle'
Previously Abort raised during 'getbundle' call poorly reported (HTTP-500 for
http, some scary messages for ssh). Abort error have been properly reported for
"push" for a long time, there is not reason to be different for 'getbundle'. We
properly catch such error and report them back the best way available. For
bundle, we issue a valid bundle2 reply (as expected by the client) with an
'error:abort' part. With bundle1 we do as best as we can depending of http or
ssh.
2017-02-10 18:20:58 +01:00
Pierre-Yves David
695fa85daa getbundle: cleanly handle remote abort during getbundle
bundle2 allow the server to report error explicitly. This was initially
implemented for push but there is not reason to not use it for pull too. This
changeset add logic similar to the one in 'unbundle' to the
client side of 'getbundle'. That logic make sure the error is properly reported
as "remote". This will allow the server side of getbundle to send clean "Abort"
message in the next changeset.
2017-02-10 18:17:20 +01:00
Pierre-Yves David
d00dbd00d9 bundle1: fix bundle1-denied reporting for pull over ssh
Changeset a0966f529e1b introduced a config option to have the server deny pull
using bundle1. The original protocol has not really been design to allow that
kind of error reporting so some hack was used. It turned the hack only works on
HTTP and that ssh server hangs forever when this is used. After further
digging, there is no way to report the error in a unified way. Using `ooberror`
freeze ssh and raising 'Abort' makes HTTP return a HTTP-500 without further
details. So with sadness we implement a version that dispatch according to the
protocol used.

Now the error is properly reported, but we still have ungraceful abort after
that. The protocol do not allow anything better to happen using bundle1.
2017-02-10 18:06:08 +01:00
Pierre-Yves David
5b07cfa3b3 bundle1: display server abort hint during unbundle
The code was printing the abort message but not the hint. This is now fixed.
2017-02-10 17:56:52 +01:00
Pierre-Yves David
64f57e513b bundle1: fix bundle1-denied reporting for push over ssh
Changeset a0966f529e1b introduced a config option to have the server deny push
using bundle1. The original protocol has not really be design to allow such kind
of error reporting so some hack was used. It turned the hack only works on HTTP
and that ssh wire peer hangs forever when the same hack is used. After further
digging, there is no way to report the error in a unified way. Using 'ooberror'
freeze ssh and raising 'Abort' makes HTTP return a HTTP500 without further
details. So with sadness we implement a version that dispatch according to the
protocol used.

We also add a test for pushing over ssh to make sure we won't regress in the
future. That test show that the hint is missing, this is another bug fixed in
the next changeset.
2017-02-10 17:56:59 +01:00
Pierre-Yves David
e8a7ecc281 bundle2: keep hint close to the primary message when remote abort
The remote hint message was ignored when reporting the remote error and
passed to the local generic abort error. I think I might initially have
tried to avoid reimplementing logic controlling the hint display depending of
the verbosity level. However, first, there does not seems to have such verbosity
related logic and second the resulting was wrong as the primary error and the
hint were split apart. We now properly print the hint as remote output.
2017-02-10 17:56:47 +01:00
FUJIWARA Katsunori
2afd920706 misc: update year in copyright lines
This patch also makes some expected output lines in tests glob-ed for
persistence of them.

BTW, files below aren't yet changed in 2017, but this patch also
updates copyright of them, because:

    - mercurial/help/hg.1.txt

      almost all of "man hg" output comes from online help of hg
      command, and is already changed in 2017

    - mercurial/help/hgignore.5.txt
    - mercurial/help/hgrc.5

      "copyright 2005-201X Matt Mackall" in them mentions about
      copyright of Mercurial itself
2017-02-12 02:23:33 +09:00
Durham Goode
2971a9e1cb treemanifest: make node reuse match flat manifest behavior
In a flat manifest, a node with the same content but different parents is still
considered a new node. In the current tree manifests however, if the content is
the same, we ignore the parents entirely and just reuse the existing node.

In our external treemanifest extension, we want to allow having one treemanifest
for every flat manifests, as a way of easeing the migration to treemanifests. To
make this possible, let's change the root node treemanifest behavior to match
the behavior for flat manifests, so we can have a 1:1 relationship.

While this sounds like a BC breakage, it's not actually a state users can
normally get in because: A) you can't make empty commits, and B) even if you try
to make an empty commit (by making a commit then amending it's changes away),
the higher level commit logic in localrepo.commitctx() forces the commit to use
the original p1 manifest node if no files were changed. So this would only
affect extensions and automation that reached passed the normal
localrepo.commit() logic straight into the manifest logic.
2017-03-01 16:19:41 -08:00
Augie Fackler
0ab8866ffd help: update help.internalstable for new censor docs 2017-03-10 17:37:39 -05:00
Augie Fackler
007f68b225 parsers: drop old nonnormalentries method
This is okay to do because the Python will fall back transparently if
the method is missing.
2017-03-10 16:54:41 -05:00
Augie Fackler
a35e22bdf9 parsers: avoid leak of nonnset and otherpset
Py_BuildValue increments the refcount, rather than stealing the
reference, which I missed in code review.
2017-03-10 16:53:00 -05:00
Gregory Szorc
967eed8566 sslutil: issue warning when [hostfingerprint] is used
Mercurial 3.9 added the [hostsecurity] section, which is better
than [hostfingerprints] in every way.

One of the ways that [hostsecurity] is better is that it supports
SHA-256 and SHA-512 fingerprints, not just SHA-1 fingerprints.

The world is moving away from SHA-1 because it is borderline
secure. Mercurial should be part of that movement.

This patch adds a warning when a valid SHA-1 fingerprint from
the [hostfingerprints] section is being used. The warning informs
users to switch to [hostsecurity]. It even prints the config
option they should set. It uses the SHA-256 fingerprint because
recommending a SHA-1 fingerprint in 2017 would be ill-advised.

The warning will print itself on every connection to a server until
it is fixed. There is no way to suppress the warning. I admit this
is annoying. But given the security implications of sticking with
SHA-1, I think this is justified. If this patch is accepted,
I'll likely send a follow-up to start warning on SHA-1
certificates in [hostsecurity] as well. Then sometime down
the road, we can drop support for SHA-1 fingerprints.

Credit for this idea comes from timeless in issue 5466.
2017-03-09 20:33:29 -08:00
Yuya Nishihara
cb8fe16f12 help: fix layout of pre-formatted text 2017-03-09 12:55:48 +09:00
Yuya Nishihara
99a5ad18ca help: fix example of revs() fileset 2017-03-09 11:01:03 +09:00
Mads Kiilerich
6945cf0f5b merge: more safe detection of criss cross merge conflict between dm and r
0b5f1f2efc77 introduced handling of a crash in this case. A review comment
suggested that it was not entirely obvious that a 'dm' always would have a 'r'
for the source file.

To mitigate that risk, make the code more conservative and make less
assumptions.
2017-02-01 02:10:30 +01:00
Mads Kiilerich
120b66d101 merge: fix crash on criss cross merge with dir move and delete (issue5020)
Work around that 'dm' in the data model only can have one operation for the
target file, but still can have multiple and conflicting operations on the
source file where the other operation is a 'rm'. The move would thus fail with
'abort: No such file or directory'.

In this case it is "obvious" that the file should be removed, either before or
after moving it. We thus keep the 'rm' of the source file but drop the 'dm'.

This is not a pretty fix but quite "obviously" safe (famous last words...) as
it only touches a rare code path that used to crash. It is possible that it
would be better to swap the files for 'dm' as suggested on
https://bz.mercurial-scm.org/show_bug.cgi?id=5020#c13 but it is not entirely
obvious that it not just would create conflicts on the other file. That can be
revisited later.
2017-01-31 03:25:59 +01:00
Martin von Zweigbergk
06f115a93e util: make sortdict.keys() return a copy
dict.keys() is documented to return a copy, so it's surprising that
sortdict.keys() did not. I noticed this because we have an extension
that calls readlocaltags(). That method tries to remove any tags that
point to non-existent revisions (most likely stripped). However, since
it's unintentionally working on the instance it's modifying, it
sometimes fails to remove tags when there are multiple bad tags in a
row. This was not caught because localrepo.tags() does an additional
layer of filtering.

sortdict is also used in other places, but I have not checked whether
its keys() and/or __delitem__() methods are used there.
2017-01-30 22:58:56 -08:00
Yuya Nishihara
74023f2b13 revset: prevent using outgoing() and remote() in hgweb session (BC)
outgoing() and remote() may stall for long due to network I/O, which seems
unsafe per definition, "whether a predicate is safe for DoS attack." But I'm
not 100% sure about this. If our concern isn't elapsed time but CPU resource,
these predicates are considered safe. Perhaps that would be up to the
web/application server configuration?

Anyway, outgoing() and remote() wouldn't be useful in hgweb, so I think
it's okay to ban them.
2017-01-20 21:33:18 +09:00
Sean Farley
e145fc2df7 ui: rename tmpdir parameter to more specific repopath
This was requested by Augie and I agree that repopath is more
descriptive.
2017-01-18 18:25:51 -08:00
Gregory Szorc
9c03a7696d statprof: require input file
statprof has a __main__ handler that allows viewing of previously
written data files. As Yuya pointed out during review, 82ee01726a77
broke this. This patch fixes that.
2017-01-18 22:45:07 -08:00
Sean Farley
a405503f7a cmdutil: add tmpdir parament to ui.edit calls 2017-01-16 21:15:21 -08:00
Sean Farley
9280f19af2 ui: add a parameter to set the temporary directory for edit
Until callsites are updated, this will have no effect. Once callsites
are updated, specifying experimental.editortmpinhg will create editor
temporary files in a subdirectory of .hg, which will make it easier
for tool integrations to determine what repository is in play when
they're asked to edit an hg-related file.
2017-01-16 21:05:22 -08:00
Pulkit Goyal
f38d10e539 help: update help for hg update which was misleading (issue5427) 2017-01-18 03:44:19 +05:30
Matt Harbison
511b164fad templater: add '{envvars}' to access environment variables
Since the option for ui.exportableenviron is experimental, so is this template
until the underlying API is sorted out.
2017-01-17 23:12:54 -05:00