Commit Graph

64 Commits

Author SHA1 Message Date
Durham Goode
a0fdd80720 dirstate: rename drop to untrack
Summary:
dirstate.drop() is used in two different situations. 1. To make a
tracked file become untracked, and 2. To remove a file from the dirstate
entirely. In the treestate case, this difference matters, so let's split drop
into two functions, one to mark something as untracked, and the other to remove
it entirely.

In this first patch we just rename drop to untrack. The next patch will
introduce the new delete function.

Reviewed By: ikostia

Differential Revision: D10317738

fbshipit-source-id: 85950ab1b1a10cd481edcfbba6da445b3dbf6397
2018-10-12 09:38:25 -07:00
Jun Wu
4f1f17133d sparse: do not ignore root directory ""
Summary: `repo.dirstate._ignore("")` should return False.

Reviewed By: DurhamG

Differential Revision: D10316447

fbshipit-source-id: df0ee2c5474784532280b7031623c135a784a196
2018-10-10 16:42:41 -07:00
Mark Thomas
06a462bb89 fbsparse: add switchprofile command
Summary:
Add the `sparse switchprofile` command, which lets users specify a set of
sparse profiles they would like to switch to.  This is equivalent to `hg sparse
reset` followed by `hg sparse enableprofile`, but in a single step.

Reviewed By: farnz

Differential Revision: D10141938

fbshipit-source-id: 5a1e547d21e3246237fffb17f3b512da18fac804
2018-10-02 03:35:49 -07:00
Mark Thomas
463cc8f299 hgext: use repo.localvfs instead of repo.vfs
Summary:
Update most locations in the hg extensions to use `repo.localvfs` instead of
`repo.vfs`.

Reviewed By: quark-zju

Differential Revision: D9699153

fbshipit-source-id: 48d5f9678caa4961063db30477d6fbe0d6f34347
2018-09-28 07:23:01 -07:00
Jun Wu
7ca13cb470 sparse: add a progress bar applying sparse matcher
Summary: This step could take a long time. Therefore add a progress bar.

Reviewed By: DurhamG

Differential Revision: D9375200

fbshipit-source-id: f7eb3d3bb750b873df90eb950098a743e24c6440
2018-08-17 11:38:27 -07:00
Jun Wu
01fc38d9d4 sparse: do not load dirstate in reposetup
Summary:
While investigating T30931730, I wondered why Eden importer needs to access
dirstate. Turned out the sparse extension would construct it in `reposetup`.
Changing that to a cheaper test - `repo.local()` to avoid loading dirstate.
A local repo always has a dirstate.

Reviewed By: simpkins

Differential Revision: D8669930

fbshipit-source-id: b738f7d888fe8ad62c9a29bd910230f62278a7af
2018-07-17 14:50:24 -07:00
Jun Wu
bb9e6e0a18 fbsparse: avoid cyclic reference in reposetup
Summary: When wrapping the repo object, use local variable if possible.

Reviewed By: chadaustin

Differential Revision: D8676284

fbshipit-source-id: d35d9b7b9357a8e16d4eb10032911ecbdc34b907
2018-06-28 14:20:41 -07:00
Wez Furlong
07a4e11545 improve sparse extension error handling when used with eden
Summary:
Some folks might attempt to load this extension despite it
not being useful with eden.  The extension knows not to hook in to
the repo when eden is in used, but the various commands to manipulate
the sparse config do not.

This diff adds a little helper function to show a more reasonable
error message than an ugly stack trace when attempting to use them.

Reviewed By: simpkins

Differential Revision: D8328229

fbshipit-source-id: d7cc4c7047b11f8da96e26ab70bd522b52546151
2018-06-08 14:51:54 -07:00
Lukasz Langa
dfda82e492 Upgrade to 18.5b1
Summary: Mostly empty lines removed and added.  A few bugfixes on excessive line splitting.

Reviewed By: quark-zju

Differential Revision: D8199128

fbshipit-source-id: 90c1616061bfd7cfbba0b75f03f89683340374d5
2018-05-30 02:23:58 -07:00
Jun Wu
584656dff3 codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).

Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.

Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.

An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.

As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.

Reviewed By: wez, phillco, simpkins, pkaush, singhsrb

Differential Revision: D8173629

fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-25 22:17:29 -07:00
Martijn Pieters
59b960eade sparse: filter on file containment
Summary: This lets you find profiles that'll include a given filename.

Reviewed By: markbt

Differential Revision: D7876496

