Commit Graph

14232 Commits

Author SHA1 Message Date
Anton Shestakov
0fef35aa40 hgweb: fix help pages title in gitweb and monoblue
Help pages in gitweb and monoblue were setting a completely inappropriate
title: "Branches". Let's have a proper title (copy-pasted from paper style).
2015-06-30 23:31:19 +08:00
Anton Shestakov
749eb6196d hgweb: don't show summary link as active on error pages in monoblue
These two error pages in monoblue think they are the summary page, when they
clearly aren't.
2015-06-30 22:15:58 +08:00
Matt Harbison
d1eccc45b8 identify: build the tag list directly instead of using wctx.tags()
The current implementation of workingctx.tags() returns the tags of the parents.
This causes the calculation of {lastesttagdistance} from wdir() to be wrong.
The value when updated to a tag is 0, but updated to the tag's child is 2, the
child of that 3, and so on.  This prepares for workingctx.tags() to not report
the parent tags.
2015-06-28 13:22:17 -04:00
Matt Harbison
36b6d6cb5d identify: avoid a crash when given '-r wdir()'
The crash was 'NoneType is not subscriptable' in hexfunc(ctx.node()), because
the node for wdir() is None.  This can be avoided simply by detecting 'wdir()'
and taking the existing path for no given revision.
2015-06-28 18:39:58 -04:00
Matt Mackall
2173cc3777 merge with stable 2015-06-29 16:38:22 -05:00
Gregory Szorc
f20e6c2557 demandimport: support importing builtins for Python 3
__builtin__ was renamed to builtins in Python 3. If importing
__builtin__ fails, fall back to importing builtins in order to support
Python 3.
2015-06-27 17:31:06 -07:00
Gregory Szorc
11ddb8efd9 demandimport: alias __builtin__ as builtins
Python 3 renamed the __builtin__ module to builtins. In preparation for
supporting Python 3, alias the imported module as "builtins."
2015-06-27 17:29:15 -07:00
Pierre-Yves David
2c879590b7 bufferedinputpipe: remove N^2 computation of buffer length (issue4735)
The assumption that dynamically computing the length of the buffer was N^2, but
negligible because fast was False. So we drop the dynamic computation and
manually keep track of the buffer length.
2015-06-26 11:29:50 -07:00
Pierre-Yves David
4d8c7e6435 bufferedinputpipe: remove an outdate comment
This comment is the remains of a intermediate implementation using

  self._buffer += data

This implementation never made it to the repository and we can safely drop the
comment.
2015-06-27 11:51:25 -07:00
Siddharth Agarwal
b0b5c35a2f statichttprepo: kill off sopener 2015-06-25 22:20:09 -07:00
Siddharth Agarwal
a5b449ed2e obsolete: replace references to 'sopener' with 'svfs' 2015-06-25 22:19:49 -07:00
Siddharth Agarwal
6bd6a96a1b exchange: replace references to 'sopener' with 'svfs' 2015-06-25 22:18:56 -07:00
Siddharth Agarwal
8a17b8b38b localrepo: kill off sopener (API)
sopener is deprecated since 12df7401e8cd (Mercurial 2.3). It's annoying for
extension authors to have to deal with both. Let's just kill it off.
2015-06-25 22:17:52 -07:00
Matt Harbison
d4e8d4f13c archive: don't assume '.' is being archived for changessincelatesttag
Hardcoding '.' is wrong, and yielded strange results when archiving old
revisions.  For example, when archiving the cset that adds the signature to 3.4
(a4f6d198e7df), the resulting value was previously 51 (the number of commits on
stable between 3.4 and today), even though it was a direct descendant of a tag,
with a {latesttagdistance} of 2.  This still includes all other _ancestor_ paths
not included in {latesttag}.

Note that archiving wdir() currently blows up several lines above this when
building the 'base' variable.  Since wdir() isn't documented, ignore that it
needs work to handle wdir() here for now.
2015-06-25 21:16:47 -04:00
Anton Shestakov
f9942be78e hgweb: use css for stripey background in coal
Since "fd4945970469 or b7c98f01667e::be1d0b03b11a" paper style used css for
stripes in background for browsing files, for listing branches/tags/bookmarks,
and so on.

