Commit Graph

16105 Commits

Author SHA1 Message Date
Maciej Fijalkowski
688a2c6f37 pypy: fix doctests for pypy optimizations
PyPy would sometime call __len__ at points where it things preallocating
the container makes sense. Change the doctests so they're using generator
expressions and not list comprehensions
2016-03-31 18:38:08 +02:00
liscju
f82ff5ff29 bundle: warn when update to revision existing only in a bundle (issue5004)
Now its done silently, so unless user really knows what he is doing
will be suprised to find that after update 'hg status' doesn't work.
This commit makes also merge operation warns about missing parent when
revision to merge exists only in the bundle.
2016-03-23 08:55:22 +01:00
Anton Shestakov
9f3a77930a hgweb: generate last change date for an empty atom-bookmarks feed (issue5022)
RFC 4287 states that atom feeds must have an <updated> element, so let's add
one even when repo doesn't have a single bookmark.
2016-03-31 15:37:21 +08:00
Anton Shestakov
d9e41fcffc hgweb: sort bookmarks in revlog order of their nodes
Changes, branches and tags are already in revlog order on /summary, /branches
and /tags, let's now make bookmarks be sorted by the same principle. It's more
helpful to show more "recent" bookmarks on top. This will affect /bookmarks
page in all styles, including atom, rss and raw, and also /summary page.

Bookmarks are sorted using a (revision number, bookmark name) tuple.
2016-03-31 15:22:06 +08:00
Anton Shestakov
0741a98a71 hgweb: sort bookmarks early
Let's do the same thing that /tags page does. It gets sorted tags and then if
it needs the latest only, it just slices the first item from the list. Since
it's a slice and not a min(), it doesn't throw an exception if the list is
empty. This fixes HTTP 500 error from issue5022.
2016-03-31 14:23:27 +08:00
Anton Shestakov
e81bf97ae9 hgweb: add parents to json-log (issue5074)
Entries prepared in webutil.changelistentry() skip showing parents in the
trivial case when there's only one parent and it's the previous revision. This
doesn't work well for the json-log template, which is supposed to just dump raw
data in an easy-to-parse format, so let's provide all parents as another
keyword: allparents.

Using a lambda function here means that the performance of templates that don't
use allparents won't be affected (see 88bd6697bfad).
2016-03-31 18:09:09 +08:00
Yuya Nishihara
5013ac73bc revset: make _parsealiasdecl() simply return the original parsed tree
It wasn't necessary to reconstruct the same tuple.
2016-02-29 17:46:06 +09:00
Yuya Nishihara
9cb56c55c8 revset: inline isvalidfunc(), getfuncname() and getfuncargs()
See the previous commit for why. These functions are also trivial.
2016-02-29 16:35:58 +09:00
Yuya Nishihara
8437ca0ff3 revset: inline isvalidsymbol() and getsymbol() into _parsealiasdecl()
Since I'm going to extract a common alias parser, I want to eliminate
dependencies to the revset parsing rules. These functions are trivial,
so we can go without them.
2016-02-29 16:32:18 +09:00
Yuya Nishihara
23d5f85790 revset: remove redundant checks for parsed tree of alias
If tree is a tuple, it must have at least one element. Also the length of node
tuple is guaranteed by the syntax elements. (e.g. 'func' must have 3 items.)

This change will help inlining these trivial functions in future patches.
2016-02-29 16:23:09 +09:00
FUJIWARA Katsunori
4f1a0e917c templater: use templatefunc to mark a function as template function
Using decorator can localize changes for adding (or removing) a
template function in source code.

This patch also removes leading ":FUNC(ARG...):" part in help document
of each function, because using templatefunc makes it useless.

This patch uses not 'func' but 'templatefunc' as a decorator name,
because the former is too generic one, even though the latter is a
little redundant in 'templater.py'.
2016-03-30 02:10:44 +09:00
FUJIWARA Katsunori
7a6d96d902 registrar: add templatefunc to mark a function as template function (API)
This patch also adds loadfunction() to templater, because this
combination helps to figure out how they cooperate with each other.

