Commit Graph

29396 Commits

Author SHA1 Message Date
Kostia Balytskyi
a6f612e44f rebase: move handling of obsolete commits to be a separate RR class method 2016-07-01 14:09:53 +02:00
Kostia Balytskyi
c56035ebe4 rebase: move rebase finish logic to be a method of the RR class
Rebase finish logic includes collapsing working directorystate into
a single commit, moving bookmarks, clearing status and collapsemsg files,
reporting skipped commits to the user and obsoleting precursors of the
newly created commits.
2016-07-01 14:09:53 +02:00
Kostia Balytskyi
aa32920473 rebase: move core rebase logic to be a method of the RR class 2016-07-01 14:09:53 +02:00
Kostia Balytskyi
5b06bb7da5 rebase: move local variable 'extrafn' to the RR class 2016-07-01 14:09:53 +02:00
Kostia Balytskyi
ae0baad3c5 rebase: move local variable 'currentbookmarks' to the RR class 2016-07-01 14:09:53 +02:00
Kostia Balytskyi
f2b722d727 rebase: make collapsing use explicit logic to decide on the rev to reuse
This code:

    for rev in sortedstate:
        ...
    ...
    newnode = concludenode(repo, rev, p1, rbsrt.external,
                           commitmsg=commitmsg,
                           extrafn=extrafn, editor=editor,
                           keepbranches=rbsrt.keepbranchesf,
                           date=rbsrt.date)

uses 'rev' variable in 'concludenode' function invocation. It is not
explicitly assigned before, but its value comes as last value or 'rev' in
a for loop, e.g. last element in a 'sortedstate'. IMO this a bad style and it
also makes it hard to refactor the function, so it is better to explicitly
define the value passed to 'concludenode'.
2016-07-01 14:09:53 +02:00
Kostia Balytskyi
936c3aec9f rebase: move new rebase preparation to be a method of the RR class
This commit moves logic that prepares the execution of a new rebase
operation to be a method of the rebaseruntime class.
2016-07-01 14:09:53 +02:00
Kostia Balytskyi
0946a3aa1d rebase: move abort/continue prep to be a method of the RR class
This commit moves logic that prepares the execution of abort and
continue phases or rebase operation to be a method of the rebaseruntime
class.
2016-07-01 14:09:53 +02:00
Gregory Szorc
5255c3f24b hgweb: expose list of per-repo labels to templates
hgweb currently offers limited functionality for "classifying"
repositories. This patch aims to change that.

The web.labels config option list is introduced. Its values
are exposed to the "index" and "summary" templates. Custom
templates can use template features like ifcontains() to e.g.
look for the presence of a specific label and engage specific
behavior. For example, a site operator may wish to assign a
"defunct" label to a repository so the repository is prominently
marked as dead in repository indexes.
2016-06-30 18:59:53 -07:00
Sean Farley
bae0386e22 histedit: move autoverb rule to the commit it matches
Inspired by how 'git rebase -i' works, we move the autoverb to the
commit line summary that it matches. We do this by iterating over all
rules and inserting each non-autoverb line into a key in an ordered
dictionary. If we find an autoverb line later, we then search for the
matching key and append it to the list (which is the value of each key
in the dictionary). If we can't find a previous line to move to, then we
leave the rule in the same spot.

Tests have been updated but the diff looks a little messy because we
need to change one of the summary lines so that it will actually move to
a new spot. On top of that, we added -q flags to future some of the
output and needed to change the file it modified so that it wouldn't
cause a conflict.
2016-06-21 14:58:49 -07:00
Henrik Stuart
5de4cefa8f largefiles: fix support for local largefiles while using share extension
Prior to revision 149be6a0072e, largefiles were saved in the local repository,
even if it was using the share extension. After that change, all largefiles are
now stored in the shared repository. However, the backward compatibility for
existing largefiles already placed in the local repository was never tested,
and has been broken since.
2016-06-07 08:32:33 +02:00
Matt Mackall
d3fd1530f8 bdiff: remove effectively dead code
Now that we extend matches backwards in the inner loop, the final
adjustment has no effect.

(A similar extension for the forward direction is trickier and has
less benefit.)
2016-06-02 17:11:32 -05:00
Matt Mackall
18c0002f9b bdiff: extend matches across popular lines
For very large diffs that have large numbers of identical lines (JSON
dumps) that also have large blocks of identical text, bdiff could become
confused about which block matches which because it can only match
very limited regions. The result is very large diffs for small sets of edits.

The earlier recursion rebalancing fix made this behavior more frequent because
it's now more prone to match block 1 to block 2. One frequent user of
large JSON files reported being unable to pass the resulting diffs
through their code review system.

Prior to this change, bdiff would calculate the length of a match at
(i, j) as 1 + length found at (i-1, j-1). With large number of popular
(ignored) lines, this often meant matches couldn't be extended
backwards at all and thus all matching regions were very small.
Disabling the popularity threshold is not an option because it brings
back quadratic behavior.