Since coal borrows many paper templates (e.g. shortlogentry.tmpl), it actually
tried to do the same, but it didn't have the needed css classes. You can
compare https://selenic.com/hg?style=coal with
https://selenic.com/hg?style=paper and see how log view in coal style has plain
white background, unlike the one in paper style. This wasn't intended.

Let's copy css classes directly from style-paper.css and remove parity classes
from elements that don't need them anymore. This makes plain white background
have stripes again and makes coal/map even more similar to paper/map (which can
ease porting changes or %including paper/map in future).
2015-06-25 20:27:36 +08:00
Matt Harbison
906e3d1b5d templatekw: correct typo in activebookmark documentation 2015-06-24 11:15:00 -04:00
Matt Mackall
0508027d17 merge with stable 2015-06-24 13:41:27 -05:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Gregory Szorc
3aa1c73868 global: mass rewrite to use modern octal syntax
Python 2.6 introduced a new octal syntax: "0oXXX", replacing "0XXX". The
old syntax is not recognized in Python 3 and will result in a parse
error.

Mass rewrite all instances of the old octal syntax to the new syntax.

This patch was generated by `2to3 -f numliterals -w -n .` and the diff
was selectively recorded to exclude changes to "<N>l" syntax conversion,
which will be handled separately.
2015-06-23 22:30:33 -07:00
Laurent Charignon
a48a11f98e revert: change the direction of revert -i
After the discussion on the list about hg revert -i, it seems like we are
satisfied with what we called proposition 2. It shows the changes to revert in
the same direction as hg diff. This patch makes it the default option.
It changes all the + in - and vice versa in the tests for revert -i.
2015-06-23 14:28:15 -07:00
Yuya Nishihara
ec7ad76871 templater: fix handling of \-escapes in raw string literals
The backslash character should start escape sequences no matter if a string is
prefixed with 'r'. They are just not interpreted as escape sequences in raw
strings. revset.tokenize() handles them correctly, but templater didn't.

https://docs.python.org/2/reference/lexical_analysis.html#string-literals
2015-06-21 13:24:43 +09:00
Yuya Nishihara
5747b2c8e6 parser: update documentation about tokenizer and elements 2015-06-21 00:56:09 +09:00
Yuya Nishihara
fe462ed8ac parser: accept iterator of tokens instead of tokenizer function and program
This can simplify the interface of parse() function. Our tokenizer tends to
have optional arguments other than the message to be parsed.

Before this patch, the "lookup" argument existed only for the revset, and the
templater had to pack [program, start, end] to be passed to its tokenizer.
2015-06-21 00:49:26 +09:00
Gregory Szorc
8e1cdd21f4 verify: print hint to run debugrebuildfncache
Corrupt fncache is now a recoverable operation. Inform the user how to
recover from this warning.
2015-06-20 20:11:53 -07:00
Gregory Szorc
8f8cc06067 repair: add functionality to rebuild fncache
Currently, there is no way to recover from a missing or corrupt fncache
file in place (a clone is required). For certain use cases such as
servers and with large repositories, an in-place repair may be
desirable. This patch adds functionality for in-place repair of the
fncache.

The `hg debugrebuildfncache` command is introduced. It ensures the
fncache is up to date by reconstructing the fncache from all seen files
encountered during a brute force traversal of the repository's entire
history.

The command will add missing entries and will prune excess ones.

Currently, the command no-ops unless the repository has the fncache
requirement. The command could later grow the ability to "upgrade" an
existing repository to be fncache enabled, if desired.