fbshipit-source-id: 3b375e5d8257a80853f854a6be27c74f805687e3
2018-05-04 07:31:06 -07:00
Mark Thomas
7da35d4f22 fbsparse: use new subcommand infra
Summary:
Replace the monkey-patched subcommands in fbsparse with the new subcommand
infra.

Reviewed By: mjpieters

Differential Revision: D7849195

fbshipit-source-id: 7f1fc21f555dc2bea49d3a80efdbfd42a6e70cb5
2018-05-03 04:35:46 -07:00
Mark Thomas
0aab0bd5dd commands: allow commands to have subcommands
Summary:
Add generalised support for subcommands.  This is similar to the monkey-patched
version in `fbsparse`, but fully supported by the command infrastructure.

Subcommands are the same structure as normal commands, but are attached to a
table in the `subcommands` attribute of the main command.  Normally, if no
subcommand is provided, the normal command function is called.  This can be
made into an error by setting `subonly` on the top-level command.

In order to make `fbsparse` continue to work, I've temporarily hacked how it
handles help text.  This will be fixed in a later diff that switches fbsparse
to use this infrastructure.

Reviewed By: mjpieters

Differential Revision: D7849476

fbshipit-source-id: b988edabb17da77bf91a278e0faa2feecd0c1db9
2018-05-03 04:35:46 -07:00
Jun Wu
841114e210 sparse: skip checking files outside sparse for absorb's case
Summary:
The logic was added by D2594568 and is intentional for "repairing" dirstate.
It's O(working copy). That makes absorb super slow. Therefore let's use the
new "exact" flag to skip the slow path.

Reviewed By: mitrandir77

Differential Revision: D7818728

fbshipit-source-id: a3a7d6074bd0240b9e1919e18d3e0b95daf74a64
2018-05-02 17:16:01 -07:00
Jun Wu
1b475a874d dirstate: add an "exact" parameter to "rebuild"
Summary: This is a hint for performing certain fast paths.

Reviewed By: mitrandir77

Differential Revision: D7818730

fbshipit-source-id: 4adcf8724b462d8d652e8e580d6a36eebc46a0f8
2018-05-02 17:15:40 -07:00
Jun Wu
3368506521 tests: fix test-check-code.t
Summary:
There is a proper way [1] to skip the dict check-code check. Let's use it.

[1]: a61ed1c2d7

Reviewed By: DurhamG

Differential Revision: D7831336

fbshipit-source-id: a5e654e9e94cbfb1c5a07b047eb6e5451904c48e
2018-05-01 14:17:43 -07:00
Martijn Pieters
a9f4167218 sparse: add filtering on field contents
Summary: This lets you select on substrings in fields and paths.

Reviewed By: quark-zju

Differential Revision: D7788826

fbshipit-source-id: f92b8cc646fd36f4cb3b8a4dc6116576db80eb42
2018-04-30 14:16:44 -07:00
Martijn Pieters
796523487a sparse: add a hint about using --verbose on hg sparse list
Summary: Calculation on how many profiles were hidden is only done when the hint is actually shown.

Reviewed By: quark-zju

Differential Revision: D7774192

fbshipit-source-id: a7196b2cc5640d0a7cb9c4d572e1a31ebfa41598
2018-04-30 14:16:44 -07:00
Martijn Pieters
2c10ce3145 sparse: add filtering options for fields present or missing
Summary:
This lets us produce a list of profiles with the title set, or find all profiles that are missing a description.

Convert the 'hidden' filter to use this feature, rather than special-case it in `_discover()`.

Reviewed By: quark-zju

Differential Revision: D7774029

fbshipit-source-id: 3bcba75e6da97bf0e560e11ce1ae7cbcee49ee45
2018-04-30 14:16:44 -07:00
Jun Wu
e21cf00d2e sparse: move some documentation to extension-level
Summary:
check-seclevel.py complains about using section markers inside a container.
The help text about sparse file format and config options can be put at
extension-level.

Reviewed By: mjpieters

Differential Revision: D7776355

fbshipit-source-id: 0b7d813c5eee352a054b21897682f6064f384829
2018-04-27 23:40:00 -07:00
Martijn Pieters
ed857415c5 sparse: allow listing of profiles at a different revision
Summary: This is needed to be able to list profiles via SCMQuery, where there is a working copy at the null revision.

Reviewed By: quark-zju

Differential Revision: D7745434

fbshipit-source-id: b5ac236c36f9bafc9e0f305bc0892e0cd8bec628
2018-04-25 08:50:27 -07:00
Martijn Pieters
51dae5969e sparse: ignore non-existing profiles when listing
Summary: If there is a non-existing sparse profile active in .hg/sparse, skip it rather than bail out.

