Commit Graph

29214 Commits

Author SHA1 Message Date
liscju
41cd14dafa py3: make largefiles/__init__.py use absolute_import 2016-05-06 14:28:32 +02:00
liscju
d655e60e3c largefiles: move basestore._openstore into new module to remove cycle 2016-06-04 16:53:44 +02:00
Kostia Balytskyi
5501c91461 revset: make filteredset.__nonzero__ respect the order of the filteredset
This fix allows __nonzero__ to respect the direction of iteration of the
whole filteredset. Here's the case when it matters. Imagine that we have a
very large repository and we want to execute a command like:

    $ hg log --rev '(tip:0) and user(ikostia)' --limit 1

(we want to get the latest commit by me).

Mercurial will evaluate a filteredset lazy data structure, an
instance of the filteredset class, which will know that it has to iterate
in a descending order (isdescending() will return True if called). This
means that when some code iterates over the instance of this filteredset,
the 'and user(ikostia)' condition will be first checked on the latest
revision, then on the second latest and so on, allowing Mercurial to
print matches as it founds them. However, cmdutil.getgraphlogrevs
contains the following code:

    revs = _logrevs(repo, opts)
    if not revs:
        return revset.baseset(), None, None

The "not revs" expression is evaluated by calling filteredset.__nonzero__,
which in its current implementation will try to iterate the filteredset
in ascending order until it finds a revision that matches the 'and user(..'
condition. If the condition is only true on late revisions, a lot of
useless iterations will be done. These iterations could be avoided if
__nonzero__ followed the order of the filteredset, which in my opinion
is a sensible thing to do here.

The problem gets even worse when instead of 'user(ikostia)' some more
expensive check is performed, like grepping the commit diff.


I tested this fix on a very large repo where tip is my commit and my very
first commit comes fairly late in the revision history. Results of timing
of the above command on that very large repo.

-with my fix:
real    0m1.795s
user    0m1.657s
sys     0m0.135s

-without my fix:
real    1m29.245s
user    1m28.223s
sys     0m0.929s

I understand that this is a very specific kind of problem that presents
itself very rarely, only on very big repositories and with expensive
checks and so on. But I don't see any disadvantages to this kind of fix
either.
2016-06-02 22:39:01 +01:00
FUJIWARA Katsunori
37b26ec7b6 phases: make writing phaseroots file out avoid ambiguity of file stat
Cached attribute repo._phasecache uses stat of '.hg/phaseroots' file
to examine validity of cached contents. If writing '.hg/phaseroots'
file out keeps ctime, mtime and size of it, change is overlooked, and
old contents cached before change isn't invalidated as expected.

To avoid ambiguity of file stat, this patch writes '.hg/phaseroots'
file out with checkambig=True.

This patch is a part of "Exact Cache Validation Plan":

    https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
2016-06-03 00:44:20 +09:00
FUJIWARA Katsunori
f90241706d dirstate: make writing branch file out avoid ambiguity of file stat
Cached attribute dirstate._branch uses stat of '.hg/branch' file to
examine validity of cached contents. If writing '.hg/branch' file out
keeps ctime, mtime and size of it, change is overlooked, and old
contents cached before change isn't invalidated as expected.

To avoid ambiguity of file stat, this patch writes '.hg/branch' file
out with checkambig=True.

This patch is a part of "Exact Cache Validation Plan":

    https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
2016-06-03 00:44:20 +09:00
FUJIWARA Katsunori
00e016ed43 dirstate: make writing dirstate file out avoid ambiguity of file stat
Cached attribute repo.dirstate uses stat of '.hg/dirstate' file to
examine validity of cached contents. If writing '.hg/dirstate' file
out keeps ctime, mtime and size of it, change is overlooked, and old
contents cached before change isn't invalidated as expected.

To avoid ambiguity of file stat, this patch writes '.hg/dirstate' file
out with checkambig=True.

The former diff hunk changes the code path for "dirstate.write()", and
the latter changes the code path for "dirstate.savebackup()".

