Gregory Szorc <gregory.szorc@gmail.com> [Wed, 21 Mar 2018 18:13:40 -0700] rev 37179
thirdparty: allow zope.interface.advice to be lazily imported
The symbol from this module is only used in functions. Let's access
that symbol through its imported module so importing
zope.interface.advice can be lazy.
Differential Revision: https://phab.mercurial-scm.org/D2931
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 21 Mar 2018 19:52:30 -0700] rev 37178
thirdparty: port zope.interface to relative imports
By using relative imports, we're guaranteed to get modules
vendored with Mercurial rather than other random modules
that might be in sys.path.
My editor strips trailing whitespace on save. So some minor
source code cleanup was also performed as part of this commit.
# no-check-commit because some modified lines have double newlines
Differential Revision: https://phab.mercurial-scm.org/D2930
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 21 Mar 2018 19:49:07 -0700] rev 37177
thirdparty: don't make zope a namespace package
There are a gazillion zope.* packages in the wild. So zope/__init__.py
needs to be a namespace package. But in Mercurial, we have 1 zope
package. And even if we had multiple packages, they'd all be in
thirdparty/zope/. So we don't need a namespace package.
Differential Revision: https://phab.mercurial-scm.org/D2929
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 21 Mar 2018 19:48:50 -0700] rev 37176
thirdparty: vendor zope.interface 4.4.3
I've been trying to formalize interfaces for various components
of Mercurial. So far, we've been using the "abc" package. This
package is "good enough" for a lot of tasks. But it quickly
falls over. For example, if you declare an @abc.abstractproperty,
you must implement that attribute with a @property or the class
compile time checking performed by abc will complain. This often
forces you to implement dumb @property wrappers to return a
_ prefixed attribute of the sane name. That's ugly.
I've also wanted to implement automated checking that classes
conform to various interfaces and don't expose other "public"
attributes.
After doing a bit of research and asking around, the general
consensus seems to be that zope.interface is the best package for
doing interface-based programming in Python. It has built-in
support for verifying classes and objects conform to interfaces.
It allows an interface's properties to be defined during __init__.
There's even an "adapter registry" that allow you to register
interfaces and look up which classes implement them. That could
potentially be useful for places where our custom registry.py
modules currently facilitates central registrations, but at a
type level. Imagine extensions providing alternate implementations
of things like the local repository interface to allow opening
repositories with custom requirements.
Anyway, this commit vendors zope.interface 4.4.3. The contents of
the source tarball have been copied into mercurial/thirdparty/zope/
without modifications.
Test modules have been removed because they are not interesting
to us.
The LICENSE.txt file has been copied so it lives next to the
source.
The Python modules don't use relative imports. zope/__init__.py
defines a namespace package. So we'll need to modify the source
code before this package is usable inside Mercurial. This will
be done in subsequent commits.
# no-check-commit for various style failures
Differential Revision: https://phab.mercurial-scm.org/D2928
Martin von Zweigbergk <martinvonz@google.com> [Thu, 29 Mar 2018 23:05:41 -0700] rev 37175
context: set repo property in basectx
It seems like a good practice to call the super constructor. Let's
start by passing the repo along to basectx so it can assign it to a
private attribute. We should perhaps pass the rev and node along as
well, but that requires more work before it can be done.
Differential Revision: https://phab.mercurial-scm.org/D2970
Martin von Zweigbergk <martinvonz@google.com> [Thu, 29 Mar 2018 22:51:45 -0700] rev 37174
context: move reuse of context object to repo.__getitem__ (API)
As an example of how weird the basectx.__new__ is: whenever you create
a workingctx, basectx.__new__ gets called first. Since our __new__ has
a "changeid" argument as second parameter, when create the
workingctx(repo, text="blah"), the text gets bound to
"changeid". Since a string isn't a basectx, our __new__ ends up not
doing anything funny, but that's still very confusing code.
Another case is metadataonlyctx.__new__(), which I think exists in
order to prevent metadataonlyctx.__init__'s third argument
(originalctx) from being interpreted as a changeid in
basectx.__new__(), thereby getting reused.
Let's move this to repo.__getitem__ instead, where it will be pretty
obvious what the code does.
After this patch, changectx(ctx) will be an error (it will fail when
trying to see if it's a 20-byte string).
Differential Revision: https://phab.mercurial-scm.org/D2969
Martin von Zweigbergk <martinvonz@google.com> [Thu, 29 Mar 2018 22:22:51 -0700] rev 37173
memctx: create parent contexts using "repo[p]" syntax
I want to reduce dependence on basectx.__new__() and move that code
over to repo.__getitem__().
Differential Revision: https://phab.mercurial-scm.org/D2968
Martin von Zweigbergk <martinvonz@google.com> [Thu, 29 Mar 2018 21:29:15 -0700] rev 37172
context: avoid using a context object as a changeid
I find it misleading to pass changeid=changectx. It currently works to
do that because there's weird (IMO) handling of it in
basectx.__new__. I'm planning on removing that code. Passing changeid
as "changeid" and context as "context" makes it more readable.
Note that the documentation of filectx.__init__ doesn't even seem to
be aware that a changeid can be a context ("changeset revision, node,
or tag").
Differential Revision: https://phab.mercurial-scm.org/D2967
Martin von Zweigbergk <martinvonz@google.com> [Thu, 29 Mar 2018 21:15:40 -0700] rev 37171
context: remove unwanted assignments in basectx.__new__() (API)
The two subclasses in core apparently didn't trust __new__() to do the
job anyway (they both reassigned all the properties after).
Differential Revision: https://phab.mercurial-scm.org/D2966
Boris Feld <boris.feld@octobus.net> [Wed, 31 Jan 2018 17:15:44 +0100] rev 37170
streamclonebundle: make sure we accept new stream clone bundle spec
When asked specifically, the code do a sanity check on the clone bundle to
ensure it's a stream bundle. As we introduced a new stream bundle spec, update
the logic to support it.
With this final changeset, we can now announce safely a stream v2 clone bundle
and old clients would not crash trying to process it.
This changeset address the last comment from Gregory Szorc on the stream v2
bundle series.
Differential Revision: https://phab.mercurial-scm.org/D1957
Boris Feld <boris.feld@octobus.net> [Wed, 31 Jan 2018 11:44:33 +0100] rev 37169
streamclonebundle: add a test for stream clone bundle v2
Differential Revision: https://phab.mercurial-scm.org/D1956
Boris Feld <boris.feld@octobus.net> [Wed, 31 Jan 2018 11:10:55 +0100] rev 37168
bundlespec: add support for some variants
This way the stream v2 bundle spec can disable the changegroup part while
enabling the stream v2 part.
Differential Revision: https://phab.mercurial-scm.org/D1955
Boris Feld <boris.feld@octobus.net> [Wed, 31 Jan 2018 11:09:20 +0100] rev 37167
bundle: add the possibility to bundle a stream v2 part
Differential Revision: https://phab.mercurial-scm.org/D1954
Boris Feld <boris.feld@octobus.net> [Wed, 31 Jan 2018 10:55:15 +0100] rev 37166
streambundlev2: add a new test-file
Add the new test file in a separate changeset before supporting the new format
so we better see the differences.
Differential Revision: https://phab.mercurial-scm.org/D1953
Boris Feld <boris.feld@octobus.net> [Fri, 30 Mar 2018 12:43:57 +0200] rev 37165
bundlespec: move computing the bundle contentops in parsebundlespec
We will introduce a new bundlespec for stream bundle which will influence the
contentops.
Differential Revision: https://phab.mercurial-scm.org/D1952
Boris Feld <boris.feld@octobus.net> [Fri, 30 Mar 2018 12:43:08 +0200] rev 37164
bundlespec: introduce an attr-based class for bundlespec
We will add support of contentops in the next patch, introduce a class instead
of returning a 4-items tuple.
Differential Revision: https://phab.mercurial-scm.org/D2971
Yuya Nishihara <yuya@tcha.org> [Fri, 23 Mar 2018 20:43:55 +0900] rev 37163
templater: factor out unwrapastype() from evalastype()
So ParseError of unwrapastype() can be caught reliably.
Yuya Nishihara <yuya@tcha.org> [Fri, 23 Mar 2018 20:34:12 +0900] rev 37162
templater: extract unwrapinteger() function from evalinteger()
Yuya Nishihara <yuya@tcha.org> [Fri, 23 Mar 2018 21:03:21 +0900] rev 37161
templater: extract type conversion from evalfuncarg()
Needed by the subsequent patches.
Yuya Nishihara <yuya@tcha.org> [Fri, 23 Mar 2018 20:23:55 +0900] rev 37160
templater: drop bool support from evalastype()
Future patches will split evalastype() into two functions, evalrawexp()
and unwrapastype(), so we can catch the exception of type conversion.
# evaluating function may bubble up inner ParseError
thing = evalrawexp(context, mapping, arg)
try:
return unwrapastype(context, thing)
except ParseError:
# add hint and reraise
However, evalboolean() can't be factored out in this way since it has to
process boolean-like symbols as non keyword. Fortunately, it's unlikely
that we'll need a general type converter supporting bool, so this patch
drops it from the table.
Yuya Nishihara <yuya@tcha.org> [Sat, 17 Mar 2018 20:13:06 +0900] rev 37159
templater: do not use stringify() to concatenate flattened template output
Yuya Nishihara <yuya@tcha.org> [Sat, 17 Mar 2018 20:04:20 +0900] rev 37158
templateutil: reimplement stringify() using flatten()
Yuya Nishihara <yuya@tcha.org> [Sat, 17 Mar 2018 20:00:54 +0900] rev 37157
templateutil: move flatten() from templater
It's the same kind of utility as stringify().
Matt Harbison <matt_harbison@yahoo.com> [Sun, 01 Apr 2018 01:27:18 -0400] rev 37156
server: ensure the incoming request falls under the prefix value
Prior to this, the first test asserted in wsgiref.validate.check_environ()
saying PATH didn't start with '/', but the second test served up the repo. The
assertion was just added in this cycle (though the value of PATH is still wrong
without the assertion). Allowing access to the repo at any URL outside of the
prefix is a long standing bug. This also affected hgwebdir, at least when used
via --subrepo.
Paths are not being canonicalized, so accesses to things like 'foo/../bar' will
get tossed out here, unless the prefix also matches.
Connor Sheehan <sheehan@mozilla.com> [Tue, 27 Mar 2018 11:01:13 -0400] rev 37155
stringutil: move person function from templatefilters
Move the person function from template filters to the stringutil
module, so it can be reused in the mailmap template function.
Differential Revision: https://phab.mercurial-scm.org/D2960
Connor Sheehan <sheehan@mozilla.com> [Thu, 22 Mar 2018 09:48:22 -0400] rev 37154
stringutil: add isauthorwellformed function
The regular expression for this function formerly lived at
https://hg.mozilla.org/hgcustom/version-control-tools/file/tip/hghooks/mozhghooks/author_format.py#l13
Differential Revision: https://phab.mercurial-scm.org/D2959
Matt Harbison <matt_harbison@yahoo.com> [Sat, 17 Mar 2018 02:37:46 -0400] rev 37153
test-lfs-test-server: add a testcase for `hg serve`
I haven't figured out yet how to make the authentication checks work for a
specific list of users, so the 'web.allow-push' list is wildcarded. (It appears
that the client doesn't react to a 401 by sending authentication data, which may
be caused in part by not having all of the headers in httpbasicauthhandler's
http_error_auth_reqed(), compared to a run of test-http.t. But in any case, we
should probably have a separate set of tests for various authentication
scenarios. As it is, without the wildcard, no push access is granted.)
There are several deviations from the `lfs-test-server` case:
- `hg serve` emits a Server header. I think Gregory indicated that this isn't
easily suppressed.
- `hg serve` names the "basic" transfer handler in the Batch API response. Not
having to specify it was for backwards compatability, so this seems like the
right thing to do. (`lfs-test-server` doesn't name it, whether it was
explicitly requested by the client or not.)
- PUT status for a newly created file is 201, per RFC-2616 [1]. The Basic
Transfer API [2] shows an example upload transcript with a 200 response. It
doesn't make much sense to re-upload a file (unless it is corrupt) in an
example, but I wouldn't be surprised if some other implementations also
expect 200 because of this. But the RFC says MUST use 201 for creation.
- The Content-Type for the file transfers is "application/octet-stream", like
the sample transcript (though I don't see it explicitly called out in the
text elsewhere). Using "text/plain" seems clearly wrong.
- `lfs-test-server` isn't removing the action property and sending back an
error code like the spec calls out when a file is missing or corrupt. Doing
so on the `hg serve` side reveals a bug in our client code when handling the
response- it indicates the remote file is missing instead of corrupt around
line 452.
I'll probably glob over the Content-Length differences once this settles down.
Prior to the recent hgweb refactoring, the Batch API response was using chunked
encodings instead.
Back to the RFC, I have no idea if the python framework handles the "MUST NOT
ignore any Content-* (e.g. Content-Range) headers that it does not understand or
implement and MUST return a 501" for a PUT request.
[1] https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6
[2] https://github.com/git-lfs/git-lfs/blob/master/docs/api/basic-transfers.md#uploads
Martin von Zweigbergk <martinvonz@google.com> [Thu, 29 Mar 2018 09:23:39 -0700] rev 37152
push: use "repo['.']" instead of old form "repo['']"
Note that this does not conflict with the commit message of my
previous patch: I found this after writing the previous patch
(besides, I very easily forget things).
Differential Revision: https://phab.mercurial-scm.org/D2965
Martin von Zweigbergk <martinvonz@google.com> [Thu, 29 Mar 2018 09:34:17 -0700] rev 37151
context: change default changeid from old form '' to '.'
I don't think I've seen repo[''] in the codebase at least in the last
two years.
Differential Revision: https://phab.mercurial-scm.org/D2964
Sushil khanchi <sushilkhanchi97@gmail.com> [Wed, 21 Mar 2018 23:36:11 +0530] rev 37150
remove: add dry-run functionality
Matt Harbison <matt_harbison@yahoo.com> [Sat, 17 Mar 2018 01:53:44 -0400] rev 37149
lfs: add support for serving blob files
Matt Harbison <matt_harbison@yahoo.com> [Sat, 17 Mar 2018 01:47:57 -0400] rev 37148
lfs: add server side support for the Batch API
Matt Harbison <matt_harbison@yahoo.com> [Sat, 17 Mar 2018 01:23:01 -0400] rev 37147
lfs: add basic routing for the server side wire protocol processing
The recent hgweb refactoring yielded a clean point to wrap a function that could
handle this, so I moved the routing for this out of the core. While not an hg
wire protocol, this seems logically close enough. For now, these handlers do
nothing other than check permissions.
The protocol requires support for PUT requests, so that has been added to the
core, and funnels into the same handler as GET and POST. The permission
checking code was assuming that anything not checking 'pull' or None ops should
be using POST. But that breaks the upload check if it checks 'push'. So I
invented a new 'upload' permission, and used it to avoid the mandate to POST. A
function wrap point could be added, but security code should probably stay
grouped together. Given that anything not 'pull' or None was requiring POST,
the comment on hgweb.common.permhooks is probably wrong- there is no 'read'.
The rationale for the URIs is that the spec for the Batch API[1] defines the URL
as the LFS server url + '/objects/batch'. The default git URLs are:
Git remote: https://git-server.com/foo/bar
LFS server: https://git-server.com/foo/bar.git/info/lfs
Batch API: https://git-server.com/foo/bar.git/info/lfs/objects/batch
'.git/' seems like it's not something a user would normally track. If we adhere
to how git defines the URLs, then the hg-git extension should be able to talk to
a git based server without any additional work.
The URI for the transfer requests starts with '.hg/' to ensure that there are no
conflicts with tracked files. Since these are handed out by the Batch API, we
can change this at any point in the future. (Specifically, it might be a good
idea to use something under the proposed /api/ namespace.) In any case, no
files are stored at these locations in the repository directory.
I started a new module for this because it seems like a good idea to keep all of
the security sensitive server side code together. There's also an issue with
`hg verify` in that it will want to download *all* blobs in order to run.
Sadly, there's no way in the protocol to ask the server to verify the content of
a blob it may have. (The verify action is for storing files on a 3rd party
server, and then informing the LFS server when that completes.) So we may end
up implementing a custom transfer adapter that simply indicates if the blobs are
valid, and fall back to basic transfers for non-hg servers. In other words,
this code is likely to get bigger before this is made non-experimental.
[1] https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md
Matt Harbison <matt_harbison@yahoo.com> [Wed, 14 Mar 2018 23:34:08 -0400] rev 37146
test-lfs: drop trailing ', ' item separators from debug JSON output
The trailing space looks weird when conditionalizing the line. The commas
shouldn't be necessary because of the indenting. The `lfs-test-server` isn't
sending all of the same items (notably, the "transfer" attribute is missing), so
having the commas means more lines need to be conditionalized.
Matt Harbison <matt_harbison@yahoo.com> [Thu, 22 Feb 2018 23:33:52 -0500] rev 37145
lfs: add a blob verification method to the local store
A corrupt blob can be signaled through the Batch API response, without actually
transferring the file. A true/false indicator is slightly easier than
immediately catching an exception.
Matt Harbison <matt_harbison@yahoo.com> [Wed, 28 Mar 2018 22:38:01 -0400] rev 37144
tests: conditionalize printed environment variable output in test-alias
Martin von Zweigbergk <martinvonz@google.com> [Wed, 28 Mar 2018 15:31:18 -0700] rev 37143
debugsetparents: avoid using "r1/r2" variable names for nodeids
Differential Revision: https://phab.mercurial-scm.org/D2963
Martin von Zweigbergk <martinvonz@google.com> [Wed, 28 Mar 2018 15:29:49 -0700] rev 37142
tag: avoid using "r" variable name for nodeid
Differential Revision: https://phab.mercurial-scm.org/D2962
Martin von Zweigbergk <martinvonz@google.com> [Wed, 28 Mar 2018 15:30:09 -0700] rev 37141
locate: avoid using "rev" variable name for nodeid
Also, drop silly "ctx = repo[ctx.node()]".
Differential Revision: https://phab.mercurial-scm.org/D2961
Yuya Nishihara <yuya@tcha.org> [Wed, 28 Mar 2018 22:06:47 +0900] rev 37140
py3: bytes/unicode dance on __doc__ of cmdalias
Yuya Nishihara <yuya@tcha.org> [Wed, 28 Mar 2018 22:04:45 +0900] rev 37139
alias: reject non-ascii characters in user help/doc strings
Since command doc/help texts are passed to i18n.gettext(), they must be
ASCII. Otherwise, UnicodeError would be raised.
Matt Harbison <matt_harbison@yahoo.com> [Mon, 26 Mar 2018 22:18:36 -0400] rev 37138
lfs: respect narrowmatcher when testing to add 'lfs' requirement (
issue5794)
There's a similar test in lfs.wrapper.convertsink(), but I didn't update that
because I don't think that the sink repo in a convert can be narrow.
It seems reasonable that a narrow clone of an LFS repo may not necessarily be an
LFS repo. The only potential issue is that LFS has a hard requirement for
changegroup v3, which that extension enables. The use of treemanifest will
enable changegroup v3 in narrow clones, because allsupportedversions() in
changegroup.py preserves it when it sees a 'treemanifest' requirement. But I
don't see where changegroup v3 is enabled for a flat manifest.
Gregory Szorc <gregory.szorc@gmail.com> [Tue, 20 Mar 2018 18:02:16 -0700] rev 37137
localrepo: make filterpats private (API)
I'm not sure why this is available on the public API. AFAICT it isn't
used outside of the class.
.. api::
localrepo.localrepository.filterpats was renamed to
localrepo.localrepository._filterpats.
Differential Revision: https://phab.mercurial-scm.org/D2927
Gregory Szorc <gregory.szorc@gmail.com> [Tue, 20 Mar 2018 17:34:05 -0700] rev 37136
narrow: use featuresetupfuncs
This is the preferred way to register repo requirements that can be
opened because it respects the set of loaded extensions at repo open
time.
Differential Revision: https://phab.mercurial-scm.org/D2926
Gregory Szorc <gregory.szorc@gmail.com> [Tue, 20 Mar 2018 17:30:30 -0700] rev 37135
localrepo: move featuresetupfuncs out of localrepository class (API)
I want to establish an interface for local repositories.
featuresetupfuncs is a class attribute and is global/shared across all
localrepository instances. Let's move it to a module-level attribute
to clarify it isn't part of the local repository interface.
.. api::
localrepo.localrepository.featuresetupfuncs has been renamed to
localrepo.featuresetupfuncs.
Differential Revision: https://phab.mercurial-scm.org/D2925
Rodrigo Damazio <rdamazio@google.com> [Sun, 04 Mar 2018 17:11:33 -0500] rev 37134
help: supporting both help and doc for aliases
This allows an alias to be definted like:
[alias]
lj = log -Tjson
lj:help = [-r REV]
lj:doc = Shows the revision log in JSON format.
Differential Revision: https://phab.mercurial-scm.org/D2678
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com> [Tue, 27 Mar 2018 20:21:30 +0530] rev 37133
grep: fixes erroneous output of grep in forward order (
issue3885)
If grep is passed a revset in forwards order via -r , say -r 0:tip
Then the output is erroneous. This patch fixes that. The output was wrong
because we deleted the last revision key in the matches and when we moved
to the next revision we didn't had this to compare the diff. So the pstates
dict was always empty and in the SequenceMatcher, to convert and empty pstate
to the states dictionary you would always insert. This patch keeps the matches
dictionary until the end of this window and clears it at once when this
window ends. This solves the above mentioned problem and also do not cause
any memory leak.
Matt Harbison <matt_harbison@yahoo.com> [Mon, 26 Mar 2018 23:02:50 -0400] rev 37132
lfs: move the 'supportedoutgoingversions' handling to changegroup.py
This handling already exists here for the narrow extension. We still need to
either figure out how to enable changegroup v3 without the extension, or figure
out how to let the server detect that the client doesn't have it loaded, and
emit a user friendly error[1]. I can't tell if D1944 is the appropriate vehicle
for the latter.
[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2018-January/109550.html
Gregory Szorc <gregory.szorc@gmail.com> [Sun, 04 Mar 2018 09:58:57 -0500] rev 37131
obsolete: refactor function for getting obsolete options
The function for returning obsolete option values obtains all
options, validates, then returns the option that was requested.
Let's create a new function to return all obsolete option values
so callers needing multiple values can call that.
Differential Revision: https://phab.mercurial-scm.org/D2667
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 26 Mar 2018 14:17:01 -0700] rev 37130
setup: install cbor packages
Without this, standalone installs don't have the cbor files.
Differential Revision: https://phab.mercurial-scm.org/D2949
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 26 Mar 2018 09:21:07 -0700] rev 37129
wireproto: review fixups
Capture various TODOs and return an explicit value. This
represents feedback from Yuya and Augie on various commits.
Differential Revision: https://phab.mercurial-scm.org/D2944
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 26 Mar 2018 10:22:13 -0700] rev 37128
cbor: add a __init__.py to top level cbor module
Differential Revision: https://phab.mercurial-scm.org/D2752
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 26 Mar 2018 08:32:21 -0700] rev 37127
cbor: fix core test-check*
This patch fixes couple of test-check* tests by making sure they skip
testing the third party library cbor.
Differential Revision: https://phab.mercurial-scm.org/D2751
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 26 Mar 2018 08:33:57 -0700] rev 37126
thirdparty: vendor cbor2 python library
CBOR stands for Concise Binary Object Representation, which is a data format
which is very compact and extensible.
This patch moves the python library which can serilaize and deserialize python
objects to/from cbor formats. The library is taken from
https://github.com/agronholm/cbor2/ from commit
84181540f6eb650437e3f73cd104a65661fe8e67.
Unrequired files from the cbor library - docs/, tests/, setup.py, setup.cfg,
and tox.ini - have not been vendored.
There is another python library for cbor at
https://github.com/brianolson/cbor_py/ which is used in evolve extension and was
imported in initial version of this series. That library though contains C code
and is bit faster, but has known bugs around serializing nested structures, is
unmaintained, raises an Exception object instead of a more dedicated Error type.
So, it's better to use a bug free and actively maintained library.
This library is not yet used and will be used in later commits.
# no-check-commit because we are importing a third library module
Differential Revision: https://phab.mercurial-scm.org/D2750
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Mar 2018 00:30:00 -0500] rev 37125
merge: deprecate accessing update results by index
Now that we have named attributes, let's convert the code base to use
them. We also add deprecation warnings so legacy consumers are aware
of their transgressions.
``stats.unresolvedcount`` is much easier to read than ``stats[3]``,
don't you think?
Differential Revision: https://phab.mercurial-scm.org/D2694
Yuya Nishihara <yuya@tcha.org> [Sun, 25 Mar 2018 11:58:05 +0900] rev 37124
procutil: introduce context-manager interface for protect/restorestdio
The code looks slightly cleaner since it was pretty easy to pass arguments
in wrong order.
Yuya Nishihara <yuya@tcha.org> [Sun, 25 Mar 2018 11:40:30 +0900] rev 37123
procutil: move protectio/restoreio from commandserver
Some variants of this will be useful for stdio-based servers such as
sshserver.
Yuya Nishihara <yuya@tcha.org> [Sun, 25 Mar 2018 11:30:59 +0900] rev 37122
commandserver: rewrite protectio/restoreio to not depend on ui
Prepares for porting to utils.procutil, in which ui shouldn't be known.
ui.flush() is replaced with ui.fout.flush() since ui.ferr wasn't involved.
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 14:54:15 +0900] rev 37121
util: deprecate procutil proxy functions (API)
Several functions are re-exported by utils.procutil, which require explicit
modname parameter.
.. api::
Utility functions related to process/executable management have been moved
to utils.procutil module.
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 15:10:51 +0900] rev 37120
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 15:09:33 +0900] rev 37119
procutil: bulk-replace util.std* to point to new module
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 13:38:04 +0900] rev 37118
procutil: move process/executable management functions to new module
std* files, pipe helpers, and findexe()s are moved as well since they are
likely to be used with sub processes.
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 14:32:34 +0900] rev 37117
util: stop using readfile() in tempfilter()
To unblock code move to utils.*. It's merely two lines of very Pythonic code.
No helper function should be needed.
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 14:38:34 +0900] rev 37116
util: mark filtertable as private constant
Prepares for porting to utils.*.
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 17:04:43 +0900] rev 37115
util: mark platform-specific gethgcmd() as private
util.hgcmd() is the public interface for gethgcmd().
Matt Harbison <matt_harbison@yahoo.com> [Sat, 24 Mar 2018 22:10:58 -0400] rev 37114
test-pathconflicts-merge: stop requiring symlink support
The errors from the last time I took a shot at this back in early November have
disappeared, so let's just enable this.
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Mar 2018 17:50:54 -0800] rev 37113
commands: use constants for merge things
We have nice constants now. Let's use them to make the code
easier to reason about.
Differential Revision: https://phab.mercurial-scm.org/D2702
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Mar 2018 18:10:36 -0800] rev 37112
merge: use constants for actions
We finish up establishing named constants in this file with
actions.
I remember scratching my head trying to figure out what this
code was doing as part of addressing a recent security issue with
subrepos. Having the named constants in place definitely makes
things easier to read.
I'm not convinced the new constants have the best names (I'm not
an expert in this code). But they can be changed easily enough.
Also, since these constants are internal only, we might want
to change their values to something more human readable to
facilitate debugging. Or maybe we could employ an enum type
some day...
Differential Revision: https://phab.mercurial-scm.org/D2701
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Mar 2018 14:21:57 -0500] rev 37111
merge: use constants for merge record state
Named constants are easier to read than short string values.
Differential Revision: https://phab.mercurial-scm.org/D2700
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Mar 2018 14:15:31 -0500] rev 37110
merge: use constants for merge driver state
Named constants are superior to magic values.
Differential Revision: https://phab.mercurial-scm.org/D2699
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Mar 2018 14:09:23 -0500] rev 37109
merge: use constants for merge state record types
merge.py is using multiple discrete sets of 1 and 2 letter constants
to define types and behavior. To the uninitiated, the code is very
difficult to reason about. I didn't even realize there were multiple
sets of constants in play initially!
We begin our sanity injection with merge state records. The record
types (which are serialized to disk) are now defined in RECORD_*
constants.
Differential Revision: https://phab.mercurial-scm.org/D2698
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Mar 2018 00:28:40 -0500] rev 37108
histedit: always define update results
Before, we had a branch that could return None for the update stats.
Let's just return an updateresult instance instead.
Differential Revision: https://phab.mercurial-scm.org/D2693
Gregory Szorc <gregory.szorc@gmail.com> [Mon, 05 Mar 2018 00:02:13 -0500] rev 37107
merge: return an attrs class from update() and applyupdates()
Previously, we returned a tuple containing counts. The result of an
update is kind of complex and the use of tuples with nameless fields
made the code a bit harder to read and constrained future expansion
of the return value.
Let's invent an attrs-defined class for representing the result of
an update operation.
We provide __getitem__ and __len__ implementations for backwards
compatibility as a container type to minimize code churn.
In (at least) Python 2, the % operator seems to insist on using
tuples. So we had to update a consumer using the % operator.
.. api::
merge.update() and merge.applyupdates() now return a class
with named attributes instead of a tuple. Switch consumers
to access elements by name instead of by offset.
Differential Revision: https://phab.mercurial-scm.org/D2692
Sangeet Kumar Mishra <mail2sangeetmishra@gmail.com> [Fri, 23 Feb 2018 11:48:58 +0530] rev 37106
histedit: make histedit's commands accept revsets (
issue5746)
Earlier the code was only looking for rulehashes and neglecting
all other revision identifiers, this code intercepts the fromrule function
and calls scmutil.revsingle() on anything that is not a rulehash and then
obtains the rulehash from the changectx object returned, rest of the pipeline
follows as it was
Differential Revision: https://phab.mercurial-scm.org/D2394
Yuya Nishihara <yuya@tcha.org> [Sat, 17 Mar 2018 17:54:33 +0900] rev 37105
formatter: make 'originalnode' a thing in log-like templates
mapping['node'] doesn't work since {node} is computed dynamically in non-web
templates.
Yuya Nishihara <yuya@tcha.org> [Sat, 17 Mar 2018 17:41:07 +0900] rev 37104
formatter: port handling of 'originalnode' to populatemap() hook
This isn't a pure templating business, so let's move out of the templater
module.
Note that this works only in web templates where mapping['node'] is a static
value.
Yuya Nishihara <yuya@tcha.org> [Thu, 15 Mar 2018 21:52:47 +0900] rev 37103
templater: switch 'revcache' based on new mapping items
It was pretty easy to leave a stale 'revcache' when switching 'ctx'.
Let's make it be automatically replaced.
Yuya Nishihara <yuya@tcha.org> [Thu, 15 Mar 2018 21:49:33 +0900] rev 37102
templater: add hook point to populate additional mapping items
The 'revcache' dict will be inserted by this hook.
Matt Harbison <matt_harbison@yahoo.com> [Sat, 24 Mar 2018 01:30:50 -0400] rev 37101
context: skip path conflicts by default when clearing unknown file (
issue5776)
Prior to adding path conflict checking in
989e884d1be9, the test-audit-path.t
tests failed as shown here (but it was globbed away).
989e884d1be9 made it fail
with a message about the destination manifest containing a conflict (though the
no-symlink case wasn't updated). When the path conflict checking was gated
behind an experimental config in
2a774cae3a03^::
2a774cae3a03, the update started
erroneously succeeding here. It turns out that the child of
989e884d1be9 is the
origin of this change when path conflict checking is disabled, as shown by
grafting the experimental config range on top of it.
What's happening here is merge.batchget() is writing the symlink 'back' to wdir
(but as a regular file for the no-symlink case), and then tries to write
'back/test', but calls wctx['back/test'].clearunknown() first. The code that's
gated here was removing the newly written 'back' file, allowing 'back/test' to
succeed. I tried checking for the dir components of 'back/test' in dirstate,
and skipping removal if present. But that didn't work because the dirstate
isn't updated after each file is written out.
This is the last persistent test failure on Windows, so the testbot should start
turning green now. \o/
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 13:02:27 +0900] rev 37100
url: make logginghttphandler compatible with Python 2.7.6
There wasn't a usable hook point in httplib, so we have to replace connect()
to wrap the socket before self._tunnel().
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 14:24:32 +0900] rev 37099
util: make safehasattr() a pycompat function
So safehasattr() can be imported by utils.* modules. util.safehasattr() still
remains as an alias since it is pretty basic utility available for years.
On current Python 3, the builtin hasattr() should have no problem.
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 14:13:37 +0900] rev 37098
util: drop util.Abort in favor of error.Abort (API)
IIRC, error.Abort exists since Mercurial 1.2, so it should be pretty easy
for extensions authors to update their code.
.. api::
The util.Abort alias has been removed. Use error.Abort.
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 14:09:44 +0900] rev 37097
test-bundle2-exchange: use error.Abort instead of util.Abort
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 14:08:50 +0900] rev 37096
util: use error.Abort instead of local alias
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 13:30:50 +0900] rev 37095
rcutil: directly call win32.executablepath()
Since it isn't supported on POSIX platform, we don't need to double the
compatibility layers.
Yuya Nishihara <yuya@tcha.org> [Sat, 24 Mar 2018 17:19:32 +0900] rev 37094
directaccess: do not abort by 'ff...' hash
Since the 'ff...' hash should never be hidden, we can just ignore it.
Gregory Szorc <gregory.szorc@gmail.com> [Fri, 23 Mar 2018 11:20:13 -0700] rev 37093
hgweb: don't responsd to api requests unless feature is enabled
Per discussion at https://phab.mercurial-scm.org/D2834, new URLs
in hgweb can conflict with subrepos and virtual repos. This may prevent
access to repos in certain paths or having certain names.
Until we have a workaround for this, let's not serve requests for
"api/" URLs unless the feature is enabled.
Differential Revision: https://phab.mercurial-scm.org/D2936
Daniel Ploch <dploch@google.com> [Fri, 23 Mar 2018 11:20:49 -0700] rev 37092
fancyopts: prevent mutation of the default value in customopts
Differential Revision: https://phab.mercurial-scm.org/D2937
Daniel Ploch <dploch@google.com> [Thu, 22 Mar 2018 17:08:25 -0700] rev 37091
fancyopts: fix rendering of customopt defaults in help text
Differential Revision: https://phab.mercurial-scm.org/D2935
Pulkit Goyal <7895pulkit@gmail.com> [Mon, 12 Mar 2018 18:38:26 +0530] rev 37090
remotenames: show remote bookmarks in `hg bookmarks`
This patch adds functionality to show list of remote bookmarks in `hg bookmarks`
command.
There is some indenting problem in the test output as the current bookmark
printing code in core can handle bookmark names of size 25 only gracefully.
The idea is taken from hgremotenames extension which has --remote and --all
flags to show remote bookmarks. However, this patch by defaults support showing
list of remote bookmarks if remotenames extension is enabled and remotebookmarks
are turned on.
Differential Revision: https://phab.mercurial-scm.org/D2808
Pulkit Goyal <7895pulkit@gmail.com> [Sun, 11 Mar 2018 16:17:51 +0530] rev 37089
remotenames: add functionality to hoist remotebookmarks
This patch adds the functionality to hoist remotebookmarks to the top level
namespace. The peer of which bookmarks should be hoisted can be set using
`remotenames.hoistedpeer` config option. Only bookmarks can be hoisted. If a
hoisted name and local bookmark exists of the same name, the local bookmark
takes precedence.
While I was here, I documented the default values of two other remotenames
config options.
Differential Revision: https://phab.mercurial-scm.org/D2807
Kyle Lippincott <spectral@google.com> [Thu, 08 Mar 2018 11:44:03 -0800] rev 37088
copyfile: preserve stat info (mtime, etc.) when doing copies/renames
Differential Revision: https://phab.mercurial-scm.org/D2729
Matt Harbison <matt_harbison@yahoo.com> [Thu, 22 Mar 2018 22:58:31 -0400] rev 37087
merge: add 'isknown=True' to a dirstate.normalize() in _unknowndirschecker
Per the docstring for dirstate.normalize().
Matt Harbison <matt_harbison@yahoo.com> [Thu, 22 Mar 2018 22:56:29 -0400] rev 37086
merge: pconvert paths in _unknowndirschecker before dirstate-normalizing
This fixes the failure in test-pathconflicts-basic.t on Windows. The test was
passing in 'a\b', which was getting normalized to 'A\B', which isn't in
dirstate. (The filesystem path is all lowercase anyway.)
This isn't the only case of calling dirstate.normalize(), but other methods here
(util.finddirs()) seem to assume the input paths are already using '/'. I think
the backslash comes from wvfs.reljoin() (in this case), but could also come from
wvfs.walk(), so this is the only case that needs it.
Yuya Nishihara <yuya@tcha.org> [Thu, 22 Mar 2018 22:39:43 +0900] rev 37085
util: enable deprecation warning for stringutil proxy (API)
.. api::
Several generic string helper functions have been moved to utils.stringutil
module.
Yuya Nishihara <yuya@tcha.org> [Thu, 22 Mar 2018 21:56:20 +0900] rev 37084
stringutil: bulk-replace call sites to point to new module
This might conflict with other patches floating around, sorry.
Yuya Nishihara <yuya@tcha.org> [Thu, 22 Mar 2018 21:19:31 +0900] rev 37083
stringutil: move generic string helpers to new module
Per https://phab.mercurial-scm.org/D2903#46738
URL and file paths functions are left since they are big enough to make
separate modules.
Yuya Nishihara <yuya@tcha.org> [Thu, 22 Mar 2018 21:32:19 +0900] rev 37082
util: remove unused private constant '_hextochr'
The only user, _urlunquote(), was removed by
81d38478fced.
Yuya Nishihara <yuya@tcha.org> [Thu, 22 Mar 2018 21:20:47 +0900] rev 37081
util: mark internal constants of escapedata() as private
Yuya Nishihara <yuya@tcha.org> [Thu, 22 Mar 2018 21:14:12 +0900] rev 37080
util: adjust indent level in wrap()
Yuya Nishihara <yuya@tcha.org> [Thu, 22 Mar 2018 21:13:31 +0900] rev 37079
util: mark MBTextWrapper as private
Makes porting slightly easier.
Yuya Nishihara <yuya@tcha.org> [Thu, 22 Mar 2018 21:10:42 +0900] rev 37078
util: add helper to define proxy functions to utils.*
Kyle Lippincott <spectral@google.com> [Wed, 21 Mar 2018 12:36:29 -0700] rev 37077
filemerge: make the 'local' path match the format that 'base' and 'other' use
If we pass a separate '$output' arg to the merge tool, we produce four files:
local, base, other, and output. In this situation, 'output' will be the
original filename, 'base' and 'other' are temporary files, and previously
'local' would be the backup file (so if 'output' was foo.txt, 'local' would be
foo.txt.orig).
This change makes it so that 'local' follows the same pattern as 'base' and
'other' - it will be a temporary file either in the
`experimental.mergetempdirprefix`-controlled directory with a name like
foo~local.txt, or in the normal system-wide temp dir with a name like
foo~local.RaNd0m.txt.
For the cases where the merge tool does not use an '$output' arg, 'local' is
still the destination filename, and 'base' and 'other' are unchanged.
The hope is that this is much easier for people to reason about; rather than
having a tool like Meld pop up with three panes, one of them with the filename
"foo.txt.orig", one with the filename "foo.txt", and one with
"foo~other.StuFf2.txt", we can (when the merge temp dir stuff is enabled) make
it show up as "foo~local.txt", "foo.txt" and "foo~other.txt", respectively.
This also opens the door to future customization, such as getting the
operation-provided labels and a hash prefix into the filenames (so we see
something like "foo~dest.abc123", "foo.txt", and "foo~src.d4e5f6").
Differential Revision: https://phab.mercurial-scm.org/D2889
Matt Harbison <matt_harbison@yahoo.com> [Wed, 21 Mar 2018 22:36:26 -0400] rev 37076
test-strip-narrow: adjust bundle removal for Windows test stability
MSYS was mangling $TESTTMP to C:\\Users\\...\\test-narrow-strip.t-flat/, which
caused `rm` to fail. The -f was suppressing -ENOENT, so the only clue something
was wrong was when 2 bundles were applied via `hg unbundle` on line 91, instead
of just 1. This changed the text output of `hg unbundle`.
The first `rm` wasn't causing an issue, but is changed for consistency with the
rest of the file.
Yuya Nishihara <yuya@tcha.org> [Thu, 15 Mar 2018 21:38:57 +0900] rev 37075
templater: drop symbols which should be overridden by new 'ctx' (
issue5612)
This problem is caused by impedance mismatch between the templater and the
formatter interface, which is that the template keywords are generally
evaluated dynamically, but the formatter puts static values into a template
mapping.
This patch avoids the problem by removing conflicting values from a mapping
dict when a 'ctx' is switched.
Yuya Nishihara <yuya@tcha.org> [Thu, 15 Mar 2018 21:22:52 +0900] rev 37074
templater: factor out function to create mapping dict for nested evaluation
overlaymap() is the hook point to drop mapping items conflicting with the
default keywords which have to be re-evaluated with new 'ctx' resource.
Yuya Nishihara <yuya@tcha.org> [Thu, 15 Mar 2018 20:43:39 +0900] rev 37073
templater: introduce resourcemapper class
A couple more functions will be added later to work around nested mapping
bugs such as the issue 5612.
Yuya Nishihara <yuya@tcha.org> [Thu, 15 Mar 2018 20:27:38 +0900] rev 37072
log: do no expect templateresources() returning a dict
The resources dict will be replaced with new resource mapper object, which
won't implement __getitem__(key). Share the whole resources object with
_graphnodeformater() to make porting easier.
Yuya Nishihara <yuya@tcha.org> [Fri, 16 Mar 2018 23:11:55 +0900] rev 37071
templatekw: mark _showlist() as deprecated (API)
.. api::
``templatekw._showlist()`` is deprecated in favor of
``templateutil._showcompatlist()``, which takes ``context`` in place of
``templ``.
Yuya Nishihara <yuya@tcha.org> [Fri, 16 Mar 2018 23:09:21 +0900] rev 37070
templater: drop 'templ' from resources dict
Partially resolves cycle, templ -> context -> templ. This will make it easier
to replace the resources dict with new immutable resource mapper interface.
Yuya Nishihara <yuya@tcha.org> [Fri, 16 Mar 2018 23:01:51 +0900] rev 37069
templatekw: stop using _showlist() which is about to be deprecated
Use the new context-based API instead.
Yuya Nishihara <yuya@tcha.org> [Fri, 16 Mar 2018 22:47:15 +0900] rev 37068
templater: use template context to render old-style list template
Prepares for dropping the 'templ' resource.
This means old-style list templates are processed by the same engine class
as the one for the list node. I think that's fine since templates for the
same list should be tightly coupled, and I believe the extension point for
the engine classes isn't actually used.
Now templatekw._showlist() is a compatibility wrapper for _showcompatlist(),
and will be deprecated soon. The function is still marked as private since
I plan to change the interface to get rid of closures capturing context and
mapping.