Reviewed By: quark-zju

Differential Revision: D7744957

fbshipit-source-id: 4e6a046c95f5fe6cf49a7093d3443340f70e8e2a
2018-04-24 10:21:22 -07:00
Adam Simpkins
05edd145db ensure that fbsparse never wraps Eden repositories
Summary:
Update `fbsparse.reposetup()` to avoid attempting to wrap the localrepo object
in Eden repositories.  The fbsparse extension is normally disabled in Eden
repositories, but this ensures the code does the correct thing even if the
fbsparse extension has been explicitly loaded.

Reviewed By: ryanmce

Differential Revision: D7642679

fbshipit-source-id: d0a229091d794fb326ab1db1c01e5a0a271092c4
2018-04-18 12:18:01 -07:00
Adam Simpkins
36de34b8f2 do not allow hg sparse to execute in non-sparse repositories
Summary:
Update the sparse command to fail early if the repository in question is not a
sparse repository.

Reviewed By: ryanmce

Differential Revision: D7642680

fbshipit-source-id: eaf765d38b45acf17d7c755f95083371f43f7259
2018-04-18 12:18:01 -07:00
Martijn Pieters
f07e9c14b6 fbsparse: add hint to sparse explain about the verbose flag
Summary:
```
$ hg sparse explain some/profile
[...]
hint[sparse-explain-verbose]: use 'hg sparse explain --verbose some/profile' to include the total file size for a give profile
hint[hint-ack]: use 'hg hint --ack sparse-explain-verbose' to silence these hints
```

Differential Revision: D7669896

fbshipit-source-id: c700fbc2f42044a9b15371278305f03e9e6c989f
2018-04-18 10:38:35 -07:00
Martijn Pieters
0b9356d3f2 sparse: update all subcommands with proper arguments / synopsis info
Summary: Tweak the help output to reflect the now-complete subcommand information.

Differential Revision: D7667900

fbshipit-source-id: a5a04e8bcbfe4a90266c30e25ffd705de0bdc8a9
2018-04-18 10:38:35 -07:00
Martijn Pieters
c05fc0e620 sparse: fix bug with prefetching
Summary: The attribute is called 'hex', not 'hash'. Oops.

Reviewed By: markbt

Differential Revision: D7600689

fbshipit-source-id: 027031000e6481f353ceaad79c7dc2c46a16a3cf
2018-04-17 08:27:00 -07:00
Martijn Pieters
b31ce422e2 sparse: provide sensible __repr__ strings for the custom matchers.
Summary: These matchers provide better values than the default now provided by mercurial.match.basematcher.

Reviewed By: quark-zju

Differential Revision: D7635868

fbshipit-source-id: c826390b3a5e3a2da897eeb54be22850e14403f6
2018-04-16 12:53:41 -07:00
Martijn Pieters
3f7758625a sparse: Add support for specifying a revision to sparse explain
Summary: We need this to support producing sparse profile stats in a null-revision working copy.

Reviewed By: quark-zju

Differential Revision: D7553022

fbshipit-source-id: b1643f443de5a748bf81ff2df16ace984d59a2c2
2018-04-13 21:51:50 -07:00
Martijn Pieters
6e097ff6cd sparse: add support for per-subcommand switches
Summary: A followup diff will add more in the way of testing; this is easier with an actual usecase.

Reviewed By: quark-zju

Differential Revision: D7553020

fbshipit-source-id: a6e8b86154d802f8cdbc846f5ea14fa809ac5264
2018-04-13 21:51:50 -07:00
Martijn Pieters
440232e553 sparse: fix the accidental recursive handling of profiles
Summary:
hg sparse explain wasn't supposed to recurse, not without additional support.

It was the process of gathering stats that overwrote shared mutable structures.
Prevent this from happening again by making these structures immutable.

Differential Revision: D7516570

fbshipit-source-id: 247c60b4bd8d2d22b42c41871e1eb15988820025
2018-04-13 21:51:50 -07:00
Martijn Pieters
62ec76397b sparse: fix broken signature calculation for sparse profiles
Summary:
We were ignoring the actual profile data, and all profiles were given the same .hg/sparse-based hash signature instead.

Error introduced in D7415720

Differential Revision: D7514087