This patch is a part of "Exact Cache Validation Plan":

    https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
2016-06-03 00:44:20 +09:00
FUJIWARA Katsunori
bb78b3c1b0 bookmarks: make writing files out avoid ambiguity of file stat
Cached attribute repo._bookmarks uses stat of '.hg/bookmarks' and
'.hg/bookmarks.current' files to examine validity of cached
contents. If writing these files out keeps ctime, mtime and size of
them, change is overlooked, and old contents cached before change
isn't invalidated as expected.

To avoid ambiguity of file stat, this patch writes '.hg/bookmarks' and
'.hg/bookmarks.current' files out with checkambig=True.

This patch is a part of "Exact Cache Validation Plan":

    https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
2016-06-03 00:44:20 +09:00
FUJIWARA Katsunori
1d5601ef04 transaction: avoid ambiguity of file stat at closing transaction
Files below, which might be changed at closing transaction, are used
to examine validity of cached properties. If changing keeps ctime,
mtime and size of a file, change is overlooked, and old contents
cached before change isn't invalidated as expected.

  - .hg/bookmarks
  - .hg/dirstate
  - .hg/phaseroots

To avoid ambiguity of file stat, this patch writes files out with
checkambig=True at closing transaction.

checkambig becomes True only at closing (= 'not suffix'), because stat
information of '.pending' file isn't used to examine validity of
cached properties.

This patch is a part of "Exact Cache Validation Plan":

    https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
2016-06-03 00:44:20 +09:00
FUJIWARA Katsunori
01b2069695 util: add __ne__ to filestat class for consistency
This is follow up for 41ed93728910, which introduced filestat class.
2016-06-03 00:44:20 +09:00
Sean Farley
3b8b645648 debian: forgot to make debian/rules executable in 9dad5512e855 2016-05-01 15:26:41 -07:00
Sean Farley
a260b9c4ef debian: add wish to suggests
Debian maintainers already have this and lintian warns us about not
listing 'wish' as a dependency or suggestion so this patch does indeed
just that. The issue, by the way, is that we are shipping hgk (which is
written in tcl/tk) so we should be good citizens and list wish (a meta
package for tcl/tk) as a dependency.
2016-04-30 21:21:34 -07:00
Sean Farley
dc865d7f73 hg-ssh: copy doc string to man page
This corrects a warning from lintian that we're shipping an executable without
a man page. Since there is a doc string in the text, let's use that for the man
page.
2016-05-06 23:03:41 -07:00
Matt Mackall
8568a2cad9 progress: stop excessive clearing (issue4801)
The progress bar was being cleared on every write(), regardless of
whether it was currently displayed. This could foul up the display of
any writes that didn't include a linebreak.

In particular, the win32 mode of the color extension was turning
single prompt string writes into two writes, and the resulting
clear/write/clear/write pattern was making the prompt invisible.

We fix this by insisting that we have shown a progress bar and haven't
just cleared it (setting lastprint to 0).