Listing up loadfunction() in dispatch.extraloaders causes implicit
loading template function at loading (3rd party) extension.

This patch explicitly tests whether templatefunc decorator works as
expected, because there is no bundled extension, which defines
template function.

This change requires that "templatefunc" attribute of (3rd party)
extension is registrar.templatefunc or so.
2016-03-30 02:10:44 +09:00
FUJIWARA Katsunori
15ff9ca52f templatefilters: use templatefilter to mark a function as template filter
Using decorator can localize changes for adding (or removing) a
template filter function in source code.

This patch also removes leading ":FILTER:" part in help document of
each filters, because using templatefilter makes it useless.

This patch uses not 'filter' but 'templatefilter' as a decorator name,
because the former name hides Python built-in one, even though the
latter is a little redundant in 'templatefilters.py'.
2016-03-30 02:10:44 +09:00
FUJIWARA Katsunori
098aa2f5a6 registrar: add templatefilter to mark a function as template filter (API)
This patch also adds loadfilter() to templatefilters, because this
combination helps to figure out how they cooperate with each other.

Listing up loadfilter() in dispatch.extraloaders causes implicit
loading template filter functions at loading (3rd party) extension.

This change requires that "templatefilter" attribute of (3rd party)
extension is registrar.templatefilter or so.
2016-03-30 02:10:44 +09:00
Yuya Nishihara
0f4849fc71 revset: inline _getaliasarg() function
This function is now much simpler than before. Inlining small functions helps
to extract a reusable alias processor.
2016-02-14 20:43:30 +09:00
Yuya Nishihara
6c870f3b69 revset: drop redundant check for unknown alias arguments
Since _parsealiasdefn() rejects unknown alias arguments, _checkaliasarg() is
unnecessary. New test is added to make sure unknown '$n' symbols are rejected.
2016-02-14 20:27:08 +09:00
Yuya Nishihara
208bb924ba revset: move tagging of alias arguments from tokenization to parsing phase
In short, this patch moves the hack from tokenizedefn() to _relabelaliasargs(),
which is called after parsing. This change aims to eliminate tight dependency
on the revset tokenizer.

Before this patch, we had to rewrite an alias argument to a pseudo function:

  "$1" -> "_aliasarg('$1')"
  ('symbol', '$1') -> ('function', ('symbol', '_aliasarg'), ('string', '$1'))

This was because the tokenizer must generate tokens that are syntactically
valid. By moving the process to the parsing phase, we can assign a unique tag
to an alias argument.

  ('symbol', '$1') -> ('_aliasarg', '$1')

Since new _aliasarg node never be generated from a user input, we no longer
have to verify a user input at findaliases(). The test for _aliasarg("$1") is
removed as it is syntactically valid and should pass the parsing phase.
2016-02-14 19:48:33 +09:00
Yuya Nishihara
a32c974037 templater: do not strip non-quote characters from template config
Before this patch, the first and last characters were stripped from
ui.logtemplate and template.* if they were the same. It could lead to a
strange result as quotes are optional. See the test for example.
2016-03-27 17:42:19 +09:00
FUJIWARA Katsunori
f736378bd5 destutil: show message and hint at updating to the closed head as warning 2016-03-29 23:59:32 +09:00
FUJIWARA Katsunori
aeacfdc6d7 destutil: make messages at updating to the closed head usual form
This patch makes messages at updating to the closed head usual form
for Mercurial as below:

    one line description of the problem with no period
    (a suggestion about how to move forward or get more info)
