Summary:
This could avoid issues where there are references to new trees. Trees
are written, but those references haven't been written to disk.
As we're here, also add `ui.log` to log what files are removed.
Reviewed By: markbt
Differential Revision: D8940827
fbshipit-source-id: fbe59a5d87b302c7074f618cbbae56fb1f3d4ff4
Summary: debugcolor does not need to be a repo-command.
Reviewed By: singhsrb
Differential Revision: D8944518
fbshipit-source-id: e00144dbe3dee5d1cd45d1c613e33999aa1aaaed
Summary:
The walkconfig hack was to copy the overridden configs (side effect of uisetup,
CLI flags) to new uis. Since we no longer have overridden configs, it's no
longer necessary.
Reviewed By: singhsrb
Differential Revision: D8960878
fbshipit-source-id: c7a2ad8513380c64ee4e4639016aafaa57b9d9ba
Summary: make ux better when waiting for background cloud sync to complete by showing progress bar
Reviewed By: quark-zju
Differential Revision: D8735116
fbshipit-source-id: 94659422a6fb16e540964c8b5f3316b1bb0a837f
Summary:
Merge drivers can raise exceptions. If they do, we need to restart the rebase without IMM in case they might work without IMM.
Before, we just exited out of merge.update with a positive "unresolved" count. This change raises a proper exception so we don't hit the fallback in D8886238, and have access to the failed files. It also rewrites some logic that was murky.
I think a better approach overall might be to not have driver raise exceptions, and cancel the rebase in that case or otherwise treat that case more harshly. We'd need to change existing drivers in that case. Or we can just handle this case more explicitly by adding a new `type` to `InMemoryMergeConflictsError`.
---
Note that because of the nice fallback in D8886238, all this does is change the line:
```
hit merge conflicts (in 1 file); switching to on-disk merge
```
to
```
hit merge conflicts (in FILE); switching to on-disk merge
```
but it's important to have explicit flow control so we can make future changes with confidence.
---
Reviewed By: quark-zju
Differential Revision: D8886237
fbshipit-source-id: 4e10e960f7a8d8f37de177d0596d2f3da16be4d9
Summary:
The test reveals some copy handling issues in treestate:
- copyfile can be called to override a previous copyfile source information.
- drop or remove file should reset the file's copy information.
I hope we'll clean up dirstate. The main problem of it is the "setparents" API,
it changes the parents directly, leaving it to the caller to make sure the rest
of the dirstate is in sync with repo and filesystem state. And it's super
unclear what the callers are supposed to do exactly in these cases. Ideally
there is no "setparents" API on dirstate or the repo object. The low-level
building blocks (merge or clean update) would make sure the tree is in a
consistent state and nobody else (esp. rebase) can ever change dirstate parents
directly.
Reviewed By: DurhamG
Differential Revision: D8869842
fbshipit-source-id: b7882dfe60508fa6bbcfb99e30e507dc297a1d83
Summary:
The test reveals some ordering issue with clone failure handling.
`destrepo.close()` could have side effects writing files. So let's do that
before removing the destination repo.
Reviewed By: DurhamG
Differential Revision: D8869843
fbshipit-source-id: 4cf97038dd4545a59dcee3d86bb114efd5794e62
Summary:
This test exposes an issue that treestate raises when it fails to create an
empty tree because I/O errors. In that case, just use a dummy read-only empty
tree so certain workflows could continue to work.
Reviewed By: DurhamG
Differential Revision: D8869839
fbshipit-source-id: 6ff1f78139855d583e915670adfeb6dcfb50a8f8
Summary:
This test exposes an issue that treestate does not respect HGPENDING. That
was fixed and the test is switched to run with treestate.
Reviewed By: DurhamG
Differential Revision: D8869844
fbshipit-source-id: 99583e68ccbabbe1ed8395012bf280fd5a7e98c3
Summary:
The test change is because internal details. In this case, set "mtime" to -1
is more "correct" than "0" (the fixed 1970 date).
As we're here, make treestate to normalize size and mtime at "remove" time.
This is similar to D8842389 which only affects internal representation, without
visible changes affecting users.
Reviewed By: DurhamG
Differential Revision: D8869841
fbshipit-source-id: 52fce7a230f87dbb41217f4fd2305ff2febe1fdb
Summary:
For treestate+fsmonitor case, `dirstate._map.get(path)[0]` could be `?`.
It's a new condition that the pathconflict code path didn't expect. So let's
update pathconflict checker to work with treestate+fsmonitor.
Reviewed By: DurhamG
Differential Revision: D8842393
fbshipit-source-id: 4679e23f37310bea18c34676231baa4854de1611
Summary:
There are some minor differences on deubgdirstate output:
```
$ hg debugdirstate --nodates
- r 0 0 * bar (glob)
+ r 644 0 set bar
n 0 -1 * foo (glob)
```
For "removed" files, the mode does not really matter. But let's change
treestate to set mode to 0 if a file gets removed.
Reviewed By: DurhamG
Differential Revision: D8842389
fbshipit-source-id: 634ac2ffcb2331f4bd4f6723f4eec393133aaa08
Summary: The test reveals a typo in treestate Python layer. Fix it and enable the test.
Reviewed By: DurhamG
Differential Revision: D8869840
fbshipit-source-id: 94477e31b13b80561714edfdf46adc0b764743a9
Summary:
If pushrebase.enablerecording and the rest of the parameters are set then let's
save pushrebase requests. It involves saving the changegroup and treemanifest
bundles2 parts to bundlestore, and then inserting an entry into the database
Reviewed By: quark-zju
Differential Revision: D8801602
fbshipit-source-id: bea4f798daa8542541c8d7c4c2a051c8583930a0
Summary:
Denley Bihari found a weird case where hg debugcolor reports "brightdark" is
both unknown and printed out:
% hg debugcolor
ignoring unknown color/effect 'brightblack' (configured in ...)
color mode: terminfo
available colors:
....
brightblack
Looking at the code, "terminfo" has its own weirdness, and is not used in
"auto" mode. I guess nobody really knows how "terminfo" mode should behave
correctly given terminal weirdness, and "terminfo" itself might be
incorrect.
So let's just focus on the default mode (ansi) behavior on modern systems
and drop support for the terminfo mode that no one really understands.
Reviewed By: phillco
Differential Revision: D8809676
fbshipit-source-id: fb330bfa713f5e249b865d6a4202cf4801f96988
Summary:
It's handy. Mercurial's json serialization is different from the stdlib json
module since it can round-trip binary content. stdlib json cannot be
reliably used when there are content involving paths.
Reviewed By: ryanmce
Differential Revision: D8392078
fbshipit-source-id: 423bd5c68ea317605991a20b30ae870291249d1c
Summary:
For chg's usecase, it'd be nice to learn the actual arguments being
executed. So let's just change `pycompact.sysargv`.
An alternative would be assigning it to `ui.argv`. Given the current
codebase is using `pycompact.sysargv` in multiple places. It seems easier to
just change it.
Reviewed By: ryanmce
Differential Revision: D8392081
fbshipit-source-id: e327e04e556ea00e7b62a68b1c62c834ce927293
Summary: This is useful to split dev_command_timer rows based on how many files were rebuilt.
Reviewed By: DurhamG, singhsrb
Differential Revision: D8737307
fbshipit-source-id: 18d52c0fd13184d789daaa8a74f85360554da703
Summary: It seems to work well. Let's turn it on by default.
Reviewed By: singhsrb
Differential Revision: D8744808
fbshipit-source-id: 61a8b8750f53d91ae94d019a88f27697309cfd66
Summary:
Previous code format attempt (D8173629) didn't cover all files due to `**/*.py`
was not expanded recursively by bash. That makes certain changes larger than
they should be (ex. D8675439). Now use zsh's `**/*.py` to format them.
Also fix Python syntax so black can run on more files, and all lint issues.
Reviewed By: phillco
Differential Revision: D8696912
fbshipit-source-id: 95f07aa0c5eb1b63947b0f77f534957f4ab65364
Summary:
This speeds up the matcher against several prefixes, helps commands
like `hg files subdir`.
Reviewed By: phillco
Differential Revision: D8721759
fbshipit-source-id: 8b1b35abc5bde7d3265c0874796808a39eb8810f
Summary:
This adds `repo.dirstate._map.keys(prefix=prefix)` API that returns tracked
files for a subdirectory quickly. If `prefix` ends up with `/`, it selects
the subdirectory and all files in it recursively. Otherwise it's an exact
match of a single file.
Reviewed By: phillco
Differential Revision: D8721758
fbshipit-source-id: 200def986e08fd3b9842b6c8012cb7f8350f0822
Summary:
Hg's `pad()` template function can only fill with a single character. To assert this, Hg checks the length of the fill string. Because the fill string is a Python 2 `str`, Hg rejects UTF-8 `'☃'` (`'\xe2\x98\x83'`) because its length is 3.
Instead of checking the length of the fill string, check the width of the fill string while taking encoding into account. This lets us use ☃ as a pad fill character.
For ASCII fill strings in `pad()`, this diff should not change behaviour.
Reviewed By: phillco
Differential Revision: D8730727
fbshipit-source-id: ad015aa4cae274160bc2726e0cb5e570e6edcc1e
Summary: `hg debugfs` can report `apfs` correctly on latest mac. So let's add it to whitelist.
Reviewed By: ikostia
Differential Revision: D8725764
fbshipit-source-id: a9eb0db9d1f75cdd64c28b5c2f41451955758e18
Summary:
This is a more minimal fix compared to D8676355, to handle extra calls to `markcopied` from `copies.duplicatecopies`.
Let's just make overlayworkingcontext properly support receiving copy information on (non-deleted) files, which it should do anyway.
This leaves the incorrect non-IMM behavior, but since it just involves incorrectly creating an empty commit, that's probably fine.
Reviewed By: quark-zju
Differential Revision: D8697039
fbshipit-source-id: 0c204c47e6b5031eb20928c1844be3aebcb96edb
Summary:
I was thinking about what we need to enable automatic restacking on non-conflicting amends (see the next diff), but I realized the --tool :abort tool I implemented in D8493065 doesn't really work well for this for three reasons:
- It can't handle the case of mergedriver having to run, which is the other reason we'd have to break out of IMM.
- It hard-codes the merge tool. The user might want to specify another tool that doesn't recreate conflicts or solves them differently.
- It'd force callers to detect if IMM will be used (to prevent an on-disk merge hapening by mistake). A flag can implement this much more easily.
- As I learned when writing D8493065, it would require hardcoded logic in every command anyway to support the non-IMM case. (Just raising an abort will leave most commands with an interrupted state.)
So, I think we should replace it with this flag to make auto-restacking work very reliably (we could add it to graft, too). If there was some big demand for --tool :abort we could always add it back in the future.
Reviewed By: quark-zju
Differential Revision: D8701897
fbshipit-source-id: ea3b92d0a224a8ce43edb120b53bec241d92a61d
Summary: This will let us print more helpful/precise error messages.
Reviewed By: singhsrb
Differential Revision: D8699551
fbshipit-source-id: 060058eff925d94ffa8e6b4432c4e51bd93b2945
Summary: This config was needed when IMM restarts were long and painful, but now that they're not, this clunky and inaccurate hueristic can be removed, which simplifies the control flow a bit.
Reviewed By: singhsrb
Differential Revision: D8700868
fbshipit-source-id: 0aeac26e5c41f7f0260ee826f05a8f9047dbad5a
Summary:
A future diff will make us depend on repo.close() being called to
finalize the writing of some tree data. It turns out we didn't call close on the
destination repo during a clone, which caused some tests to change. Let's call
close on that repo to prevent a test change in the next diff.
Reviewed By: phillco
Differential Revision: D8670680
fbshipit-source-id: ad63ccfc51ec4c3de2dad494fdb1ae8f6ba8e40a
Summary:
Previously we were encoding the full filepath into a single filename to
use as a backup file. If the full path was over 255 characters, then we couldn't
create a file with the name.
Since the user never sees this name unless they run --debug, let's just get rid
of the encoded name and use a purely temporary name.
Reviewed By: farnz
Differential Revision: D8695749
fbshipit-source-id: 18b6d00e5f4c856b7dd6073e9d8c9677c4baea69
Summary:
Previously, drawdag can only create commits which add or modify files.
In some cases, removing files is needed. This diff makes it support removing
files by special comments like "(removed)" and "(renamed from ...)".
Reviewed By: phillco
Differential Revision: D8698324
fbshipit-source-id: 97da946332fe64275cef40ba9ba6ac60846d7de9
Summary: We initially split out lots of different causes of slowness into their own unique tags, so that we could identify the source of slowness. Now that we've identified all the big causes, wrap them all back up into summary categories - we can change back to detailed tags at callsites if we want to separate out phases.
Reviewed By: ikostia
Differential Revision: D8664314
fbshipit-source-id: 6e141382479ca044847db1611f885e08f24f986b
Summary:
This code is no longer needed now that the buck built binary uses the same
entry point as the setup.py built code.
Reviewed By: quark-zju
Differential Revision: D8675727
fbshipit-source-id: 1b3a44371453aa16c530f73b48611958082ee080
Summary:
Update the buck build to use the "hg" script as its main module, rather than
using its own custom mercurial/main.py file.
This also changes how the extensions code decides whether to perform strict
checks or not. Previously this was disabled for buck builds by checking the
entrypoint argument. Now that buck builds use the same main module the
entrypoint is the same. Therefore we now distinguish buck-based builds based
on the presence of the `__manifest__` module.
Reviewed By: ryanmce
Differential Revision: D8601651
fbshipit-source-id: abfea4c6d91596149c240baa1bead740dffe8750
Summary:
The scenario we are handling is as follows:
1. the user runs a long-running Mercurial command with a lot of output, like
`hg log`
2. Mercurial runs pager, which is a subprocess, like `less` and changes its
stdout/stderr to point to pager's stdin.
3. The user exits from the pager (by pressing `q`, for example)
4. The pipe connecting Mercurial stdout/stderr with pager's stdin is now dead.
5. Mercurial tries to write something into its stdout, a failure occurs
6. The finally section restores stdout/stderr to be a tty
7. A failure gets caught up in the stack and printed to stderr, now a tty
A failure is vague here. On Linux, it means a `SIGPIPE`, on Windows, just and
exception that is manifested in Python as `IOError` with `errno=EINVAL`.
This is how Linux deals with it:
1. registed a signal handler for `SIGPIPE`, make this handler raise a
Mercurial-defined `error.SingalInterrupt`, which is a child exception class to
`KerboardInterrupt`
2. catch `KeyboardInterrupt` in `dispatch.dispatch`, handle the broken pipe
case there
For Windows this does not work, since there's no `SIGPIPE`, so
`SignalInterrupt` never gets raised, so we never handle the `IOError`.
This diff just explicitly handles the `IOError` in `dispatch.dispatch` and
silently consumes the `errno.EINVAL` case.
Reviewed By: quark-zju
Differential Revision: D8610555
fbshipit-source-id: 6cadba6a9ec296f03b1b616b763e56ec55da3a70
Summary:
Add a config option `fsmonitor.detectrace` and environment variable
`HGDETECTRACE`. Once set, perform an additional query to check if there are
writes to the working copy while `wctx._buildstatus()` is being calculated.
Also enable the race detector for all fsmonitor tests.
Reviewed By: wez
Differential Revision: D8597957
fbshipit-source-id: 5d83d529641325dc8d5e72ad059eed8db27d1f2a
Summary:
2f205fdc948fbea made remote stderr get written to local stderr, but
didn't catch this spot where when a connection closes we read the remainder of
stderr and write it out.
Reviewed By: quark-zju
Differential Revision: D8627272
fbshipit-source-id: c846ac6bb7425114fb29c6374c74b35057c14e63
Summary:
Fix the `_collectimport()` code to more accurately figure out module paths.
When used from a statement like `import foo.bar` the `__import__()` function
returns the `foo` module. However, if used like `from foo.bar import baz` it
returns the `foo.bar` module. The `_collectimport()` code did not expect this
behavior and assumed that it always returned `foo`. This resulted in it doing
the wrong thing when trying to resolve nested imports.
In most cases it would just fail with an attribute error and it would then
swallow this exceptions. However in some cases it was able to find a
non-module object. For instance, when processing the `mercurial.extensions`
module it would find the `extensions()` function inside this module. Calling
`inspect.getabsfile()` on this function doesn't always produce the correct
result. If loaded from a pre-compiled .pyc file the function may have a
relative path baked in as its function name. The `inspect.getabsfile()` code
then simply prepends this with the current working directory, despite the fact
that this wasn't actually imported from the current directory.
I also changed the code to use inspect.getfile() rather than
inspect.getabsfile(). The getabsfile() function attempts to do other
normalization and string manipulation that we don't need. (It tries to find
`*.py` names rather than `*.pyc` or `*.pyo` names, and it normalizes case.)
Reviewed By: ryanmce, quark-zju
Differential Revision: D8601652
fbshipit-source-id: db9be3c5cbbea83a880851036093aaa28b5b9b19
Summary:
`size = -1` does not have special meaning in dirstate. Only `size = -2` is
special.
Reviewed By: DurhamG
Differential Revision: D8623318
fbshipit-source-id: 7293a7b492ba44cb8ffc49ce54a908e9612148e2
Summary:
The previous version of this tool raised on all merges, even non-conflicting ones.
We need to attempt a three-way merge first, _then_ raise an exception if it produces conflicts.
Reviewed By: DurhamG
Differential Revision: D8607184
fbshipit-source-id: 3f208caf54fa1ace28e1ee9011b34f5ec7bacec4
Summary:
For treestate, `copies` is more expensive as it's not a cache but calculates
from the source of truth. So avoid using `copies` but read the copy
information directly from the tree.
Reviewed By: DurhamG
Differential Revision: D8595357
fbshipit-source-id: bcea254358d66c9fa9f933d73221bbeb0bd8d5b2
Summary:
Some scripts are parsing all hg outputs. The remote stderr output could
contain random noise that break the scripts. Therefore let's forward
remote stderr to local stderr, instead of local stdout.
Reviewed By: DurhamG
Differential Revision: D8514952
fbshipit-source-id: 2f205fdc948fbeacd20b5af9d6d52eaa8212e90e
Summary: This will allow us to trigger hints from functions that wrap runcommand itself.
Reviewed By: quark-zju
Differential Revision: D8591974
fbshipit-source-id: e8e4742d6728ca347b85d10adc2e2ab7ab06ef16
Summary:
Using `wdir()` in dagrange expressions (e.g. `master::wdir()`) causes Mercurial
to crash with `IndexError: head out of range`. This is because the dagrange
operations can't use the wdir rev number as it is out of range for the
changelog.
Instead, modify the revisions that we are passing in to calculate the matching
revs, and add the wdirrev at the last moment if appropriate.
Reviewed By: ryanmce
Differential Revision: D8592129
fbshipit-source-id: 8742cb72c22d1ba26f5d03f9fcf56bfdb785c25a
Summary:
Revset predicates that work substantially through `subset.filter` should have a
higher weight than the default value of 1, to prevent the optimizer incorrectly
optimizing operations like:
```
reverse(ancestors(node, limit)) & filterpredicate()
```
in a way that filters all the revisions in the repo according the predicate
before performing the dag search.
Reviewed By: ikostia
Differential Revision: D8588027
fbshipit-source-id: 57be642761af013be8c8aa27ec126b3919c34256
Summary:
The `public()` revsetpredicate has the default weight of 1, which means
expressions like `::x & public()` are optimized to `('andsmally', ::x, public())`,
which will actually result in iterating over all commits in the repo.
Increase the weight to 3 to ensure it's optimized in a way that favours
following ancestry links and then checking the phase.
Reviewed By: ikostia
Differential Revision: D8549645
fbshipit-source-id: f58750ecb1918079b7e350ce27b7a61771489233
Summary:
Upstream Mercurial renamed peer.cleanup to peer._cleanup last August,
but our connectionpool logic wasn't updated. This meant that expired connections
were left alive and just hanging there until the process died. This defeated the
entire purpose of expiring connections (to free memory on the server).
Reviewed By: singhsrb
Differential Revision: D8583327
fbshipit-source-id: 561b6ed8b76247d996051b0536c5f58050fb83a2
Summary:
This avoids potential issues when `fork()` inheriting the socket fd could
cause unresponsive servers.
Reviewed By: simpkins
Differential Revision: D8384547
fbshipit-source-id: 91aeb76f4a7b526a39bbbf846a9e5c0546348f6c
Summary:
Analogous to `localrepo._wlockfreeprefix`, this is the prefix of files in the
store that can be safely accessed without the store lock.
Reviewed By: mitrandir77
Differential Revision: D8480907
fbshipit-source-id: 6d6c625c7f2230384ee361ff6b585f42feea6d10