Instead, we extend a match backwards until we either found a previously
discovered match or we find a mismatching line. This thus successfully
bridges over any popular lines inside and before a matching region.
The larger regions then significant reduce the probability of confusion.
2016-06-02 17:09:06 -05:00
Danek Duvall
fd61c5191c tests-subrepo-git: use "f" to dump pwned.txt, for portability
Rather than sometimes using a complicated shell construct to dump pwned.txt
(if it wasn't expected to exist, but might, if something were broken) or
just cat (if it was expected to exist), just use the "f" utility, which
will be consistent in its behavior across different platforms.

Also make sure that *something* gets put into pwned.txt, even if we ended
up typoing the message variable.
2016-06-02 16:18:44 -07:00
Mads Kiilerich
f1004d7ba4 bundle2: don't assume ordering of heads checked after push
Usually, the heads will have the same ordering in handlecheckheads. Insisting
on the same ordering is however an unnecessary constraint that in some custom
cases can cause pushes to fail even though the actual heads didn't change. This
caused production issues for us in combination with the current version of
https://bitbucket.org/Unity-Technologies/hgwebcachingproxy/ .
2016-06-01 21:40:52 +02:00
Matt Mackall
17b79941e5 Added signature for changeset 9690381fa227 2016-06-01 15:48:38 -05:00
Danek Duvall
aee88deefe tests-subrepo-git: emit a different "pwned" message based on the test
Having a single "pwned" message which may or may not be emitted during the
tests for CVE-2016-3068 leads to extra confusion.  Allow each test to emit
a more detailed message based on what the expectations are.

In both cases, we expect a version of git which has had the vulnerability
plugged, as well as a version of mercurial which also knows about
GIT_ALLOW_PROTOCOL.  For the first test, we make sure GIT_ALLOW_PROTOCOL is
unset, meaning that the ext-protocol subrepo should be ignored; if it
isn't, there's either a problem with mercurial or the installed copy of
git.

For the second test, we explicitly allow ext-protocol subrepos, which means
that the subrepo will be accessed and a message emitted confirming that
this was, in fact, our intention.
2016-05-27 15:20:03 -07:00
Danek Duvall
27b40ab5d7 tests-subrepo-git: make the "pwned" message output in a stable order
The "pwned" message from this test gets gets sent to stderr, and so may get
emitted in different places from run to run in the rest of mercurial's
output.  This patch forces the message to go to a specific file instead,
whose existence and contents we can examine at a stable point in the test's
execution.
2016-05-27 15:10:38 -07:00
Sean Farley
f5c99064dd histedit: use _getsummary in ruleeditor
This patch uses our common method instead of duplicating logic.
2016-05-27 14:03:00 -07:00
Sean Farley
0aadad3fdc histedit: use _getsummary in torule
This patch uses our common method instead of duplicating logic.
2016-05-27 14:02:36 -07:00
Sean Farley
2a852d9312 histedit: extract common summary code into method
We're going to need to use this code in our autoverb logic so let's
extract it now and save ourselves from code duplication.
2016-05-27 14:00:12 -07:00
Danek Duvall
588625cce7 test-cache-abuse: correct for different hunk headers between Solaris and GNU
When diffing against an empty file, Solaris diff uses 1 to designate the
first line of the empty file (either -1,0 on the left or +1,0 on the right)
while GNU diff uses 0 (-0,0 and +0,0).  We use a glob here to make sure the
test passes with either toolchain.

I've not added tests to check-code because there are scads of places in the
tests where the GNU format is used due to that being the format that "hg
diff" and "hg export" use, and changing those to use globs seems wrong.
2016-05-27 11:14:29 -07:00
Javi Merino
b9800f248e lazymanifest: fix typo s/typles/tuples/ 2016-05-27 21:24:05 +02:00
Sean Farley
a8452be140 histedit: remove unneeded initial parameter
Now that the autoverb logic no longer acts on an individual rule line,
we don't need this parameter since we apply our logic just once at the
time of initialization.
2016-05-26 15:43:00 -07:00
Sean Farley
60d7ad0f37 histedit: move autoverb logic from torule to ruleeditor
This is needed for an upcoming change that will automatically rearrange the
rules based on the commit message. Before this patch, the autoverb logic only
applied to one rule at a time. This moves that logic one step up so that it can
iterate over all the rules and rearrange as needed.
2016-05-26 16:46:10 -07:00
Martin von Zweigbergk
82a5e7d944 treemanifests: actually strip directory manifests
Stripping has only partly worked since f41815302d49 (repair: use cg3
for treemanifests, 2016-01-19): the bundle seems to have been created
correctly, but revlog entries in subdirectory revlogs were not
stripped. This meant that e.g. "hg verify" would fail after stripping
in a tree manifest repo.

To find the revisions to strip, we simply iterate over all directories
in the repo (included in store.datafiles()). This is inefficient for
stripping few commits, but efficient for stripping many commits. To
optimize for stripping few commits, we could instead walk the tree
from the root and find modified subdirectories, just like we do in the
changegroup code. I'm leaving that for another day.
2016-06-30 13:06:19 -07:00
Jun Wu
033b57c8df logtoprocess: do not leak the ui object in uisetup
logtoprocess.log should use "self" passed in function arguments instead
of the "ui" object from outside the function.
2016-06-30 15:26:11 +01:00
Jun Wu
35f0266cea chgserver: document why we don't merge mtimehash and confighash
People may get confused about chg's mtimehash and confighash design: why two
hashes instead of just one. This patch adds text addressing the concern.
2016-06-29 23:53:20 +01:00
Jun Wu
1dbd891ce1 extensions: move uisetup and extsetup to standalone functions
This is to make them wrap-able. chgserver wants to know if an extension
accesses config or environment variables during uisetup and extsetup and
include them in confighash accordingly.
2016-06-30 10:31:50 +01:00
Matt Mackall
c0d551e8ec merge with stable 2016-07-01 16:02:56 -05:00
Anton Shestakov
f13dffc250 hgweb: add absolute urls for archives in json-summary 2016-07-01 13:54:35 +08:00
Anton Shestakov
43becb126d tests: allow bz2 archives in test-hgweb-json.t
Only testing a specific type because list items seem to be in arbitrary order.
2016-07-01 13:36:59 +08:00
Pulkit Goyal
123aebf3ce keepalive: switch from thread to threading module
The thread module in py3 is renamed to _thread, but we can use
 the high level threading module instead.
2016-07-01 19:17:16 +05:30
Pulkit Goyal
af9d7f66d0 py3: conditionalize httplib import
The httplib library is renamed to http.client in python 3. So the
import is conditionalized and a test is added in check-code to warn
to use util.httplib
2016-06-28 16:01:53 +05:30
Gregory Szorc
6adc4b7bac sslutil: emit warning when no CA certificates loaded
If no CA certificates are loaded, that is almost certainly a/the
reason certificate verification fails when connecting to a server.

The modern ssl module in Python 2.7.9+ provides an API to access
the list of loaded CA certificates. This patch emits a warning
on modern Python when certificate verification fails and there are
no loaded CA certificates.

There is no way to detect the number of loaded CA certificates
unless the modern ssl module is present. Hence the differences
in test output depending on whether modern ssl is available.

It's worth noting that a test which specifies a CA file still
renders this warning. That is because the certificate it is loading
is a x509 client certificate and not a CA certificate. This
test could be updated if anyone is so inclined.
2016-06-29 19:43:27 -07:00
Gregory Szorc
169cc46dab tests: test case where default ca certs not available
I'm not a fan of TLS tests not testing both branches of a possible
configuration. While we have test coverage of the inability to validate
a cert later in this file, I insist that we add this branch so
our testing of security code is extra comprehensive.
2016-06-29 19:49:39 -07:00
Gregory Szorc
9e29784a89 sslutil: don't load default certificates when they aren't relevant
Before, we would call SSLContext.load_default_certs() when
certificate verification wasn't being used. Since
SSLContext.verify_mode == ssl.CERT_NONE, this would ideally
no-op. However, there is a slim chance the loading of system
certs could cause a failure. Furthermore, this behavior
interfered with a future patch that aims to provide a more
helpful error message when we're unable to load CAs.

The lack of test fallout is hopefully a sign that our
security code and tests are in a relatively good state.
2016-06-29 19:38:24 -07:00
Gregory Szorc
9653d9a563 sslutil: display a better error message when CA file loading fails
Before, sslcontext.load_verify_locations() would raise a
ssl.SSLError which would be caught further up the stack and converted
to a urlerror. By that time, we lost track of what actually errored.

Trapping the error here gives users a slightly more actionable error
message.

The behavior between Python <2.7.9 and Python 2.7.9+ differs. This
is because our fake SSLContext class installed on <2.7.9 doesn't
actually do anything during load_verify_locations: it defers actions
until wrap_socket() time. Unfortunately, a number of errors can occur
at wrap_socket() time and we're unable to ascertain what the root
cause is. But that shouldn't stop us from providing better error
messages to people running a modern and secure Python version.
2016-06-29 19:37:38 -07:00
Gregory Szorc
3481b4d0f7 tests: add test for empty CA certs file
smf reported that an environment with no loaded CA certs resulted
in a weird error. I'd like to detect this a bit better so we can
display an actionable error message.

The actual error being globbed over in this patch is "unknown error"
with a ssl.c line number. That isn't useful at all.
2016-06-29 18:15:28 -07:00
Maciej Fijalkowski
8e7a874bdf internals: move the bitmanipulation routines into its own file
This is to allow more flexibility with the C sources -- now the
bitmanipulation routines can be safely imported without importing Python.h
2016-06-06 13:08:13 +02:00
Martijn Pieters
5eddc7a7b3 journal: new experimental extension
Records bookmark locations and shows you where bookmarks were located in the
past.

This is the first in a planned series of locations to be recorded; a future
patch will add working copy (dirstate) tracking, and remote bookmarks will be
supported as well, so the journal storage format should be fairly generic to
support those use-cases.
2016-06-24 16:12:05 +01:00
Augie Fackler
6a644ad048 httpclient: update to 54868ef054d2 of httpplus
As of that revision, httpplus fully supports Python 3, including
mimicing all the subtle behavior changes around headers in Python 3's
http.client.
2016-06-27 11:53:50 -04:00
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