When testing this patch on a local clone of the Firefox repository, it
removed a bunch of entries. Investigation revealed that removed entries
belonged to empty (0 byte size) .i filelogs. The functionality for
pruning fncache of stripped revlogs was introduced in 93ba76bfbe8a, so
the presence of these entries likely predates this feature.
2015-06-22 09:59:48 -07:00
Jordi Gutiérrez Hermoso
a6104a4075 import: cross-reference patch.fuzz option from hg help import 2015-06-23 13:56:53 -04:00
Jordi Gutiérrez Hermoso
3d8e519a03 import: cross-reference ui.patch option from hg help import
This is a fairly obscure patch option. It seems reasonable to expose
it a bit more from the help text for `hg import`.
2015-06-23 13:57:39 -04:00
Jordi Gutiérrez Hermoso
c63f5d825c doc: document the ui.patch option
This option has been undocumented since 2ad3e7d82d89 (July 2007).
2015-06-23 13:47:42 -04:00
Pierre-Yves David
4686ca0994 revset: rework 'filteredset.last'
'isascending' and 'isdescending' are methods, not attributes. This led 'last()'
to misbehave on some non-ascending filtered sets.
2015-06-22 13:48:01 -07:00
Pierre-Yves David
9c4de6ba91 revset: improves time complexity of 'roots(xxx)'
The canonical way of doing 'roots(X)' is 'X - children(X)'. This is what the
implementation used to be. However, computing children is expensive because it
is unbounded. Any changesets in the repository may be a children of '0' so you
have to look at all changesets in the repository to compute children(0).
Moreover the current revsets implementation for children is not lazy, leading to
bad performance when fetching the first result.


There is a more restricted algorithm to compute roots:

    roots(X) = [r for r in X if not parents(r) & X]

This achieve the same result while only looking for parent/children relation in
the X set itself, making the algorithm 'O(len(X))' membership operation.
Another advantages is that it turns the check into a simple filter, preserving
all laziness property of the underlying revsets.

The speed is very significant and some laziness is restored.

-) revset without 'roots(...)' to compare to base line
0) before this change
1) after this change

revset #0: roots((tip~100::) - (tip~100::tip))
   plain         min           last
-) 0.001082      0.000993      0.000790
0) 0.001366      0.001385      0.001339
1) 0.001257  92% 0.001028  74% 0.000821  61%

revset #1: roots((0::) - (0::tip))
   plain         min           last
-) 0.134551      0.144682      0.068453
0) 0.161822      0.171786      0.157683
1) 0.137583  85% 0.146204  85% 0.070012  44%

revset #2: roots(tip~100:)
   plain         min           first         last
-) 0.000219      0.000225      0.000231      0.000229
0) 0.000513      0.000529      0.000507      0.000539
1) 0.000463  90% 0.000269  50% 0.000267  52% 0.000463  85%

revset #3: roots(:42)
   plain         min           first         last
-) 0.000119      0.000146      0.000146      0.000146
0) 0.000231      0.000254      0.000253      0.000260
1) 0.000216  93% 0.000186  73% 0.000184  72% 0.000244  93%

revset #4: roots(not public())
   plain         min           first
-) 0.000478      0.000502      0.000504
0) 0.000611      0.000639      0.000634
1) 0.000604      0.000560  87% 0.000558

revset #5: roots((0:tip)::)
   plain         min           max           first         last
-) 0.057795      0.004905      0.058260      0.004908      0.038812
0) 0.132845      0.118931      0.130306      0.114280      0.127742
1) 0.111659  84% 0.005023   4% 0.111658  85% 0.005022   4% 0.092490  72%

revset #6: roots(0::tip)
   plain         min           max           first         last
-) 0.032971      0.033947      0.033460      0.032350      0.033125
0) 0.083671      0.081953      0.084074      0.080364      0.086069
1) 0.074720  89% 0.035547  43% 0.077025  91% 0.033729  41% 0.083197

revset #7: 42:68 and roots(42:tip)
   plain         min           max           first         last
-) 0.006827      0.000251      0.006830      0.000254      0.006771
0) 0.000337      0.000353      0.000366      0.000350      0.000366
1) 0.000318  94% 0.000297  84% 0.000353      0.000293  83% 0.000351

revset #8: roots(0:tip)
   plain         min           max           first         last
-) 0.002119      0.000145      0.000147      0.000147      0.000147
0) 0.047441      0.040660      0.045662      0.040284      0.043435
1) 0.038057  80% 0.000187   0% 0.034919  76% 0.000186   0% 0.035097  80%

revset #0: roots(:42 + tip~42:)
   plain         min           max           first         last          sort