Conveniently, the test suite already had instances of duplicate
clears.. that are now cleared up.
2016-05-06 17:53:06 -05:00
Pierre-Yves David
981a2cbeeb deprecation: gate deprecation warning behind devel configuration
Regular users are not supposed to be exposed to the API deprecation warnings.
We now only issue them when the developper warnings are enabled.
2016-05-05 16:29:31 +02:00
Augie Fackler
5a2af0bc22 bookmarks: properly invalidate volatile sets when writing bookmarks
This corrects a regression introduced during the 3.7 cycle, but which
went undetected due to the surviving-but-deprecated write() method on
bmstore.
2016-05-04 22:44:30 -04:00
Augie Fackler
eb85279af2 test-obsolete: update extension in test to actually work
This hasn't been testing anything since partway through the 3.7 cycle
due to unrelated refactoring. Sadly, the behavior it was trying to
prevent reemerged in the codebase at that time. A fix is in the next
patch, because proving that the fix was actually correct ended up
being trickier than I expected.
2016-05-05 15:41:37 +02:00
Mike Hommey
50e9c3bb84 bundle2: properly request phases during getbundle
getbundle was requesting the "phase" namespace instead of the "phases"
namespace, which led to the client still requesting the phases
separately after getbundle finished.
2016-05-05 20:57:38 +09:00
Matt Mackall
539d61b5dc Added signature for changeset 38662341e581 2016-05-01 14:36:12 -05:00
Pierre-Yves David
b6f7b74a14 style: remove namespace class
For better or worse, our coding do not use use class for pure namespacing. We
remove the class introduced in e0db55ecbc14.
2016-04-16 16:01:24 -07:00
Pierre-Yves David
1f0c33027d style: don't use capital letter for constant
For better or worse, our coding do not use all caps for constants. We rename
constant name introduced in e0db55ecbc14.
2016-04-16 15:59:30 -07:00
Gregory Szorc
0f55e28908 sslutil: print the fingerprint from the last hash used
Before, we would always print the unprefixed SHA-1 fingerprint when
fingerprint comparison failed. Now, we print the fingerprint of the
last hash used, including the prefix if necessary. This helps ensure
that the printed hash type matches what is in the user configuration.

There are still some cases where this can print a mismatched hash type.
e.g. if there are both SHA-1 and SHA-256 fingerprints in the config,
we could print a SHA-1 hash if it comes after the SHA-256 hash. But
I'm inclined to ignore this edge case.

While I was here, the "section" variable assignment has been moved to
just above where it is used because it is now only needed for this
error message and it makes the code easier to read.
2016-06-04 11:16:08 -07:00
Gregory Szorc
2337effc05 sslutil: make cert fingerprints messages more actionable
The previous warning and abort messages were difficult to understand.
This patch makes them slightly better.

I think there is still room to tweak the messaging. And as we adopt
new security defaults, these messages will certainly change again.
But at least this takes us a step in the right direction.

References to "section" have been removed because if no fingerprint
is defined, "section" can never be "hostfingerprints." So just print
"hostsecurity" every time.
2016-05-31 19:21:08 -07:00
Gregory Szorc
a59ed87b33 sslutil: refactor code for fingerprint matching
We didn't need to use a temporary variable to indicate success because
we just return anyway.

This refactor makes the code simpler. While we're here, we also call
into formatfingerprint() to ensure the fingerprint from the proper
hashing algorithm is logged.
2016-05-30 15:43:03 -07:00
Gregory Szorc
1a6d495880 sslutil: print SHA-256 fingerprint by default
The world is starting to move on from SHA-1. A few commits ago, we
gained the ability to define certificate fingerprints using SHA-256
and SHA-512.

Let's start printing the SHA-256 fingerprint instead of the SHA-1
fingerprint to encourage people to pin with a more secure hashing
algorithm.

There is still a bit of work to be done around the fingerprint
messaging. This will be addressed in subsequent commits.
2016-05-30 15:42:39 -07:00
Gregory Szorc
9ee23a401c sslutil: move and change warning when cert verification is disabled
A short time ago, validatesocket() didn't know the reasons why
cert verification was disabled. Multiple code paths could lead
to cert verification being disabled. e.g. --insecure and lack
of loaded CAs.

With the recent refactorings to sslutil.py, we now know the reasons
behind security settings. This means we can recognize when the user
requested security be disabled (as opposed to being unable to provide
certificate verification due to lack of CAs).

This patch moves the check for certificate verification being disabled
and changes the wording to distinguish it from other states. The
warning message is purposefully more dangerous sounding in order
to help discourage people from disabling security outright.