fbshipit-source-id: 56288aaaa2065b031318e7c065ec6310f6cecd37
2018-04-13 21:51:50 -07:00
Martijn Pieters
0aa55642b8 hg: make sure len(manifest) always raises TypeError
Summary:
`len()` on a hybrid manifest wrapping a treemanifest would raise an attribute error. But if there is no treemanifest or there is *only* a treemanifest, then a TypeError is raised. Using `len()` on an object that doesn't support length should always raise `TypeError`, consistently.

Instead of looking up the `__len__` attribute, use the built-in `len()` function, which will raise `TypeError` if the wrapped manifest in a hybrid doesn't have a `__len__` method. This ensures that we get a consistent exception.

Reviewed By: farnz

Differential Revision: D7485510

fbshipit-source-id: 4132d6b383171cde8dd99dd60098716d4aedc527
2018-04-13 21:51:45 -07:00
Martijn Pieters
bf9eb9018e sparse: add the option to hide certain profiles
Summary:
Some profiles are not for general consumption; they are usually profiles aimed at CI subsystems or similar. These can be hidden from listings by default using a `hidden` key.

The value of the key doesn't matter but can be used to explain why it is hidden.

Reviewed By: quark-zju

Differential Revision: D7433781

fbshipit-source-id: 877cd8698d50dc64cec8da706ab005e1fd786de4
2018-04-13 21:51:39 -07:00
Martijn Pieters
b9cca4a62b sparse: rework help information
Summary:
The hg sparse help page was overwhelming, and out of date. With subcommands, we
can break up the information a bit more.

* Subcommand help is the place for details on that command. Reduce the main
  help info to an overview.
* Move configuration switches to a `verbose` container to hide it by default.
* Add documentation on the sparse profile format.
* Mark the command-line switches with subcommands as deprecated so they are
  hidden by default.

Reviewed By: quark-zju

Differential Revision: D7432862

fbshipit-source-id: ffddd27e0ee4216f7e743e63e8efaed4eeaac582
2018-04-13 21:51:38 -07:00
Martijn Pieters
a4952f4bfa sparse: add a hg sparse files command
Summary: This command mostly echoes how `hg files` works, albeit simplified somewhat. Given a profile and optional patterns, the files that profile matches are listed.

Reviewed By: quark-zju

Differential Revision: D7431522

fbshipit-source-id: 8e9d1f0d2aa31335f53269f3005875a0cc2e65bf
2018-04-13 21:51:38 -07:00
Martijn Pieters
4c93c15316 sparse: include sparse profile impact
Summary:
Show the 'impact' of a profile, relative to a non-sparse working copy.

By default, this is the percentage of the total file count; adding --verbose will show the file sizes too.

The defined matchers have been refactored to reuse more of mercurial.match.basematcher, making it easier to reuse these in a wider mercurial context and avoiding repetition of common methods.

Reviewed By: quark-zju

Differential Revision: D7415720

fbshipit-source-id: 4ac3492c61aa70ee71d4bdf8c201b905a345a9d1
2018-04-13 21:51:38 -07:00
Martijn Pieters
96a6a5773d sparse: make hg help sparse <subcommand> work
Summary:
This gives us access to the specifics of a subcommand, including switches
(still stubbed out). Note: `hg sparse <subcommand> -h` doesn't work yet, as the
`-h` command line switch would need intercepting as well.

Reviewed By: quark-zju

Differential Revision: D7413859

fbshipit-source-id: 02534f1255a11985ebe8636b26946fbeffc6fe09
2018-04-13 21:51:38 -07:00
Martijn Pieters
84bfcf3162 RFC: sparse: ignore case collisions outside the sparse profile
Summary:
When updating a working copy that is limited by a sparse profile, do not abort on case collisions outside of the current working copy view.

Performance-wise, this isn't a big change; previously `_checkcollision()` would convert the whole manifest to a set, now we filter first with the matcher, then convert the remainder to a set. Either the original set conversion or the filtering can take O(size-of-manifest) time.

Reviewed By: ryanmce

Differential Revision: D7350251

fbshipit-source-id: efb8e270631f0aaa75c34c7b68189c60efe45984
2018-04-13 21:51:37 -07:00
Martijn Pieters
6414c84571 sparse: show individual profile details
Summary: This shows basic details about a template, including base metadata. Once we have support for per-subcommand switches we can add further filtering.

Reviewed By: ryanmce

Differential Revision: D7365794

fbshipit-source-id: 3dd362f099e7f4d6db73c9bda7c24a9f4f2f90ee
2018-04-13 21:51:37 -07:00
Martijn Pieters
422a95de10 sparse: provide subcommands for other common tasks
Summary: Now all commands can be subcommands. The command-line switches will be hidden in a next commit (but remain available for backwards compatibility).