-) 0.000321      0.000317      0.000319      0.000308      0.000369      0.000343
0) 0.000772      0.000751      0.000811      0.000750      0.000802      0.000783
1) 0.000632  81% 0.000369  49% 0.000617  76% 0.000358  47% 0.000601  74% 0.000642  81%
2015-06-22 10:19:12 -07:00
Gregory Szorc
fc448078d4 osutil: remove Python 2.4 errno conversion workaround 2015-06-22 10:11:31 -07:00
Gregory Szorc
be5724ac71 patch: remove email import workaround for Python 2.4
Python 2.6 provides access to the sub-modules just fine. This workaround
is no longer needed since we no longer support Python 2.4.
2015-06-22 10:09:08 -07:00
Yuya Nishihara
930b78aeff templater: evaluate "query" argument passed to revset()
revset() had the same issue as f921aa09b251. It crashed by passing non-string
expression.
2015-06-20 23:13:34 +09:00
Matt Harbison
f536f82114 match: let 'path:.' and 'path:' match everything (issue4687)
Previously, both queries exited with code 1, printing nothing.  The pattern in
the latter query is normalized to '.', so it is really the same case.
2015-06-20 19:59:26 -04:00
Gregory Szorc
0648c6a2bf bundle2: reword debug message for invalid .hgtags data
marmoute requested a follow-up to make the verb the first word.
2015-06-20 18:03:38 -07:00
Yuya Nishihara
bd614aebda templater: evaluate arguments passed to diff() appropriately
Before this patch, diff() crashed by passing non-string expression because
it didn't evaluate arguments at all.
2015-06-13 20:14:22 +09:00
Gregory Szorc
2f52f24ede parsers: do not cache RevlogError type (issue4451)
Index lookups raise RevlogError when the lookup fails. The previous
implementation was caching a reference to the RevlogError type in a
static variable. This assumed that the "mercurial.error" module was
only loaded once and there was only a single copy of it floating
around in memory. Unfortunately, in some situations - including
certain mod_wsgi configurations - this was not the case: the
"mercurial.error" module could be reloaded. It was possible for a
"RevlogError" reference from the first interpreter to be used by
a second interpreter. While the underlying thing was a
"mercurial.error.RevlogError," the object IDs were different, so
the Python code in revlog.py was failing to catch the exception! This
error has existed since the C index lookup code was implemented in
changeset 1e47437a1ca7, which was first released in Mercurial 2.2 in
2012.
http://emptysqua.re/blog/python-c-extensions-and-mod-wsgi/#static-variables-are-shared
contains more details.

This patch removes the caching of the RevlogError type from the
function.

Since pretty much the entire function was refactored and the return
value of the function wasn't used, I changed the function signature
to not return anything.

For reasons unknown to me, we were calling PyErr_SetObject()
with the type of RevlogError and an instance of RevlogError. This
was equivalent to the Python code "raise RevlogError(RevlogError)".
This seemed wonky and completely unnecessary. The Python code only
cares about the type of the exception, not its contents. So I got
rid of this complexity.

This is my first Python C extension patch. Please give extra scrutiny
to it during review.
2015-06-12 14:43:59 -07:00
Yuya Nishihara
54bbfd7f6b templater: do not preprocess template string in "if" expression (issue4714)
The problem was spotted at cd1b50e99ed8, that says "this patch invokes it
with "strtoken='rawstring'" in "_evalifliteral()", because "t" is the result
of "arg" evaluation and it should be "string-escape"-ed if "arg" is "string"
expression." This workaround is no longer valid since 72be08a15d8d introduced
strict parsing of '\{'.