We may want to add a URL or hint to this message. I'm going to wait
until additional changes to security defaults before committing to
something.
2016-05-30 13:15:53 -07:00
Gregory Szorc
f84915da36 sslutil: add devel.disableloaddefaultcerts to disable CA loading
There are various tests for behavior when CA certs aren't loaded.
Previously, we would pass --insecure to disable loading of CA
certs. This has worked up to this point because the error message
for --insecure and no CAs loaded is the same. Upcoming commits will
change the error message for --insecure and will change behavior
when CAs aren't loaded.

This commit introduces the ability to disable loading of CA certs
by setting devel.disableloaddefaultcerts. This allows a testing
backdoor to disable loading of CA certs even if system/default
CA certs are available. The flag is purposefully not exposed to
end-users because there should not be a need for this in the wild:
certificate pinning and --insecure provide workarounds to disable
cert loading/validation.

Tests have been updated to use the new method. The variable used
to disable CA certs has been renamed because the method is not
OS X specific.
2016-06-01 19:57:20 -07:00
Gregory Szorc
46dd18b38d sslutil: store flag for whether cert verification is disabled
This patch effectively moves the ui.insecureconnections check to
_hostsettings(). After this patch, validatesocket() no longer uses the
ui instance for anything except writing messages.

This patch also enables us to introduce a per-host config option
for disabling certificate verification.
2016-05-30 11:20:31 -07:00
Gregory Szorc
f49cf73d42 sslutil: remove "strict" argument from validatesocket()
It was only used by mail.py as part of processing smtp.verifycert,
which was just removed.
2016-05-30 11:19:43 -07:00
Gregory Szorc
35166670e2 mail: unsupport smtp.verifycert (BC)
smtp.verifycert was accidentally broken by 799db3fe9866. And,
I believe the "loose" value has been broken for longer than that.
The current code refuses to talk to a remote server unless the
CA is trusted or the fingerprint is validated. In other words,
we lost the ability for smtp.verifycert to lower/disable security.

There are special considerations for smtp.verifycert in
sslutil.validatesocket() (the "strict" argument). This violates
the direction sslutil is evolving towards, which has all security
options determined at wrapsocket() time and a unified code path and
configs for determining security options.

Since smtp.verifycert is broken and since we'll soon have new
security defaults and new mechanisms for controlling host security,
this patch formally deprecates smtp.verifycert. With this patch,
the socket security code in mail.py now effectively mirrors code
in url.py and other places we're doing socket security.

For the record, removing smtp.verifycert because it was accidentally
broken is a poor excuse to remove it. However, I would have done this
anyway because smtp.verifycert is a one-off likely used by few people
(users of the patchbomb extension) and I don't think the existence
of this seldom-used one-off in security code can be justified,
especially when you consider that better mechanisms are right around
the corner.
2016-06-04 11:13:28 -07:00
Blake Burkhart
a5bebc504a convert: pass absolute paths to git (SEC)
Fixes CVE-2016-3105 (1/1).

Previously, it was possible for the repository path passed to git-ls-remote
to be misinterpreted as a URL.

Always passing an absolute path to git is a simple way to avoid this.
2016-04-06 22:57:46 -05:00
Matt Mackall
c9c3060889 Added signature for changeset 89e922ed00c5 2016-05-01 13:52:26 -05:00
Sean Farley
41d6e5ed5b debian: alphabetize build deps 2016-04-30 21:21:17 -07:00
Sean Farley
35d3b6884b debian: fix lintian warning about debhelper
It seems this is correct but does it work on older distros? I ran the
docker-jessie rule and didn't get any warnings.
2016-04-30 17:26:48 -07:00
Sean Farley
8b7c1af14d builddeb: remove chmod as lintian tells us
It turns out we just need debian/rules to be executable, so we do just that.
2016-04-30 17:29:12 -07:00
Sean Farley
205b5f811e builddeb: use codename in version
Apparently, this is needed to allow ppas to be built for multiple distros.
2016-04-30 11:51:45 -07:00
Pierre-Yves David
aab6e0ee27 rebase: restrict rebase destination to the pulled set (issue5214)
Before this patch, `hg pull --rebase` would be a strict sequence of `hg pull`
followed by `hg rebase` if anything was pulled.

