Jun Wu <quark@fb.com> [Wed, 06 Sep 2017 12:40:00 -0700] rev 34092
rebase: do not crash rebasing merge with a parent having hidden successor
The added test will crash with previous code.
Differential Revision: https://phab.mercurial-scm.org/D640
Durham Goode <durham@fb.com> [Wed, 06 Sep 2017 18:33:55 -0700] rev 34091
changegroup: fix to allow empty manifest parts
The current chunk reading algorithm relied on counting the number of empty
chunks and comparing it to the number of chunk lists it expected (1 list of
files for cg1 and cg2, and 1 list of files + 1 list of trees for cg3). This
implicitly assumed that both the changelog part and the manifestlog part were
never empty (since them being empty would cause it to count it as one list being
done, and screw up the count). In our treemanifest code, the manifest section
could be empty, so we need to handle that case.
This patches refactors that code to be more explicit about how it counts the
expected parts.
Differential Revision: https://phab.mercurial-scm.org/D646
Mads Kiilerich <mads@kiilerich.com> [Mon, 11 Sep 2017 00:42:24 +0200] rev 34090
mq: create non-lossy patches, also with custom global diff configuration
Users with custom [diff] configuration most certainly didn't intend it to make
mq lose changes. It could:
* git is handled perfectly fine.
* nobinary could make mq leave some files out from the patches.
* noprefix could make mq itself (and probably also other tools) fail to apply
patches without the usual a/b prefix.
* ignorews, ignorewsamount, or ignoreblanklines could create patches with
missing whitespace that could fail to apply correctly.
Thus, when refreshing patches, use patch.difffeatureopts, optionally with git
as before, but without the config options for whitespace and format changing
that most likely will cause loss or problems.
(patch.diffopts is just patch.difffeatureopts with all options enabled and can
be replaced with that.)
Mads Kiilerich <mads@kiilerich.com> [Mon, 11 Sep 2017 00:42:22 +0200] rev 34089
mq: test coverage of how [diff] configuration influence can break mq patches
Jun Wu <quark@fb.com> [Tue, 05 Sep 2017 15:18:45 -0700] rev 34088
wrapcommand: use functools.partial
Like the previous patch, this helps remove noises in traceback.
Practically, this removes another 6 lines in `rebase -s . -d .` traceback in
my setup:
....
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
-File "hg/mercurial/extensions.py", line 331, in closure
- return func(*(args + a), **kw)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
File "fb-hgext/hgext3rd/fbhistedit.py", line 283, in _rebase
return orig(ui, repo, **opts)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
-File "hg/mercurial/extensions.py", line 331, in closure
- return func(*(args + a), **kw)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
File "remotenames.py", line 633, in exrebasecmd
ret = orig(ui, repo, **opts)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
-File "hg/mercurial/extensions.py", line 331, in closure
- return func(*(args + a), **kw)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
File "fb-hgext/hgext3rd/fbamend/__init__.py", line 453, in wraprebase
return orig(ui, repo, **opts)
File "hg/mercurial/util.py", line 1118, in check
return func(*args, **kwargs)
....
Differential Revision: https://phab.mercurial-scm.org/D633
Jun Wu <quark@fb.com> [Tue, 05 Sep 2017 13:37:36 -0700] rev 34087
wrapfunction: use functools.partial if possible
Every `extensions.bind` call inserts a frame in traceback:
... in closure
return func(*(args + a), **kw)
which makes traceback noisy.
The Python stdlib has a `functools.partial` which is backed by C code and
does not pollute traceback. However it does not support instancemethod and
sets `args` attribute which could be problematic for alias handling.
This patch makes `wrapfunction` use `functools.partial` if we are wrapping a
function directly exported by a module (so it's impossible to be a class or
instance method), and special handles `wrapfunction` results so alias
handling code could handle `args` just fine.
As an example, `hg rebase -s . -d . --traceback` got 6 lines removed in my
setup:
File "hg/mercurial/dispatch.py", line 898, in _dispatch
cmdpats, cmdoptions)
-File "hg/mercurial/extensions.py", line 333, in closure
- return func(*(args + a), **kw)
File "hg/hgext/journal.py", line 84, in runcommand
return orig(lui, repo, cmd, fullargs, *args)
-File "hg/mercurial/extensions.py", line 333, in closure
- return func(*(args + a), **kw)
File "fb-hgext/hgext3rd/fbamend/hiddenoverride.py", line 119, in runcommand
result = orig(lui, repo, cmd, fullargs, *args)
File "hg/mercurial/dispatch.py", line 660, in runcommand
ret = _runcommand(ui, options, cmd, d)
-File "hg/mercurial/extensions.py", line 333, in closure
- return func(*(args + a), **kw)
File "hg/hgext/pager.py", line 69, in pagecmd
return orig(ui, options, cmd, cmdfunc)
....
Differential Revision: https://phab.mercurial-scm.org/D632
Saurabh Singh <singhsrb@fb.com> [Fri, 01 Sep 2017 12:34:36 -0700] rev 34086
cmdutil: remove redundant commitfunc parameter in amend (API)
Since the redundant commit during the amend has been been removed, there is no
need for commit callback function in amend now. Therefore, this commit removes
the unused parameter "commmitfunc" which was being used for this purpose.
Test Plan:
Ensured that all the tests pass
Differential Revision: https://phab.mercurial-scm.org/D635
Saurabh Singh <singhsrb@fb.com> [Fri, 01 Sep 2017 12:34:36 -0700] rev 34085
cmdutil: remove the redundant commit during amend
There was an extra commit made during the amend operation to track the
changes to the working copy. However, this logic was written a long time back
and newer API's make this extra commit redundant. Therefore, I am removing the
extra commit. After this change, I noticed that
- Execution time of the cmdutil.amend improved by over 40%.
- Execution time of "hg commit --amend" improved by over 20%.
Test Plan:
I ensured that the all the hg tests passed after the change. I had
to fix a few tests which were aware of the extra commit made during the amend.
Differential Revision: https://phab.mercurial-scm.org/D636
Jun Wu <quark@fb.com> [Wed, 06 Sep 2017 12:56:19 -0700] rev 34084
checknlink: rename file object from 'fd' to 'fp'
Make it clear that `fp` (`file` object) is different from `fd` (low-level
file descriptor number).
Differential Revision: https://phab.mercurial-scm.org/D642
Martin von Zweigbergk <martinvonz@google.com> [Tue, 05 Sep 2017 15:06:45 -0700] rev 34083
cleanup: rename "matchfn" to "match" where obviously a matcher
We usually call matchers either "match" or "m" and reserve "matchfn"
for functions.
Differential Revision: https://phab.mercurial-scm.org/D641
Martin von Zweigbergk <martinvonz@google.com> [Wed, 06 Sep 2017 08:22:54 -0700] rev 34082
check-code: fix incorrect capitalization in camelcase regex
This was found internally at Google as part of a monorepo-wide
cleanup.
Differential Revision: https://phab.mercurial-scm.org/D637
Martin von Zweigbergk <martinvonz@google.com> [Wed, 06 Sep 2017 10:41:13 -0700] rev 34081
amend: use context manager for config override
Differential Revision: https://phab.mercurial-scm.org/D639
Martin von Zweigbergk <martinvonz@google.com> [Wed, 06 Sep 2017 10:42:02 -0700] rev 34080
amend: delete dead assignment to "newid"
Differential Revision: https://phab.mercurial-scm.org/D638
Jun Wu <quark@fb.com> [Fri, 01 Sep 2017 17:09:53 -0700] rev 34079
checknlink: use a random temp file name for checking
Previously, if `.hg/store/00manifest.d.hgtmp1` exists, hg will copy the
entire `00manifest.d` every time when appending new manifest revisions.
That could happen if Mercurial or the machine crashed when `.hgtmp1` was
just created but not deleted yet.
This patch changes the fixed name to a random generated name. To be
consistent with D468, `~` suffix was used.
Differential Revision: https://phab.mercurial-scm.org/D611
Pulkit Goyal <7895pulkit@gmail.com> [Sun, 03 Sep 2017 02:34:01 +0530] rev 34078
copytrace: move the default copytracing algorithm in a new function
We are going to introduce a new fast heuristic based copytracing algorithm, so
lets make mergecopies the function which decides which algorithm to go with and
then calls the related function.
While I was here, I add a line in test-copy-move-merge.t saying its a test
related to the full copytracing algorithm.
Differential Revision: https://phab.mercurial-scm.org/D622
Pulkit Goyal <7895pulkit@gmail.com> [Sun, 03 Sep 2017 01:52:19 +0530] rev 34077
copytrace: replace experimental.disablecopytrace config with copytrace (BC)
This patch replaces experimental.disablecopytrace with experimental.copytrace.
Since the words does not means the same, the default value is also changed. Now
experimental.copytrace defaults to 'on'. The new value is not boolean value as
we will be now having two different algorithms (current one and heuristics one
to be imported from fbext) so we need this to be have more options than
booleans.
The old config option is not kept is completely replaced as that was under
experimental and we don't gurantee BC to experimental things.
.. bc::
The config option for copytrace `experimental.disablecopytrace` is now
replaced with `experimental.copytrace` which defaults to `on`. If you need to
turn off copytracing, add `[experimental] copytrace = off` to your config.
Differential Revision: https://phab.mercurial-scm.org/D621
Phil Cohen <phillco@fb.com> [Tue, 05 Sep 2017 12:04:02 -0700] rev 34076
filemerge: use fctx.write() in the internal:dump tool, instead of copy
This is slower but allows this tool to work with the "deferred writes"
milestone of in-memory merge.
The performance hit is not too noticiable since this only used for the :dump
merge tool during a conflict.
Differential Revision: https://phab.mercurial-scm.org/D617
Martin von Zweigbergk <martinvonz@google.com> [Thu, 31 Aug 2017 22:39:10 -0700] rev 34075
largefiles: remove unused assignments from wrapfunction()
The return values from wrapfunction() were never used here. Using the
value is also a little tricky and wrappedfunction() should be
preferred, so let's just delete the assignments.
There's also a bunch of return values from wrapcommand() being
assigned to a variable here, but at least that value can be (and is
used after some of the assignments).
Differential Revision: https://phab.mercurial-scm.org/D618
the31k <the31k@thethirty.one> [Thu, 31 Aug 2017 18:24:08 +0300] rev 34074
branches: correctly show inactive multiheaded branches
Issue being fixed here: `hg branches` incorrectly renders inactive multiheaded
branches as active if they have closed heads.
Example:
```
$ hg log --template '{rev}:{node|short} "{desc}" ({branch}) [parents: {parents}]\n'
4:
2e2fa7af8357 "merge" (default) [parents: 0:
c94e548c8c7d 3:
7be622ae5832 ]
3:
7be622ae5832 "2" (somebranch) [parents: 1:
81c1d9458987 ]
2:
be82cf30409c "close" (somebranch) [parents: ]
1:
81c1d9458987 "1" (somebranch) [parents: ]
0:
c94e548c8c7d "initial" (default) [parents: ]
$ hg branches
default 4:
2e2fa7af8357
somebranch 3:
7be622ae5832
```
Branch `somebranch` have two heads, the 1st one being closed (rev 2) and
the other one being merged into default (rev 3). This branch should be shown as
inactive one.
This happens because we intersect branch heads with repo heads to check branch
activity. In this case intersection in a set with one node (rev 2). This head
is closed but the branch is marked as active nevertheless.
Fix is to check branch activity by intersecting only open heads set.
Fixed output:
```
$ hg branches
default 4:
2e2fa7af8357
somebranch 3:
7be622ae5832 (inactive)
```
Relevant tests for multihead branches added to test-branches suite.
Implentation note about adding `iteropen` method:
At first I have tried to modify `iterbranches` is such a way that it would
filter out closed heads itself. For example it could have `closed=False`
parameter. But in this case we would have to filter closed tips as well.
Reasoning in terms of `hg branches` we actually are not allowed to do this.
Also, we need to do heads filtering only if tip is not closed itself. But if it
is - we are ok to skip filtering, because branch is already known to be inactive.
So we can't implement heads filtering in `iterbranches` in elegant way, because
we will end up with something like `closed_heads=False` or even
`closed_heads_is_tip_is_open`. Finally I decided to move this logic to the
`branches` function, adding `iteropen` helper method.
Differential Revision: https://phab.mercurial-scm.org/D583
Yuya Nishihara <yuya@tcha.org> [Sun, 03 Sep 2017 21:17:25 +0900] rev 34073
parser: stabilize output of prettyformat() by using byte-safe repr()
The format of leaf nodes is slightly changed so they look more similar to
internal nodes.
Yuya Nishihara <yuya@tcha.org> [Sun, 03 Sep 2017 17:51:23 +0900] rev 34072
py3: fix repr(util.url) to return system string
This is required on Python 3.
Yuya Nishihara <yuya@tcha.org> [Sun, 03 Sep 2017 17:37:17 +0900] rev 34071
py3: use bytes[n:n + 1] to get bytes in templater._parsetemplate()
Yuya Nishihara <yuya@tcha.org> [Sun, 03 Sep 2017 17:14:53 +0900] rev 34070
py3: fix type of attribute name in smartset.py
Yuya Nishihara <yuya@tcha.org> [Sun, 03 Sep 2017 17:03:23 +0900] rev 34069
py3: fix mixed bytes/unicode in revsetlang._aliassyminitletters
Yuya Nishihara <yuya@tcha.org> [Sun, 03 Sep 2017 15:01:23 +0900] rev 34068
py3: fix type of regex literals in subrepo.py
Yuya Nishihara <yuya@tcha.org> [Sun, 03 Sep 2017 16:19:20 +0900] rev 34067
py3: replace bytes[n] with bytes[n:n + 1] in patch.py where needed
Yuya Nishihara <yuya@tcha.org> [Sun, 03 Sep 2017 16:12:15 +0900] rev 34066
py3: fix type of regex literals in patch.py
Jun Wu <quark@fb.com> [Mon, 28 Aug 2017 14:49:00 -0700] rev 34065
revset: optimize "draft() & ::x" pattern
The `draft() & ::x` type query could be common for selecting one or more
draft feature branches being worked on.
Before this patch, `::x` may travel through the changelog DAG for a long
distance until it gets a smaller revision number than `min(draft())`. It
could be very slow on long changelog with distant (in terms of revision
numbers) drafts.
This patch adds a fast path for this situation, and will stop traveling the
changelog DAG once `::x` hits a non-draft revision.
The fast path also works for `secret()` and `not public()`.
To measure the performance difference, I used drawdag to create a repo that
emulates distant drafts:
DRAFT4
|
DRAFT3 # draft
/
PUBLIC9999 # public
|
PUBLIC9998
|
. DRAFT2
. |
. DRAFT1 # draft
| /
PUBLIC0001 # public
And measured the performance using the repo:
(BEFORE)
$ hg perfrevset 'draft() & ::(DRAFT2+DRAFT4)'
! wall 0.017132 comb 0.010000 user 0.010000 sys 0.000000 (best of 156)
$ hg perfrevset 'draft() & ::(all())'
! wall 0.024221 comb 0.030000 user 0.030000 sys 0.000000 (best of 113)
(AFTER)
$ hg perfrevset 'draft() & ::(DRAFT2+DRAFT4)'
! wall 0.000243 comb 0.000000 user 0.000000 sys 0.000000 (best of 9303)
$ hg perfrevset 'draft() & ::(all())'
! wall 0.004319 comb 0.000000 user 0.000000 sys 0.000000 (best of 655)
Differential Revision: https://phab.mercurial-scm.org/D441
Jun Wu <quark@fb.com> [Fri, 01 Sep 2017 12:13:17 -0700] rev 34064
phabricator: add a config to use curl for communication
Not sure why, but I got `phabsend` hang on work network pretty frequently.
The traceback indicates it hangs at `_sslobj.do_handshake()`:
File "mercurial/sslutil.py", line 404, in wrapsocket
sslsocket = sslcontext.wrap_socket(sock, server_hostname=serverhostname)
File "/usr/lib/python2.7/ssl.py", line 363, in wrap_socket
_context=self)
File "/usr/lib/python2.7/ssl.py", line 611, in __init__
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 840, in do_handshake
self._sslobj.do_handshake()
I had tried adding `timeout` in various places but they seem not effective.
It seems easier to just allow shelling out to `curl` with retry and timeout
flags.
This could also be helpful for people with an older Python installed without
modern security (SNI).
Differential Revision: https://phab.mercurial-scm.org/D605
Jun Wu <quark@fb.com> [Thu, 24 Aug 2017 18:00:23 -0700] rev 34063
phabricator: standardize colors
Previously, the `--confirm` text could have colors but the main `phabsend`
does not. This patch adjusts the main command so it also has colors.
A default color table was added so the colors are visible by default.
Differential Revision: https://phab.mercurial-scm.org/D515
Kyle Lippincott <spectral@google.com> [Fri, 01 Sep 2017 14:00:13 -0700] rev 34062
wireproto: do not abort after successful lookup
As far as I can tell, this interface originally used 'return' here, so the
"fallthrough" to self._abort made sense. When it was switched to 'yield' this
didn't make sense, but doesn't impact most uses because the 'plain' wrapper in
peer.py's 'batchable' decorator only attempts to yield two items (args and
value).
When using iterbatch, however, it attempts to verify that the @batchable
generators only emit 2 results, by expecting a StopIteration when attempting to
access a third.
Differential Revision: https://phab.mercurial-scm.org/D608
Jun Wu <quark@fb.com> [Fri, 01 Sep 2017 16:44:30 -0700] rev 34061
check-code: forbid "\S" in egrep regular expression
BSD `egrep` does not like it. So let's forbid it.
Differential Revision: https://phab.mercurial-scm.org/D610
Jun Wu <quark@fb.com> [Fri, 01 Sep 2017 15:47:32 -0700] rev 34060
check-code: forbid using bash in shebang
Some platforms (ex. FreeBSD) do not have `bash` by default. Therefore it
should not be used in test scripts.
Differential Revision: https://phab.mercurial-scm.org/D609
Saurabh Singh <singhsrb@fb.com> [Fri, 01 Sep 2017 12:34:34 -0700] rev 34059
amend: add tests for amending only some files from commit to be amended
We do not have robust enough tests for scenarios where only some files in a
changeset are amended. This presents an interesting scenario because the
working copy could have modified versions of the remaining files in the
pre-amend changeset. Therefore, I have added some tests to ensure that amend
behaves as expected in these scenarios.
Test Plan:
Ensured that the test "test-commit-amend.t" passes.
Differential Revision: https://phab.mercurial-scm.org/D596
Yuya Nishihara <yuya@tcha.org> [Sat, 02 Sep 2017 21:49:45 +0900] rev 34058
test-editor-filename: fix portability of fake editor command
- /bin/bash doesn't exist on FreeBSD
- edit is executed by cmd.exe on Windows
Saurabh Singh <singhsrb@fb.com> [Fri, 01 Sep 2017 12:34:36 -0700] rev 34057
amend: moving first assignment of newid closer to its use
newid was needlessly further away from where its intended to be used
leading to bad readability. This commit moves it to address the same. The end
goal is to remove the redundant commit in the amend code path and this commit
takes care of cleaning up some unrelated code before that change.
Test Plan:
ran the test suite
Differential Revision: https://phab.mercurial-scm.org/D597
Saurabh Singh <singhsrb@fb.com> [Thu, 31 Aug 2017 18:35:39 -0700] rev 34056
amend: rectify comment
Comment was ambiguous as there can be two parents of a changeset in mercurial.
This commit fixes the comment to clarify that the first parent is being
considered.
Test Plan:
ran the test suite
Differential Revision: https://phab.mercurial-scm.org/D595
Saurabh Singh <singhsrb@fb.com> [Fri, 01 Sep 2017 15:08:54 -0700] rev 34055
amend: removing redundant if condition
There is needless checking for the new commit hash not being equal to
the old commit hash. This condition will always be true at this point in the
code path and thus, can be removed safely. This commit removes the redundant
condition.
Test Plan:
ran the test suite.
Differential Revision: https://phab.mercurial-scm.org/D594
Michael Bolin <mbolin@fb.com> [Fri, 01 Sep 2017 20:28:26 +0000] rev 34054
editor: file created for diff action should have .diff suffix
This is a follow-up to https://phab.mercurial-scm.org/D464 (
6e6452bc441d) that
introduced the new file extension behavior. It erroneously changed `.diff` to
`.diff.hg.txt`.
Test Plan:
Verified `make tests` passes, particularly `test-editor-filename.t`.
Differential Revision: https://phab.mercurial-scm.org/D607
Jun Wu <quark@fb.com> [Fri, 01 Sep 2017 11:13:55 -0700] rev 34053
test-amend: match output using conditional test case name
D466 (
6cc8f848b4c3) allows output to be conditionally matched by test name.
This patch changes test-amend.t to use that feature, instead of duplicating
`hg amend` command or use `-q` to silence its output.
Differential Revision: https://phab.mercurial-scm.org/D601
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 31 Aug 2017 19:40:15 -0700] rev 34052
util: use set for reserved Windows filenames
Previously, we were performing membership testing against a
list. Change it to a set for a minor perf win. While we're at it,
explode the assignment in place so less work is needed at module
import time.
Differential Revision: https://phab.mercurial-scm.org/D600
Phil Cohen <phillco@fb.com> [Fri, 01 Sep 2017 11:52:20 -0700] rev 34051
context: add arbitraryfilectx, which can represent files outside the workdir
Move it from contrib/simplemerge so it can be re-used in the future.
Differential Revision: https://phab.mercurial-scm.org/D604
Phil Cohen <phillco@fb.com> [Fri, 01 Sep 2017 10:35:43 -0700] rev 34050
simplemerge: remove unused `filtereddata` parameter
Differential Revision: https://phab.mercurial-scm.org/D603
Phil Cohen <phillco@fb.com> [Fri, 01 Sep 2017 10:35:43 -0700] rev 34049
simplemerge: remove unused `repo` parameter
This is now no longer used or needed thanks to the `decodeddata()` context
function.
Differential Revision: https://phab.mercurial-scm.org/D602
Christophe de Vienne <christophe@cdevienne.info> [Tue, 29 Aug 2017 18:24:51 +0200] rev 34048
extensions: prohibit unicode defaults
If the default value of an option is a unicode string (something
than happen easily when using a 'from __future__ import unicode_literals'),
any value passed on the command line will be ignored because the fancyopts
module only checks for byte strings and not unicode strings.
Changing fancyopts behavior is easy but would make assumptions on how
the python3 port should be done, which is outside the scope of this patch.
The chosen approach is to stop an extension from being loaded when a unicode
default value is detected, with a hint for the developer.
Yuya Nishihara <yuya@tcha.org> [Sat, 19 Aug 2017 22:04:03 +0900] rev 34047
revsetlang: remove unused functions
Superseded by the _match() function.
Yuya Nishihara <yuya@tcha.org> [Wed, 17 Feb 2016 21:40:59 +0900] rev 34046
revsetlang: match tree by helper function on optimize
This should make optimize() more readable and less error-prone, but it doubles
the parsing cost.
(original)
$ python -m timeit -n10000 -s 'from mercurial import revsetlang as L' \
'L.optimize(L.analyze(L.parse("ancestors(x) and not ancestors(y)")))'
10000 loops, best of 3: 79.3 usec per loop
(this patch)
$ python -m timeit -n10000 -s 'from mercurial import revsetlang as L' \
'L._treecache.clear(); \
L.optimize(L.analyze(L.parse("ancestors(x) and not ancestors(y)")))'
10000 loops, best of 3: 201 usec per loop
Yuya Nishihara <yuya@tcha.org> [Wed, 17 Feb 2016 21:31:09 +0900] rev 34045
parser: add helper function to test if pattern matches parsed tree
This function will be used as follows:
match('ancestors(_) and not ancestors(_)', x)
See the next patch for details.
Yuya Nishihara <yuya@tcha.org> [Wed, 17 Feb 2016 21:38:25 +0900] rev 34044
revsetlang: build optimized tree by helper function
This should make optimize() more readable, but it doubles the parsing cost.
(original)
$ python -m timeit -n10000 -s 'from mercurial import revsetlang as L' \
'L.optimize(L.analyze(L.parse("::tip")))'
10000 loops, best of 3: 18.1 usec per loop
(this patch)
$ python -m timeit -n10000 -s 'from mercurial import revsetlang as L' \
'L._treecache.clear(); L.optimize(L.analyze(L.parse("::tip")))'
10000 loops, best of 3: 48.4 usec per loop
30usec isn't dominant compared to the revset evaluation, but that is a cost.
That's why a parsed tree is cached, which can benefit in hgweb or chg server.
Yuya Nishihara <yuya@tcha.org> [Wed, 17 Feb 2016 21:30:04 +0900] rev 34043
parser: add helper function that constructs parsed tree from template
This function will be used as follows:
build('only(_, _)', x, y)
See the next patch for details.
Pulkit Goyal <7895pulkit@gmail.com> [Wed, 30 Aug 2017 18:19:14 +0530] rev 34042
patch: take messages out of the function so that extensions can add entries
Extensions will want to have interactive thing for more operations or
particulary want to show more verbs. So this patch takes out the message thing
from the function so that extensions can add verbs to this. The curses one is
also not in any function so extensions can add more actions and verbs there.
Differential Revision: https://phab.mercurial-scm.org/D567
Jun Wu <quark@fb.com> [Wed, 02 Aug 2017 21:24:29 -0700] rev 34041
run-tests: allow bisecting a different repo
Add `--bisect-repo` flag which accepts a different repo to bisect.
3rd party extensions may reuse `run-tests.py` from core to run tests. Test
failure could be caused by either a core hg change or the 3rd party
extension code itself. Having a way to specify which repo to bisect is
useful.
Differential Revision: https://phab.mercurial-scm.org/D578
Jun Wu <quark@fb.com> [Wed, 02 Aug 2017 21:01:38 -0700] rev 34040
run-tests: extract prefix of bisect commands to a variable
This does not change any logic.
Differential Revision: https://phab.mercurial-scm.org/D577
Jun Wu <quark@fb.com> [Wed, 02 Aug 2017 21:01:38 -0700] rev 34039
run-tests: pass --with-hg to run-tests.py command used by bisect
This makes `run-tests.py -l test-run-tests.t` 23 seconds faster on my
laptop. Inside the test, `$ rt --known-good-rev=0 test-bisect.t` took 24.9
seconds before, and 1.2 seconds after.
Differential Revision: https://phab.mercurial-scm.org/D576
Jun Wu <quark@fb.com> [Mon, 28 Aug 2017 13:43:25 -0700] rev 34038
import-checker: allow relative import a module being checked
This would make the checker more friendly for 3rd-party code. For example,
In remotefilelog/x.py, it may have:
from . import shallowutils
That could trigger "relative import of stdlib module" if
"remotefilelog" was installed in the system. If the module being checked
conflicts with the system module, it makes sense to not treat that module as
system module. This patch makes it so.
Differential Revision: https://phab.mercurial-scm.org/D552
Phil Cohen <phillco@fb.com> [Thu, 31 Aug 2017 11:28:59 -0700] rev 34037
merge: move some of the logic in batchget() to workingfilectx
We will use this logic in two places with in-memory merge.
Differential Revision: https://phab.mercurial-scm.org/D444
Phil Cohen <phillco@fb.com> [Thu, 31 Aug 2017 11:28:59 -0700] rev 34036
filemerge: add _restorebackup
Differential Revision: https://phab.mercurial-scm.org/D404
Phil Cohen <phillco@fb.com> [Thu, 31 Aug 2017 11:28:59 -0700] rev 34035
filemerge: reduce creation of tempfiles until needed
This restricts the creation of temporary files to just `_xmerge`, when we call
an external tool.
Differential Revision: https://phab.mercurial-scm.org/D403
Phil Cohen <phillco@fb.com> [Thu, 31 Aug 2017 11:28:59 -0700] rev 34034
filemerge: add `_workingpath`
This reduces any reliance on `a`.
Differential Revision: https://phab.mercurial-scm.org/D401
Phil Cohen <phillco@fb.com> [Thu, 31 Aug 2017 11:28:59 -0700] rev 34033
filemerge: move a util copy call to filectx.write
This way a future in-memory-merge context can intercept them.
Differential Revision: https://phab.mercurial-scm.org/D400
Phil Cohen <phillco@fb.com> [Thu, 31 Aug 2017 11:28:59 -0700] rev 34032
filemerge: eliminate most uses of tempfiles
Emphasize that they're unused so we can more easily remove them later.
Differential Revision: https://phab.mercurial-scm.org/D399
Phil Cohen <phillco@fb.com> [Thu, 31 Aug 2017 11:05:19 -0700] rev 34031
filemerge: extract _maketemp and _makebackup
These functions will be modified by in-memory merge, so let's extract them first and add some comments.
This also shortens `_filemerge` a bit.
Differential Revision: https://phab.mercurial-scm.org/D388
Yuya Nishihara <yuya@tcha.org> [Thu, 31 Aug 2017 21:56:40 +0900] rev 34030
encoding: check overflow while calculating size of JSON escape buffer
The minimum input size to exploit is ~682MB (= INT_MAX / len('\\u0000') * 2)
on 32bit system, which isn't easy to achieve using Python str in 2GB process
address space, but probably doable.
Michael Bolin <mbolin@fb.com> [Wed, 30 Aug 2017 20:25:56 +0000] rev 34029
editor: use an unambiguous path suffix for editor files
Changes the API of `ui.edit()` to take an optional `action` argument,
which is used when constructing the suffix of the temp file.
Previously, it was possible to set the suffix by specifying a `suffix` to the
optional `extra` dict that was passed to `ui.edit()`, but the goal is to
drop support for `extra.suffix` and make `action` a required argument.
To this end, `ui.edit()` now yields a `develwarn()` if `action` is not set
or if `extra.suffix` is set.
I updated all calls to `ui.edit()` I could find in `hg-crew` to specify the
appropriate `action`. This means that when creating a commit, instead
of the path to the editor file being something like:
`/tmp/hg-editor-XXXXXX.txt`
it is now something like:
`/tmp/hg-editor-XXXXXX.commit.hg.txt`
Some editors (such as Atom) make it possible to statically define a [TextMate]
grammar for files with a particular suffix. For example, because Git reliably
uses `.git/COMMIT_EDITMSG` and `.git/MERGE_MSG` as the paths for commit-type
messages, it is trivial to define a grammar that is applied when files of
either name are opened in Atom:
https://github.com/atom/language-git/blob/v0.19.1/grammars/git%20commit%20message.cson#L4-L5
Because Hg historically used a generic `.txt` suffix, it was much harder to
disambiguate whether a file was an arbitrary text file as opposed to one
created for the specific purpose of authoring an Hg commit message.
This also makes it easier to add special support for `histedit`, as it has its own
suffix that is distinct from a commit:
`/tmp/hg-histedit-XXXXXX.histedit.hg.txt`
Test Plan:
Added an integration test: `test-editor-filename.t`.
Manually tested: ran `hg ci --amend` for this change and saw that it
used `/tmp/hg-editor-ZZjcz0.commit.hg.txt` as the path instead of
`/tmp/hg-editor-ZZjcz0.txt` as the path.
Verified `make tests` passes.
Differential Revision: https://phab.mercurial-scm.org/D464
Martin von Zweigbergk <martinvonz@google.com> [Wed, 30 Aug 2017 09:21:31 -0700] rev 34028
revlog: move check for wdir from changelog to revlog
Yuya said he preferred this (to keep them in one place, I think).
Differential Revision: https://phab.mercurial-scm.org/D569
Matt Harbison <matt_harbison@yahoo.com> [Tue, 29 Aug 2017 16:38:10 -0400] rev 34027
debugssl: allow a URL to be specified without a local repository
This was the original intent, but I bungled the logic. Otherwise if there is a
certificate chain issue, the repository can't be cloned in order for there to be
a repo object. I think I missed this case because I was inside of a Mercurial
clone as I was originally developing and testing this.
Augie Fackler <raf@durin42.com> [Tue, 22 Aug 2017 21:21:43 -0400] rev 34026
revlog: use pycompat.bytestr() to reliably have a %s-able value
Augie Fackler <raf@durin42.com> [Tue, 22 Aug 2017 23:11:35 -0400] rev 34025
debugcommands: stabilize output of debugbundle by having a custom repr
We handle all dict-like things the same, and don't worry about it
actually being a repr.
Augie Fackler <raf@durin42.com> [Tue, 22 Aug 2017 20:25:08 -0400] rev 34024
python3: whitelist another 5 passing tests found with the ratchet script
Augie Fackler <raf@durin42.com> [Tue, 22 Aug 2017 20:06:58 -0400] rev 34023
python3: replace sorted(<dict>.iterkeys()) with sorted(<dict>)
Augie Fackler <raf@durin42.com> [Tue, 22 Aug 2017 20:03:07 -0400] rev 34022
python3: wrap all uses of <exception>.strerror with strtolocal
Our string literals are bytes, and we mostly want to %-format a
strerror into a one of those literals, so this fixes a ton of issues.
Jun Wu <quark@fb.com> [Wed, 30 Aug 2017 14:04:55 -0700] rev 34021
pager: do not start pager if `ui` has been `pushbuffer`-ed
The `pushbuffer`, `popbuffer` APIs are intended to capture internal output.
They will prevent `ui.write` from writing to the actual `ui.fout`. So a
pager won't receive the output and do the right thing. In general, it does
not make sense to start a pager if ui is in the "pushbuffer" mode.
Differential Revision: https://phab.mercurial-scm.org/D574
Jun Wu <quark@fb.com> [Wed, 30 Aug 2017 16:05:12 -0700] rev 34020
revset: do not flip "and" arguments when optimizing
Rewrite `flipand(y, x)` to `andsmally(x, y)` so the AST order is unchanged,
which could be more friendly to developers.
Differential Revision: https://phab.mercurial-scm.org/D579
Yuya Nishihara <yuya@tcha.org> [Wed, 30 Aug 2017 22:51:28 +0900] rev 34019
revset: make match function follow given subset if specified (API)
This should be sensible default since mfunc(subset) is roughly equivalent
to 'subset & mfunc'. The order argument is still there so we can specify
'anyorder' if the order doesn't really matter.
Yuya Nishihara <yuya@tcha.org> [Wed, 30 Aug 2017 22:41:36 +0900] rev 34018
revset: move order argument to run-time match function
We no longer need the order flag to build a parsed tree.
Yuya Nishihara <yuya@tcha.org> [Wed, 30 Aug 2017 23:53:30 +0900] rev 34017
revset: fix example describing how ordering is determined
It was 'X & !Y' before.
Yuya Nishihara <yuya@tcha.org> [Wed, 30 Aug 2017 22:32:47 +0900] rev 34016
revset: move order constants from revsetlang
Thanks to the recent refactor, the ordering rule is fully processed at
runtime.
Denis Laxalde <denis@laxalde.org> [Tue, 29 Aug 2017 11:25:22 +0200] rev 34015
tag: use filtered repo when creating new tags (
issue5539)
When pruning a changeset that added a tag and then adding another tag, the
"pruned" tag gets restored. This is because the tag creation step (tags._tag()
call in tags.tag()) is currently done on the unfiltered repo. This behavior
has been there from
7977d35df13b which backs out
b08af8f0ac01 with no clear
reason but caution on unthought situations at that time. In this changeset, we
pass the filtered repo to tags._tag(), preventing "pruned" tags to reappear.
This somehow restores
b08af8f0ac01, though now we arguably have a valid use
case for.
Martin von Zweigbergk <martinvonz@google.com> [Mon, 21 Aug 2017 16:46:05 -0700] rev 34014
extensions: add wrappedfunction() context manager
Several extensions exist that temporarily want to wrap a function (at
least narrowhg, any many of the extensions in hg-experimental). That's
why we have the unwrapfunction() that was introduced in
19578bb84731
(extensions: add unwrapfunction to undo wrapfunction, 2016-08-10).
This patch adds a simple wrappedfunction() that returns a context
manager.
Differential Revision: https://phab.mercurial-scm.org/D472
David Soria Parra <davidsp@fb.com> [Tue, 29 Aug 2017 18:20:50 -0700] rev 34013
mdiff: add a --ignore-space-at-eol option
Add an option that only ignores whitespaces at EOL. The name of the option is
the same as Git.
.. feature::
Added `--ignore-space-at-eol` diff option to ignore whitespace differences
at line endings.
Differential Revision: https://phab.mercurial-scm.org/D422
Jun Wu <quark@fb.com> [Fri, 25 Aug 2017 11:20:34 -0700] rev 34012
revset: improve documentation about ordering handling
The old documentation is a bit confusing. Namely, it's unclear whether
`define` means "I should ALWAYS define a new order", or "I should SOMETIMES
define a new order", and if it's the latter, what's the difference between
`define` and `any`?
This patch clarifies that and adds more examples.
Differential Revision: https://phab.mercurial-scm.org/D523
Jun Wu <quark@fb.com> [Sun, 20 Aug 2017 10:55:11 -0700] rev 34011
revset: remove order information from tree (API)
Keeping `order` in tree makes AST operation harder. And there could be
invalid cases if trees could be generated and compounded freely, like:
SetA(order=define) & SetB(order=define)
^^^^^^ couldn't be satisfied
This patch changes the code to calculate order on the fly, during tree
traversal. Optimization of reordering `and` arguments is preserved by
introducing a new internal operation `flipand`.
.. api::
revset.stringset() now takes 'order' as the last argument.
Differential Revision: https://phab.mercurial-scm.org/D451
Jun Wu <quark@fb.com> [Mon, 28 Aug 2017 23:44:47 -0700] rev 34010
revset: drop optimization about reordering "or" set elements
The reordering optimization is more important for "and" than "or", given the
implementation details about "addset" and "filteredset" - reordering "or"
may help "__contains__" test but not iteration, reordering "and" could help
both. We are going to simplify the tree to remove ordering information.
Removing "or" reordering optimization would make things simpler.
This effectively reverts
c63cb2d10d6d. It tracks back to the "orset"
function added by the initial commit of revset (
c9ce8ecd6).
In the future, we might consider optimization at runtime (ex. do reordering
and rewrites inside "orset").
Differential Revision: https://phab.mercurial-scm.org/D561
Jun Wu <quark@fb.com> [Tue, 29 Aug 2017 17:51:54 -0700] rev 34009
rebase: use _ctxdesc in one more place
This simplifies the code.
Differential Revision: https://phab.mercurial-scm.org/D566
Jun Wu <quark@fb.com> [Sun, 27 Aug 2017 02:47:47 -0700] rev 34008
rebase: move working parent and bookmark for obsoleted revs (BC)
Previously, obsoleted revs with successors in destination are completely
ignored. That caused some inconvenience when working copy is obsoleted. Most
commands avoid working copy being obsoleted, but `hg pull` is an exception.
This patch makes rebase able to move bookmarks or working parent for those
obsoleted revs. It does so by keeping the obsoleted revs in `state` and
marking them as "skipped, rebased to desired destination" during run-time.
This reverts part of the behavior change of
3b7cb3d17137 and D24.
Differential Revision: https://phab.mercurial-scm.org/D527
Jun Wu <quark@fb.com> [Tue, 29 Aug 2017 17:49:13 -0700] rev 34007
rebase: remove an unnecessary adjustdest in clearrebased
`rev` being "skipped" could currently be caused by moving `rev` does not
create a new commit. In this case, `state[rev]` is already changed to `p1`,
and is a sane destination for bookmark or working parent movement. Therefore
an additional destination adjustment is unnecessary.
Differential Revision: https://phab.mercurial-scm.org/D565
Jun Wu <quark@fb.com> [Mon, 21 Aug 2017 20:22:07 -0700] rev 34006
rebase: sort destmap topologically
Previously rebase source and destination could not overlap. But with the
multi-destination support, source and destination could reasonably partially
overlap. That requires another topological sort on `{sourcerev: destrev}`
graph (destmap). This patch implements that.
If a revision's destination is itself, the error message gets changed from
"source is ancestor of destination" to "source and destination form a
cycle". Not marking as BC since automation should depend on exit code, not
error message.
Differential Revision: https://phab.mercurial-scm.org/D470
Jun Wu <quark@fb.com> [Tue, 29 Aug 2017 17:27:37 -0700] rev 34005
rebase: initial support for multiple destinations
This patch defines `SRC` (a single source revision) and `ALLSRC` (all source
revisions) to be valid names in `--dest` revset if `--src` or `--rev` is
used. So destination could be defined differently according to source
revisions. The names are capitalized to make it clear they are "dynamically
defined", distinguishable from normal revsets (Thanks Augie for the
suggestion).
This is useful, for example, `-r 'orphan()' -d 'calc-dest(SRC)'` to solve
instability, which seems to be a highly wanted feature.
The feature is not completed, namely if `-d` overlaps with `-r`, things
could go wrong. A later patch will handle that case.
The feature is also gated by `experimental.rebase.multidest` config option
which is default off.
Differential Revision: https://phab.mercurial-scm.org/D469
Jun Wu <quark@fb.com> [Fri, 11 Aug 2017 00:32:19 -0700] rev 34004
rebase: change internal format to support destination map
A later patch will add multiple destination support. This patch changes
internal state and the rebase state file format to support that. But the
external interface still only supports single destination.
A test was added to make sure rebase still supports legacy state file.
The new state file is incompatible with old clients. We had done similar
state file format change before: 5eac7ab, 92409f8, and 72412af. The state
file is transient, so the impact of incompatibility is limited. Besides,
the old client won't support multiple destinations anyway so it does not
really make sense to make the file format compatible with them.
Differential Revision: https://phab.mercurial-scm.org/D348
Jun Wu <quark@fb.com> [Fri, 11 Aug 2017 00:31:52 -0700] rev 34003
rebase: rewrite _computeobsoletenotrebased
The old code stores successors of all related nodes together, which works
fine if destination is unique. A future patch would make destination
non-unique so let's change the implementation to test successors for
rebaseset separately.
Differential Revision: https://phab.mercurial-scm.org/D347
Michael Bolin <mbolin@fb.com> [Tue, 22 Aug 2017 00:38:38 +0000] rev 34002
util: use ~ as a suffix for a temp file in the same directory as a source file
Tools like Buck have patterns to ignore the creation of files (in the working
copy) that match certain patterns:
https://github.com/facebook/buck/blob/
39278a4f0701c5239eae148968dc1ed4cc8661f7/src/com/facebook/buck/cli/Main.java#L259-L299
When Buck sees a new source file (as reported by Watchman), it has to invalidate
a number of caches associated with the directory that contains the file.
Using a standard suffix, such as `~`, would make it easier for Buck and others
to filter out these types of file creation events.
The other uses of `tempfile.mkstemp()` in Hg do not appear to be problematic
because they (generally speaking) do not specify the `dir` parameter, so the
new file is created in the system-appropriate temp directory, which is outside
the working copy.
Test Plan:
`make tests`
Differential Revision: https://phab.mercurial-scm.org/D468
Martin von Zweigbergk <martinvonz@google.com> [Mon, 28 Aug 2017 14:47:18 -0700] rev 34001
morestatus: simplify check for unresolved merge conflicts
Differential Revision: https://phab.mercurial-scm.org/D546
Martin von Zweigbergk <martinvonz@google.com> [Mon, 28 Aug 2017 15:06:34 -0700] rev 34000
tests: rename test-terse-status.t to test-status-terse.t
When looking for status tests, most people would probably look for
"test-status*", so it would be nice if they could find it there. This
also let's them run (most) status tests with "run-tests.py
test-status*".
Differential Revision: https://phab.mercurial-scm.org/D547
Jun Wu <quark@fb.com> [Mon, 28 Aug 2017 16:58:59 -0700] rev 33999
metadataonlyctx: don't crash when reusing the manifest with deletions
This was originally fixed by Mateusz Kwapich for the `metaedit` command in
fb-hgext with a test for the `metaedit` command. It didn't get upstreamed
because `metaedit` was not in core.
This patch fixes the crash and adds a test about `metadataonlyctx` to
avoid future regressions.
Differential Revision: https://phab.mercurial-scm.org/D550
Jun Wu <quark@fb.com> [Mon, 28 Aug 2017 16:49:41 -0700] rev 33998
context: make parents and text optional in metadataonlyctx
The metadataonlyctx is to copy an existing context with some minor metadata
changes. If the caller only wants to change "extra", or "user", ideally it
does not have to read and pass "parents" and "text" information.
This patch makes "parents" and "text" optionally to convenient callers.
Differential Revision: https://phab.mercurial-scm.org/D548
Boris Feld <boris.feld@octobus.net> [Thu, 17 Aug 2017 18:09:32 +0200] rev 33997
test: add more obsmarker tests for pruning scenarios
The obsfate output in cases of pruning is not ideal right now, add some tests
so have these scenarios around.