Instead, we should interpret bare token as "string" or "rawstring" template.
This is what buildmap() does at parsing phase.
2015-06-08 18:14:22 +09:00
Laurent Charignon
e02fe4b93e crecord: fix three typos introduced while moving crecord into core
When moving crecord to core, I did a search an replace to remove all of the
variable with caps letter. Doing so, I unfortunately changed some commands
with capital letter shortcut to their lowercase counterpart. I fixed one
of these cases in bfcbb3995330. This patch fixes all of the remaining cases.
2015-06-05 12:57:21 -07:00
Laurent Charignon
8979893774 crecord: fix a typo introduced when moving crecord to core
When moving crecord to core, I did a search an replace to remove all of the
variable with caps letter. Doing so, I unfortunately changed the 'F' command
to 'f' leading to two 'f' commands, one never used. This patch fixes this
mistake and re enables the behavior of 'F'.
2015-06-05 10:44:34 -07:00
Matt Harbison
a1a73ad1ab hgwebdir: don't allow the hidden parent of a subrepo to show as a directory
Previously, if a subrepo parent had 'web.hidden=True' set, neither the parent
nor child had a repository entry.  However, the directory entry for the parent
would be listed (it wouldn't have the fancy 'web.name' if configured), and that
link went to the repo's summary page, effectively making it not hidden.

This simply disables the directory processing if a valid repository is present.
Whether or not the subrepo should be hidden is debatable, but this leaves that
behavior unchanged (i.e. it stays hidden).
2015-06-01 18:06:20 -04:00
Pierre-Yves David
9e0c5a2a51 pull: avoid race condition with 'hg pull --rev name --update' (issue4706)
The previous scheme was:

1) lookup node for all pulled revision,
2) pull said node
3) lookup the node of the checkout target
4) update the repository there.

If the remote repo changes between (1) and (3), the resolved name will be
different and (3) crash. There is actually no need for a remote lookup during
(3), we could just set the value in (1). This prevent the race condition and
save a possible network roundtrip.
2015-06-03 14:29:11 -07:00
Matt Harbison
7ed6e6b3e0 hgwebdir: avoid redundant repo and directory entries when 'web.name' is set
Previously, when 'web.name' was set on a subrepo parent and 'web.collapse=True',
the parent repo would show in the list with the configured 'web.name', and a
directory with the parent repo's filesystem name (with a trailing slash) would
also appear.  The subrepo(s) would unexpectedly be excluded from the list of
repositories.  Clicking the directory entry would go right to the repo page.

Now both the parent and the subrepos show up, without the additional directory
entry.

The configured hgweb paths used '**' for finding the repos in this scenario.


A couple of notes about the tests:

- The area where the subrepo was added has a comment that it tests subrepos,
  though none previously existed there.  One now does.

- The 'web.descend' option is required for collapse to work.  I'm not sure what
  the previous expectations were for the test.  Nothing changed with it set,
  prior to adding the code in this patch.  It is however required for this test.

- The only output changes are for the hyperlinks, obviously because of the
  'web.name' parameter.

- Without this code change, there would be an additional diff:

    --- /usr/local/mercurial/tests/test-hgwebdir.t
    +++ /usr/local/mercurial/tests/test-hgwebdir.t.err
    @@ -951,7 +951,7 @@
       /rcoll/notrepo/e/
       /rcoll/notrepo/e/e2/
       /rcoll/notrepo/f/
    -  /rcoll/notrepo/f/f2/
    +  /rcoll/notrepo/f/


     Test repositories inside intermediate directories

I'm not sure why the fancy name doesn't come out, but it is enough to
demonstrate that the parent is not listed redundantly, and the subrepo isn't
skipped.
2015-06-01 14:42:55 -04:00
FUJIWARA Katsunori
1d5cc643a1 templatekw: compare target context and its parent exactly (issue4690)
Before this patch, template keywords `{file_mods}`, `{file_adds}` and
`{file_dels}` use values gotten by `repo.status(ctx.p1().node(),
ctx.node())`.

But this doesn't work as expected if `ctx` is `memctx` or
`workingcommitctx`. Typical case of templating with these contexts is
customization of the text shown in the commit message editor by
`[committemplate]` configuration.

In this case, `ctx.node()` returns None and it causes comparison
between `ctx.p1()` and `workingctx`. `workingctx` lists up all changed
files in the working directory even at selective committing.

BTW, `{files}` uses `ctx.files()` and it works as expected.

To compare target context and its parent exactly, this patch passes
`ctx.p1()` and `ctx` without `node()`-nize. This avoids unexpected
comparison with `workingctx`.