Now that rebase pick his default destination the same way than merge, than
`hg rebase` step would abort in the case the repo already had multiple anonymous
heads (because of the ambiguity). (changed in 8822059a608a)

The intend of the user with `hg pull --rebase` is clearly to rebase on pulled
content. This used to be (mostly) enforced by the former default destination for
rebase, "tipmost changeset of the branch" as the tipmost would likely a
changeset that just got pulled. But this intended was no longer enforced with
the new defaul destination (unified with merge).

This changeset makes use of the '_destspace' mechanism introduced in the previous
changeset to enforce this.

This partially fixes issue5214 as no change at all have been made to the new
handling of the case with bookmark (unified with merge).
2016-04-30 18:39:39 +02:00
Pierre-Yves David
da0dc4d591 destutil: add the ability to specify a search space for rebase destination
In the 'hg pull --rebase', we don't want to pick a rebase destination unrelated
to the pull, we lay down basic infrastructure to allow such restriction on
stable (before 3.8 release) in this case. See issue 5214 for details.

Actual usage and test will be in the next patch.
2016-04-30 18:41:08 +02:00
Gregory Szorc
ad77315d76 sslutil: restore old behavior not requiring a hostname argument (issue5210)
This effectively backs out changeset 60b56b3206cc.

The http library behind ui.http2=true isn't specifying the hostname.
It is the day before the expected 3.8 release and we don't want to ship
a regression.

I'll try to restore this requirement in the 3.9 release cycle as part
of planned improvements to Mercurial's SSL/TLS interactions.
2016-04-30 09:26:47 -07:00
Matt Mackall
9cda77e1b1 tests: test a variety of cache invariants
We've historically had a problem maintaining the expected invariants
on our caches, especially when introducing new caches. This tests
documents the invariants and exercises them across most of our
existing cache files.
2016-04-28 16:38:15 -05:00
Matt Mackall
a684f1361f repoview: ignore unwritable hidden cache
The atomictemp.close() file attempts to do a rename, which can fail.
Moving the close inside the exception handler fixes it.

This doesn't fit well with the with: pattern, as it's the finalizer
that's failing.
2016-04-28 16:26:18 -05:00
Matt Mackall
37e825cd02 tags: silence hgtagsfnodes reading failures
tryread() doesn't handle "is a directory" errors and presumably
others. We might not want to globally swallow such tryread errors, so
we replace with our own try/except handling.

An upcoming test will use directories as a portable stand-in for
various bizarre circumstances that cache read/write code should be
robust to.
2016-04-28 15:40:43 -05:00
Matt Mackall
8ad154abd6 tags: silence cache parsing errors
Follow our standard STFU cache-handling pattern
2016-04-28 15:35:54 -05:00
Wagner Bruna
9fe82bf618 i18n-pt_BR: synchronized with 2ae54831e766 2016-05-01 00:12:56 -03:00
Sean Farley
ca1aff7fdb ubuntu-xenial-ppa: add makefile rule 2016-04-27 01:07:40 -07:00
Sean Farley
83ef160aa1 ubuntu-wily-ppa: add makefile rule 2016-04-27 01:02:56 -07:00
Sean Farley
49dcbb48fa ubuntu-trusty-ppa: add makefile rule 2016-04-27 00:27:10 -07:00
Sean Farley
492deac0a3 ubuntu-xenial: add makefile rule to build deb 2016-04-27 00:18:18 -07:00
Sean Farley
8d241b8149 ubuntu-wily: add makefile rule to build deb 2016-04-27 00:10:49 -07:00
Sean Farley
bf3866fc9f make: turn ubuntu docker into template
This allows us to easily add more ubuntu docker targets (which following
patches will do).

Also, we no longer need the mkdir command.
2016-04-26 23:33:17 -07:00
Sean Farley
bf3cdfa44b revsets: add docs for '%' operator 2016-04-27 14:02:18 -07:00