2016-03-29 23:59:32 +09:00
timeless
0269e5f4a8 py3: handle ugettext + unicode in i18n 2016-03-29 17:22:08 +00:00
Martin von Zweigbergk
d613237780 bundle: remove obsolete (and duplicate) comment
Change 760f9c8ad835 (changegroup: move chunk extraction into a
getchunks method of unbundle10, 2014-04-10) extracted some code to a
getchunks() method and copied a comment about the changegroup format
to the new method. The copy that remains in the old place, doesn't
make much sense there, so let's remove it.
2016-03-29 10:21:05 -07:00
Matt Mackall
4a96519522 merge with stable 2016-03-29 12:29:00 -05:00
Martin von Zweigbergk
3215d75682 bundle: avoid crash when no good changegroup version found
When using treemanifests, only changegroup3 bundles can be
created. However, there is currently no way of requesting a
changegroup3 bundle, so we run into an assertion in
changegroup.getbundler() when trying to get a changroup2
bundler. Let's avoid the traceback and print a short error message
instead.
2016-03-25 23:05:32 -07:00
Martin von Zweigbergk
41fe4530a2 exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
The functions already have a lot in common, but were structured a
little differently.
2016-03-25 16:13:28 -07:00
Martin von Zweigbergk
5bf2894e26 exchange: get rid of "getcgkwargs" variable
This also makes the "version" argument explicit (never relies on
getlocalchangegroupraw()'s default), which I think is a good thing.
2016-03-25 16:01:40 -07:00
Martin von Zweigbergk
4cc86f7b27 bundle: move writebundle() from changegroup.py to bundle2.py (API)
writebundle() writes a bundle2 bundle or a plain changegroup1. Imagine
away the "2" in "bundle2.py" for a moment and this change should makes
sense. The bundle wraps the changegroup, so it makes sense that it
knows about it. Another sign that this is correct is that the delayed
import of bundle2 in changegroup goes away.

I'll leave it for another time to remove the "2" in "bundle2.py"
(alternatively, extract a new bundle.py from it).
2016-03-28 14:41:29 -07:00
liscju
91a4807057 debugsetparents: remove redundant invocations of begin/endparentchange
Method localrepo.setparents invokes begin/endparentchange internally,
so there is no need to invoke it explicitly in debugsetparents.
2016-03-28 09:12:03 +02:00
Gregory Szorc
b7edbc29ee sslutil: add docstring to wrapsocket()
Security should not be opaque.
2016-03-27 13:13:19 -07:00
Gregory Szorc
5ff877516b sslutil: remove indentation in wrapsocket declaration
It is no longer needed because we have a single code path.
2016-03-27 11:39:39 -07:00
Gregory Szorc
24502a149c sslutil: always use SSLContext
Now that we have a fake SSLContext instance, we can unify the code
paths for wrapping sockets to always use the SSLContext APIs.

Because this is security code, I've retained the try..except to
make the diff easier to read. It will be removed in the next patch.

I took the liberty of updating the inline docs about supported
protocols and how the constants work because this stuff is important
and needs to be explicitly documented.
2016-03-27 14:18:32 -07:00
Gregory Szorc
36e749aa82 sslutil: move _canloaddefaultcerts logic
We now have a newer block accessing SSLContext. Let's move this
code to make subsequent refactorings of the former block easier.
2016-03-27 14:08:52 -07:00
Gregory Szorc
93d8d2d711 sslutil: implement SSLContext class
Python <2.7.9 doesn't have a ssl.SSLContext class. In this patch,
we implement the interface to the class so we can have a unified
code path for all supported versions of Python.

This is similar to the approach that urllib3 takes.
2016-03-27 13:50:34 -07:00
Gregory Szorc
46d517af99 sslutil: store OP_NO_SSL* constants in module scope
An upcoming patch will introduce a global SSLContext type so we
have a single function used to wrap sockets. Prepare for that by
introducing module level constants for disabling SSLv2 and SSLv3.
2016-03-27 10:47:24 -07:00
Gregory Szorc
3f3e1d212c sslutil: better document state of security/ssl module
Pythons older than 2.7.9 are lacking the modern ssl module
and have horrible security. Let's document this explicitly.
2016-03-27 14:07:06 -07:00
Mateusz Kwapich
e1c4c54543 subrepo: set GIT_ALLOW_PROTOCOL to limit git clone protocols (SEC)
CVE-2016-3068 (1/1)

Git's git-remote-ext remote helper provides an ext:: URL scheme that
allows running arbitrary shell commands. This feature allows
implementing simple git smart transports with a single shell shell
command. However, git submodules could clone arbitrary URLs specified
in the .gitmodules file. This was reported as CVE-2015-7545 and fixed
in git v2.6.1.

However, if a user directly clones a malicious ext URL, the git client
will still run arbitrary shell commands.

Mercurial is similarly effected. Mercurial allows specifying git
repositories as subrepositories. Git ext:: URLs can be specified as
Mercurial subrepositories allowing arbitrary shell commands to be run
on `hg clone ...`.


The Mercurial community would like to thank Blake Burkhart for
reporting this issue. The description of the issue is copied from
Blake's report.

This commit changes submodules to pass the GIT_ALLOW_PROTOCOL env
variable to git commands  with the same list of allowed protocols that
git submodule is using.

When the GIT_ALLOW_PROTOCOL env variable is already set, we just pass it
to git without modifications.
2016-03-20 21:52:21 -07:00
timeless
9b55d3b408 summary: move mergemod before parents to give access to ms 2016-03-17 14:50:29 +00:00
timeless
81737a7154 filemerge: use revset notation for p1/p2 of local/other descriptions 2016-03-17 00:36:01 +00:00
Jordi Gutiérrez Hermoso
52cc18f78c crecord: re-enable reviewing a patch before comitting it
The "r" option for this feature was copied into Mercurial from
crecord, but the actual implementation never made it into hg until
now. It's a moderately useful feature that allows the user to edit the
patch in a text editor before comitting it for good.

This requires a test, so we must also enable a corresponding testing
'R' option that skips the confirmation dialogue. In addition, we also
need a help text for the editor when reviewing the final patch.

As for why this is a useful feature if we can already edit hunks in an
editor, I would like to offer the following points:

    * editing hunks does not show the entire patch all at once

      ** furthermore, the hunk "tree" in the TUI has no root that could be
         selected for edition

    * it is helpful to be able to see the entire final patch for
      confirmation

      ** within this view, the unselected hunks are hidden, which is
         visusally cleaner

      ** this works as a final review of the complete result, which is
         a bit more difficult to do conceptually via hunk editing

    * this feature was already in crecord, so it was an oversight to
      not bring it to core

    * it works and is consistent with editing hunks
2016-03-20 21:08:17 -04:00
Jordi Gutiérrez Hermoso
6e38da078e crecord: break out the help message for editing hunks
This help message can be useful for other situations, such as for the
review extension. It's also easier to write it at the top-level
indentation with triple-quoted strings instead of inserting comment
characters and newlines programmatically.
2016-03-20 18:24:59 -04:00
Jordi Gutiérrez Hermoso
e86f12d3c1 crecord: refactor hunk edit action to use ui.edit
The previous version of this code did a lot of dancing around a
temporary edit file that ui.edit already handles.
2016-03-20 20:59:05 -04:00
Jordi Gutiérrez Hermoso
bc9b8cd792 edit: allow to configure the suffix of the temporary filename
Sometimes, we can pick a more appropriate default suffix than ".txt",
for example, diffs could have a ".diff" suffix.
2016-03-20 13:55:41 -04:00
Simon Farnsworth
74ca86ac73 merge: save merge part labels for later reuse
We permit the caller of merge operations to supply labels for the merge
parts ("local", "other", and optionally "base"). These labels are used in
conflict markers to reduce confusion; however, the labels were not
persistent, so 'hg resolve' would lose the labels.

Store the labels in the mergestate.
2016-03-19 18:37:10 -07:00
timeless
45450b6576 ui: add prompt argument to write (issue5154) (API)
When code like filemerge._iprompt calls ui.prompt, it expects
the user to see the output in addition to getting the prompt.

Other code such as histedit may call ui.pushbuffer, but its
goal is not to interfere with prompts, so this commit adds
an optional prompt flag to ui.write and has _readline
include that argument.

ui.promptchoice calls ui.prompt which calls ui._readline.

This commit also updates hgext.color.write.
2016-03-25 21:51:00 +00:00
Yuya Nishihara
634500f64e templater: relax unquotestring() to fall back to bare string
This is convenient for our use case where quotes are optional except in
a map file.
2016-03-26 18:12:12 +09:00
Yuya Nishihara
e2dfdaa910 debugrevspec: show expanded/concatenated states before printing trees
The debugrevspec command prints at most 4 parsed trees. It wasn't easy to
tell which tree belongs to which state.
2016-03-26 19:01:12 +09:00
Yuya Nishihara
f0125a308f templater: do not abuse SyntaxError to report errors in template map file
SyntaxError is the class representing syntax errors in Python code. We should
use a dedicated exception class for our needs. With this change, unnecessary
re-wrapping of SyntaxError can be eliminated.
2016-03-26 18:01:04 +09:00
Martijn Pieters
9775d72529 graphmod: set default edge styles for ascii graphs (BC)
Leaving regular parent edges set to |, grandparent edges set to : and missing
parent edges set to end early. A sample graph:

  o    changeset:   32:d06dffa21a31
  |\   parent:      27:886ed638191b
  | :  parent:      31:621d83e11f67
  | :
  o :  changeset:   31:621d83e11f67
  |\:  parent:      21:d42a756af44d
  | :  parent:      30:6e11cd4b648f
  | :
  o :    changeset:   30:6e11cd4b648f
  |\ \   parent:      28:44ecd0b9ae99
  | ~ :  parent:      29:cd9bb2be7593
  |  /
  o :    changeset:   28:44ecd0b9ae99
  |\ \   parent:      1:6db2ef61d156
  | ~ :  parent:      26:7f25b6c2f0b9
  |  /
  o :    changeset:   26:7f25b6c2f0b9
  |\ \   parent:      18:1aa84d96232a
  | | :  parent:      25:91da8ed57247
  | | :
  | o :  changeset:   25:91da8ed57247
  | |\:  parent:      21:d42a756af44d
  | | :  parent:      24:a9c19a3d96b7
  | | :
  | o :    changeset:   24:a9c19a3d96b7
  | |\ \   parent:      0:e6eb3150255d
  | | ~ :  parent:      23:a01cddf0766d
  | |  /
  | o :    changeset:   23:a01cddf0766d
  | |\ \   parent:      1:6db2ef61d156
  | | ~ :  parent:      22:e0d9cccacb5d
  | |  /
  | o :  changeset:   22:e0d9cccacb5d
  |/:/   parent:      18:1aa84d96232a
  | :    parent:      21:d42a756af44d
  | :
  | o    changeset:   21:d42a756af44d
  | |\   parent:      19:31ddc2c1573b
  | | |  parent:      20:d30ed6450e32
  | | |
  +---o  changeset:   20:d30ed6450e32
  | | |  parent:      0:e6eb3150255d
  | | ~  parent:      18:1aa84d96232a
  | |
  | o    changeset:   19:31ddc2c1573b
  | |\   parent:      15:1dda3f72782d
  | ~ ~  parent:      17:44765d7c06e0
  |
  o  changeset:   18:1aa84d96232a
     parent:      1:6db2ef61d156
     parent:      15:1dda3f72782d
2016-03-23 13:34:47 -07:00
Matt Mackall
f8bc5de07b merge with stable 2016-03-25 16:23:23 -05:00
Martin von Zweigbergk
734edd8a4a subrepo: adapt to git's recent renames-by-default
Git turned on renames by default in commit 5404c11 (diff: activate
diff.renames by default, 2016-02-25). The change is destined for
release in git 2.8.0. The change breaks test-subrepo-git, which test
specifically that a moved file is reported as a removal and an
addition. Fix by passing --no-renames (available in git since mid
2006) to the diff commands that don't use --quiet (should make no
difference for those).
2016-03-24 09:38:11 -07:00