Commit Graph

31049 Commits

Author SHA1 Message Date
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
Gregory Szorc
8df619ffe0 setup: use setuptools on Windows (issue5400)
We've had a long, complicated history with setuptools. We want to
make it the universal default. But when we do, it breaks things.

`python setup.py build` is broken on Windows today. Forcing
the use of setuptools via FORCE_SETUPTOOLS=1 unbreaks things.

Since the previous bustage with making setuptools the default
was on !Windows, it seems safe to move ahead with the setuptools
transition on Windows. So this patch does that.
2017-03-09 19:59:52 -08:00
Yuya Nishihara
df15429e29 schemes: use br'' literal to define bytes regexp 2017-03-09 19:41:40 -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
Pierre-Yves David
18b9d6341b filecache: make 'join' abstract
All subclasses redefine this method, so we can make it abstract.
2016-08-05 14:24:53 +02:00
Pierre-Yves David
87e91693db filecache: explicitly test 'repofilecache'
The tests is actually about testing a repofilecache (it uses a fake repo). We
make this clear to prevent blockers while cleaning theses API.
2017-03-08 16:43:16 -08:00
Pierre-Yves David
6a42754a35 repofilecache: directly use 'repo.vfs.join'
The 'vfs' attribute already have all methods we need, the value of going
through the repository for this is low. so we removes it.
2016-08-05 14:25:21 +02:00
Pierre-Yves David
010d9af7e1 repofilecache: define a 'join' method
We are about to turn the 'join' method of the base class Abstract, so we need
on to be defined in the localrepo. The ultimate goal here is to be able to stop
relying for the 'localrepo' class to have a 'join' methods (there is above one
hundred methods on 'localrepo'. This change make te 'repo' file cache have its
own code so that we can prepare this change to the repostory class.


explicite join
2016-08-05 14:23:58 +02:00
Augie Fackler
5ceb2295c6 wix: add censor docs to installer script
Spotted by Matt Harbison.
2017-03-06 18:42:36 -05:00
Augie Fackler
b3e554d062 internals: add some brief documentation about censor 2017-01-23 20:17:24 -05:00
Jun Wu
c389ff2eb2 localrepo: rename proxycls to filteredrepo
When debugging in a Python shell, the type of "repo" is "proxycls", which
could confuse new people.

    In [1]: repo
    Out[1]: <mercurial.localrepo.proxycls at 0x7f65d4b976d0>

Let's rename it to "filteredrepo" to make it clearer.
2017-03-09 15:10:27 -08:00
Durham Goode
832a191f75 dirstate: track otherparent files same as nonnormal
Calling dirstate.setparents() is expensive in a large repo because it iterates
over every file in the dirstate. It does so to undo any merge state or
otherparent state files. Merge state files are already covered by
dirstate._nonnormalset, so we just need to track otherparent files in a similar
manner to avoid the full iteration here.

Fixing this shaves 20-25% off histedit in large repos.

I tested this by adding temporary debug logic to verify that the old files
processed in the loop matched the new files processed in the loop and running
the test suite.
2017-03-08 17:35:20 -08:00
Denis Laxalde
0ed26e5739 hgweb: use patch.diffhunks in webutil.diffs to simplify the algorithm
Function patch.diffhunks yields items for a "block" (i.e. a file) as a whole
so take advantage of this to simplify the algorithm and avoid parsing diff
lines to determine whether we're starting a new "block" or not. Thus we drop
to external block counter and rely on diffhunks iterations instead.
We also take advantage of the fact that patch.diffhunks() yields *lines* of
hunks (instead of a string) to avoid building a list that is ''.join-ed into a
string that is then split.

As lines in 'header' returned by patch.diffhunks() have no trailing new line,
we need to insert it ourselves to match template expectations.
2017-03-06 09:28:33 +01:00
Denis Laxalde
5d10a8a4b5 hgweb: start enumerate at 1 in webutil.diffs's inner function prettyprintlines 2017-03-06 09:44:39 +01:00
Denis Laxalde
27968948ed patch: add a diffhunks function yielding (diffheaders, hunks)
trydiff function now yield (header, hunks) tuple that are processed by
diffhunks(). Then diff() is a wrapper around diffhunks().
2017-03-03 17:20:11 +01:00
Denis Laxalde
6759ce9345 mdiff: let unidiff return (diffheader, hunks)
This will be used to make it possible to filter diff hunks based on this range
information.

Now unidiff returns a 'hunks' generator that yield tuple (hunkrange,
hunklines) coming from _unidiff() with 'newline at end of file' processing.
2017-03-03 17:46:40 +01:00
Denis Laxalde
1ec128500e mdiff: extract a checknonewline inner function in unidiff() 2017-03-03 17:46:28 +01:00
Denis Laxalde
fbe932a316 mdiff: distinguish diff headers from hunks in unidiff()
Let unidiff return the list of headers it produces (lines '--- <original>' and
'+++ <new>') apart from diff hunks. In patch.diff(), we combine headers
generated there (not specific to unified format) with those from unidiff().
By returning a list of header lines, we do not append new lines in datetag
inner function of unidiff() so that all header lines are '\n'.join-ed in a
similar way.
2017-03-03 13:51:22 +01:00
Denis Laxalde
e8f2a25582 test: end printed diff "hunks" with an empty string in test-context.py
So that the resulting diff is correct and does not include a spurious empty
line between lines "diff --git a/foo b/foo" and "--- a/foo".
2017-03-03 16:17:17 +01:00
Denis Laxalde
dab0828dbc mdiff: let _unidiff yield hunks as (<range information>, <hunk lines>)
Now _unidiff yields each hunk lines packed into a tuple with the "range
information" `(s1, l1, s2, l2)` that is used to build the typical hunk header
'@@ -s1,l1 +s2,l2 @@'.
This will be used to make it possible to filter diff hunks based on this range
information.

The new "range information" is ignored in unidiff() (only caller of _unidiff)
for now.
2017-03-02 17:22:46 +01:00
Denis Laxalde
e158e9848e mdiff: turn the comment above _unidiff into a docstring 2017-01-09 09:34:39 +01:00
Denis Laxalde
9d2de61e1a mdiff: compute newlines-splitted texts within _unidiff
There is no reason to compute splitted texts l1, l2 in unidiff() before
calling _unidiff as they are only used with the latter function.
2016-09-27 20:27:35 +02:00
Augie Fackler
7405058a22 dispatch: add pagination of two more help cases
I missed these in the last round anf Yuya spotted them in
review. Thanks!
2017-03-08 18:32:42 -05:00
Augie Fackler
d60f4a3869 help: avoid mutating passed-in keep list in formattedhelp 2017-03-08 18:31:33 -05:00
Augie Fackler
98883dec44 extensions: use [0:1] slice on config path instead of [0]
This behaves the same in Python 2 and Python 3, even though the path
is a bytes.
2017-03-03 13:32:10 -05:00
Augie Fackler
8db5d39760 extensions: use inspect module instead of func_code.co_argcount
Fixes the extsetup argspec check on Python 3.
2017-03-03 13:27:21 -05:00
Durham Goode
f20d9939b3 treemanifest: add tests covering hg diff of partial trees
Previously the hg files tests also covered the logic (i.e.
treemanifest.matches) that governed how hg diff limited its diff. In a future
patch we will be switching treemanifest.diff() to have a custom implementation,
so let's go ahead and add equivalent test coverage for hg diff.
2017-03-07 18:29:58 -08:00
Durham Goode
2d56462702 context: remove uses of manifest.matches
This removes the uses of manifest.matches in context.py in favor of the new
manifest.diff(match) api. This is part of removing manifest.matches since it is
O(manifest).

To drop the dependency on ctx._manifestmatches(s) we transfer responsibilty for
creating status oriented manifests over to ctx._buildstatusmanifest(s). This
already existed for workingctx, we just need to implement a simple version for
basectx. The old _manifestmatches functionality is basically identical to the
_buildstatusmanifest functionality (minus the matching part), so no behavior
should be lost.
2017-03-07 17:52:45 -08:00
Durham Goode
16ae1e05bb context: remove assumptions about manifest creation during _buildstatus
Previously we called self.manifest() in some cases to preload the
first manifest. This relied on the assumption that the later
_manifestmatches() call did not duplicate any work the original
self.manifest() call did. Let's remove that assumption, since it bit
me during my refactors of this area and is easy to remove.
2017-03-07 17:49:50 -08:00
Durham Goode
d0909f9a09 context: move _manifest from committablectx to workingctx
committablectx had a _manifest implementation that was only used by the derived
workingctx class. The other derived versions, like memctx and metadataonlyctx,
define their own _manifest functions.

Let's move the function down to workingctx, and let's break it into two parts,
the _manifest part that reads from self._status, and the part that actually
builds the new manifest. This separation will let us reuse the builder code in a
future patch to answer _buildstatus with varying status inputs, since workingctx
has special behavior for _buildstatus that the other ctx's don't have.
2017-03-07 17:56:30 -08:00
Durham Goode
31c97f4a1c status: handle more node indicators in buildstatus
There are several different node markers that indicate different working copy
states. The context._buildstatus function was only handling one of them, and
this patch makes it handle all of them (falling back to file content comparisons
when in one of these states).

This affects a future patch where we get rid of context._manifestmatches as part
of getting rid of manifest.matches(). context._manifestmatches is currently
hacky in that it uses the newnodeid for all added and modified files, which is
why the current newnodeid check is sufficient. When we get rid of this function
and use the normal manifest.diff function, we start to see the other indicators
in the nodes, so they need to be handled or else the tests fail.
2017-03-07 09:56:11 -08:00
Durham Goode
5d0340324a merge: remove uses of manifest.matches
This gets rid of the manifest.matches calls in merge.py in favor of the new api.
This is part of getting rid of manifest.matches since it is O(manifest).
2017-03-07 18:38:20 -08:00
Durham Goode
3058681421 copies: remove use of manifest.matches
Convert the existing use of manifest.matches to use the new api. This is part
of getting rid of manifest.matches, since it is O(manifest).
2017-03-07 09:56:11 -08:00
Durham Goode
4dc06e6401 manifest: add match argument to diff and filesnotin
As part of removing manifest.matches (since it is O(manifest)), let's start by
adding match arguments to diff and filesnotin. As we'll see in later patches,
these are the only flows that actually use matchers, so by moving the matching
into the actual functions, other manifest implementations can make more efficient
algorithsm.

For instance, this will allow treemanifest diff's to only iterate over the files
that are different AND meet the match criteria.

No consumers are changed in this patches, but the code is fairly easy to verify
visually. Future patches will convert consumers to use it.

One test was affected because it did not use the kwargs version of the clean
parameter.
2017-03-07 09:56:11 -08:00
Yuya Nishihara
bdbe6facb9 fileset: drop false function signatures from revs() and status() docs
They should be inserted by @predicate helper.
2017-03-09 00:07:13 +09:00
Yuya Nishihara
7c6e9b463e py3: factor out bytechr() function
I also changed xrange(127) to range(127) as the number is relatively small.
2017-03-08 22:30:12 +09:00
Pierre-Yves David
f53348b4a6 vfs: use 'vfs' module directly in 'test-clone-uncompressed'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:34:01 +01:00
Pierre-Yves David
63abb7df39 vfs: use 'vfs' module directly in 'test-filecache'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:33:28 +01:00
Pierre-Yves David
39137e24a7 vfs: use 'vfs' module directly in 'test-parseindex'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:33:16 +01:00
Pierre-Yves David
722a43e067 vfs: use 'vfs' module directly in 'test-lock'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:33:02 +01:00
Pierre-Yves David
083299a68b vfs: use 'vfs' module directly in 'contrib/undumprevlog'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:32:49 +01:00
Pierre-Yves David
1211038425 vfs: use 'vfs' module directly in 'hgext.largefile'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:32:27 +01:00
Pierre-Yves David
f3a174150b vfs: use 'vfs' module directly in 'hgext.convert'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:32:14 +01:00
Pierre-Yves David
2e94eebbe6 vfs: use 'vfs' module directly in 'hgext.transplant'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:31:39 +01:00
Pierre-Yves David
1be66dee7d vfs: use 'vfs' module directly in 'hgext.shelve'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:31:32 +01:00
Pierre-Yves David
485053e2a1 vfs: use 'vfs' module directly in 'hgext.mq'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:31:23 +01:00