Reviewed By: ryanmce

Differential Revision: D7365393

fbshipit-source-id: 29b8ed2ac6bffccda41ed3f738087dde23312a8c
2018-04-13 21:51:37 -07:00
Martijn Pieters
5296ef905b sparse: make the help system print our subcommands
Summary:
This means we can

- count on the minirst module to format longer lines correctly,
- show subcommands when an error occurs (so full is false),
- add verbose help when the -v switch

Reviewed By: ryanmce

Differential Revision: D7365392

fbshipit-source-id: c8711bd19a6d992ad86f24f3c07b381f69d02121
2018-04-13 21:51:37 -07:00
Martijn Pieters
b8110f185c Allow for better help handling and multiple registrations for a single function.
Summary:
We take help info from the docstring but that'd disallow multiple registrations for a single function that can handle multiple subcommands. Refactor to let the decorator set an override.

So before you'd do this:

```
subcmd('foo')
def _foocmd(...):
    "Help for foo command"
    # implementation for foo

subcmd('bar')
def _barcmd(...):
    "Help for bar command"
    # implementation for bar
```
but you could not *combine* the implementations into one function and decorate both, because there is only the single docstring.

Now you can do:

```
subcmd('foo', help="Help for foo command")
subcmd('bar', help="Help for bar command")
def _fooandbarcmd(cmd, ...):
    "This docstring is no longer used"
    # implementation for foo and bar, combined, switching on the value of cmd
```

Reviewed By: ryanmce

Differential Revision: D7365390

fbshipit-source-id: 3d41542f1f197137ef13458e8d850cda8f53da74
2018-04-13 21:51:37 -07:00
Martijn Pieters
85eb89e007 sparse: make listing profiles a subcommand
Summary:
This is based on the hg show implementation. hg sparse --list-profiles is not yet widely known, so now is the time to move it to a subcommand.

This is the first step in untangling the mess that is the `hg sparse` forest of options.

Currently, all switches on the command are mutually exclusive, except for `—force` and `—template`, which each only apply to a subset of the actions the other switches affect.

Subcommands are the right pattern for mutually-exclusive actions that can accept their own individual switches.

Reviewed By: quark-zju

Differential Revision: D7350928

fbshipit-source-id: d03014cf7edd2f089f670d11465c70940d96c070
2018-04-13 21:51:35 -07:00
Mark Thomas
77d4bc2b83 fbsparse: use new-style progress bars
Reviewed By: mjpieters

Differential Revision: D7329504

fbshipit-source-id: 8037f704f88ea8b7d02ef323932143298fef5c66
2018-04-13 21:51:33 -07:00
Martijn Pieters
36a3e5b595 sparse: use -l as the short option for --list-profiles
Summary: There's a precedent for `-l` for listing: `hg shelve -l`, `hg undo -l`, `hg resolve -l`.

Reviewed By: ryanmce

Differential Revision: D7337527

fbshipit-source-id: 3d9c340590e9756e39cad3bfdd0b017f45fd3a6e
2018-04-13 21:51:31 -07:00
Martijn Pieters
efd45069e3 sparse: use relglob to exclude readme files
Summary: Although the old glob *should* work, in practice the treemanifest matcher seems to have issues with glob:**/ paths, where relglob: works.

Reviewed By: ryanmce

Differential Revision: D7287992

fbshipit-source-id: d3802e730d937eeca7059dac691d8dac5a5de262
2018-04-13 21:51:31 -07:00
Ryan McElroy
4380742b11 fbsparse: cache translations and properly close progress bars
Reviewed By: markbt

Differential Revision: D7211458

fbshipit-source-id: 6536a9e7060ca945a0763a4a54b075bf747d09fc
2018-04-13 21:51:29 -07:00
Ryan McElroy
94ae24f468 fbsparse: show spinner while populating the fileset
Summary:
On a large repo, this can take seconds. Let the user see progress
during this time.

Differential Revision: D7211460

fbshipit-source-id: bfa9ad658a1c190399f9e33de7ddfbe006d6cbfb
2018-04-13 21:51:28 -07:00
Ryan McElroy
07c6e90f29 fbsparse: use context manager for wlock()
Summary:
During testing, I discovered that a ctrl-c while `hg sparse --refresh`
was waitign on the wlock would cause a traceback. This fixes that.

Differential Revision: D7211459

fbshipit-source-id: dde006208f688cc7e2509e822443dececd59c08d
2018-04-13 21:51:28 -07:00