This patch uses a little redundant template configurations in
`test-commit.t`, but they are needed to avoid regression around
problems fixed by 17e2fda16f58 and 2b999bc2d89a: accessing on `ctx`
may break `ctx._status` field.
2015-06-02 02:28:33 +09:00
Pierre-Yves David
e78e0b6b0c transaction: really fix _addbackupentry key usage (issue4684)
The fix in a795188178a1 is actually wrong. We now use the filename to match what
'_addentry'. This whole untested code is quite suspicious. This seems to point
that no one is ever running 'tr.find' for a backup file.
2015-05-26 13:02:28 -07:00
Matt Mackall
bd4df663a9 mergecopies: avoid slowdown from linkrev adjustment (issue4680)
checkcopies was using fctx.rev() which it was expecting would be
equivalent to linkrev() but was triggering the new _adjustlinkrev path.
This was making grafts and merges with large sets of potential copies
very expensive.
2015-05-26 06:45:18 -05:00
FUJIWARA Katsunori
1a1aa7a153 localrepo: pass hook argument txnid to pretxnopen hooks
Before this patch, hook argument `txnid` isn't passed to `pretxnopen`
hooks, even though `hooks` section of `hg help config` describes so.

  ``pretxnopen``
    Run before any new repository transaction is open. The reason for the
    transaction will be in ``$HG_TXNNAME`` and a unique identifier for the
    transaction will be in ``HG_TXNID``. A non-zero status will prevent the
    transaction from being opened.
2015-05-25 01:26:23 +09:00
FUJIWARA Katsunori
e07aa6e441 transaction: separate calculating TXNID from creating transaction object
Before this patch, transaction ID (TXNID) is calculated from
`transaction` object itself by `id()`, but this prevents TXNID from
being passed to `pretxnopen` hooks, which should be executed before
starting transaction processing (also any preparations for it, like
writing journal files out).

As a preparation for passing TXNID to `pretxnopen` hooks, this patch
separates calculation of TXNID from creation of `transaction` object.

This patch uses "random" library for reasonable unique ID. "uuid"
library can't be used, because it was introduced since Python 2.5 and
isn't suitable for Mercurial 3.4.x stable line.

`%f` formatting for `random.random()` is used with explicit precision
number 40, because default precision for `%f` is 6. 40 should be long
enough, even if 10**9 transactions are executed in a short time (a
second or less).

On the other hand, `time.time()` is used to ensures uniqueness of
TXNID in a long time, for safety.

BTW, platform not providing `/dev/urandom` or so may cause failure of
`import random` itself with some Python versions (see Python
issue15340 for detail http://bugs.python.org/issue15340).

But this patch uses "random" without any workaround, because:

  - "random" is already used directly in some code paths,
  - such platforms are very rare (e.g. Tru64 and HPUX), and
    http://bugs.python.org/issue15340#msg170000
  - updating Python runtime can avoid this issue
2015-05-25 01:26:19 +09:00
Yuya Nishihara
3ca8d79bef revbranchcache: return uncached branchinfo for nullrev (issue4683)
This fixes the crash caused by "branch(null)" revset. No cache should be
necessary for nullrev because changelog.branchinfo(nullrev) does not involve
IO operation.

Note that the problem of "branch(wdir())" isn't addressed by this patch.
"wdir()" will raise TypeError in many places because of None. This is the
reason why "wdir()" is still experimental.
2015-05-23 11:14:00 +09:00
Yuya Nishihara
799e490a3c revset: drop magic of fullreposet membership test (issue4682)
This patch partially backs out a9a86cbbc5b2 and adds an alternative workaround
to functions that evaluate "null" and "wdir()". Because the new workaround is
incomplete, "first(null)" and "min(null)" don't work as expected. But they were
not usable until 3.4 and "null" isn't commonly used, we can postpone a complete
fix for 3.5.

The issue4682 was caused because "branch(default)" is evaluated to
"<filteredset <fullreposet>>", keeping fullreposet magic. The next patch will
fix crash on "branch(null)", but without this patch, it would make
"null in <branch(default)>" be True, which means "children(branch(default))"
would return all revisions but merge (p2 != null).

I believe the right fix is to stop propagating fullreposet magic on filter(),
but it wouldn't fit to stable release. Also, we should discuss how to handle
"null" and "wdir()" in revset before.
2015-05-24 10:29:33 +09:00