Commit Graph

14427 Commits

Author SHA1 Message Date
Jun Wu
dcf2ddb57a changelog: add experimental.narrow-heads to change head() behavior
Summary:
Add a config option `experimental.narrow-heads`. Once set, "heads" get
redefined by a whitelist (visibility heads + remote names).

This is one step towards removing the blacklist (filteredrev) approach,
which does not scale with the new changelog design.

Reviewed By: sfilipco

Differential Revision: D17199845

fbshipit-source-id: 0feb300ad3ad7b2e33dd7781b4fc181233609a10
2019-09-20 13:36:19 -07:00
Durham Goode
73517f0380 lfs: add test for lfs-downgrade-after-rename issue
Summary:
Normally, when you push an lfs blob the server doesn't need to ever
download the lfs blob content because it can just compare the hashes. There's a
special case though, when a commit makes a blob go from lfs to non-lfs and the
previous version of the blob was a rename, then Mercurial must actually read the
file contents and compare it to know if it changed.

This adds a test to cover the case.

Reviewed By: quark-zju

Differential Revision: D17488079

fbshipit-source-id: 4313ee01e103d3ad13463e4774096d866d420b2e
2019-09-20 11:40:27 -07:00
Stefan Filip
5d7a31d5dd tests: add treemanifest diff test
Summary:
Tree manifests want to have a different order than flat manifests.
This difference in orders can cause algorithms like diff to give wrong
results. This test aims to validate that the treemanifest implemetations
work correctly for cases where the orders are different.

Reviewed By: quark-zju

Differential Revision: D17492500

fbshipit-source-id: eabb5d0fed5804b3d81c12667621ec6d38e0bfce
2019-09-19 19:45:08 -07:00
Jun Wu
8d4d0a66a2 context: wait for wlock for dirstate fixup if watchman reports fresh instance
Summary:
This is an attempt to solve issues that watchman state in dirstate stays stale
and users have pretty bad experience.

Normally, `hg status` is a "read-only" operation that works in a lock-free way,
and `status` still work if other hg commands are taking a lock. However,
`hg status` does need to update watchman state (clock, need-check file list) to
stay performant.

In case watchman reports "fresh instance" case, watchman also returns all file
paths in the working copy, which means the current `status` has very bad
performance, and the next `status` call can still be bad if the watchman state
in dirstate does not get updated.

This diff adds special handling of "fresh instance", waits for the lock, and
attempts to update the watchman state. It should reduce user frustration about
continuously slow `hg status` commands. In case it failed to update the
watchman state, also print warning messages so the user is aware of the issue.
For example, if there is an ongoing `hg histedit` that waits for the editor.

Reviewed By: wez

Differential Revision: D17468790

fbshipit-source-id: ad06bb1d5d13c6904db328c42a470112c3ee9940
2019-09-19 19:07:50 -07:00
Jun Wu
ba26a79d75 testutil/dott: fix delayed exception handling
Summary:
D17277286 changed the error type to SystemExit to swallow the traceback and
make the error cleaner. But that breaks `except Exception` used in `__del__`,
because `isinstance(SystemExit, Exception)` is `False` (surprise !).

Fix it by listing `SystemExit` explicitly.

Also remove the noisy `exception ... in __del__ ignored` message by removing
the `raise`.

Make sure the delayed exception will be handled by adding an `atexit` handler.

Reviewed By: sfilipco

Differential Revision: D17493283

fbshipit-source-id: 2301e318e06708804486d8625118210ae2e42817
2019-09-19 19:05:45 -07:00
Durham Goode
a0a2518bf6 hgsubversion: skip empty commits when pushing
Summary:
We're down to just one use of hgsubversion. In that use it's convienent
to skip empty commits when pushing. Let's add logic to bypass empty commits.

Differential Revision: D17452527

fbshipit-source-id: 5ef76df7d0a44f2d43f4ea0d8678e4174c0286ee
2019-09-19 15:44:19 -07:00
Jun Wu
099650d781 testutil/dott: remove unused logic in feature.py
Summary: Those belong to testtmp.py

Reviewed By: sfilipco

Differential Revision: D17483074

fbshipit-source-id: cbd27efca04ca5a9b8651f6612a5f78bedaea678
2019-09-19 11:41:41 -07:00
Jun Wu
b227af9b12 testutil/dott: do not rewrite $HGRCPATH
Summary: In case run-tests.py prepares $HGRCPATH, it should not be rewritten.

Reviewed By: sfilipco

Differential Revision: D17483075

fbshipit-source-id: d5d32aa65833dde68b37229802a39a75a32b37d0
2019-09-19 11:41:41 -07:00
Jun Wu
b737973619 merge: make it possible to manually specify a rename destination
Summary:
When the rebase destination has renamed a file, and copytrace failed to figure
out anything useful, make it possible to manually input the rename destination.

I'm using it to resolve conflicts caused by landing the bindings rename.

Reviewed By: xavierd

Differential Revision: D17367857

fbshipit-source-id: 55d9ed3a9641e40cc43518e9662fd803cbc00620
2019-09-18 20:44:05 -07:00
Ron Mordechai
4d1577a9c2 merge-tools: look for merge-tools inside repo when relative path is supplied
Summary:
This is useful when writing merge tools that are checked into the repo. We can now reference a tool in the repo. Suggested use case:

  [merge-tools]
  mytool =
  mytool.executable = scripts/mytool.py

Reviewed By: quark-zju

Differential Revision: D17342897

fbshipit-source-id: ffdb160dfea8404721c4fc94fdfcab2d86cca08d
2019-09-18 07:12:18 -07:00
Jun Wu
75ebf84a46 changelog: add a method to get public/draft nodes from remotenames
Summary:
One step towards redefining heads with remote heads.

Debugshell was teached to skip IPython for non-interactive input.

(For some reason most part of this diff got folded into the previous one)

Reviewed By: sfilipco

Differential Revision: D17199842

fbshipit-source-id: 1594658e3e5f2f2c51f817bc1074d28329df7786
2019-09-17 18:15:19 -07:00
Jun Wu
a0ede6c4c6 progressfile: include pid in progress information
Summary:
This provides a way to check if the hg process was gone unexpectedly.
The motivation was to make it less likely that Nuclide shows an hg operation
was ongoing but the process was long gone.

Reviewed By: xavierd

Differential Revision: D17372808

fbshipit-source-id: 19e51f8bbd0fdf14b7e0a4bdb8247d1b4277ee48
2019-09-16 19:02:38 -07:00
Jun Wu
bbd4b91102 remotenames: move 'remotenames' state to storevfs
Summary:
In the future the changelog would need to access 'remotenames' to figure out
public heads. Move the state file to svfs so it can be read by the changelog
object, which only has access to svfs.

Reviewed By: sfilipco

Differential Revision: D17199834

fbshipit-source-id: 9000e0d8e8bb8d398d6c77b5b395da904fef6418
2019-09-13 20:19:09 -07:00
Jun Wu
b2b78f66b9 test-fncache: remove the test
Summary:
We don't use fncache. It does not scale. The test break with narrow-heads.
This diff just removes the fncache test.

Reviewed By: singhsrb

Differential Revision: D17293478

fbshipit-source-id: b41dba333276ad63973b7556dfc400f4b33f6f5d
2019-09-13 17:36:17 -07:00
Jun Wu
14d1ae5689 amend: do not rebase obsoleted commits for next --rebase
Summary:
I hit this when editing the dag stack. This resolves a "BUG" in the
test-amend-nextrebase.t test.

Reviewed By: singhsrb

Differential Revision: D17357387

fbshipit-source-id: 309efe34dee71180abdbdb5a9fe2e7b731230051
2019-09-12 20:00:28 -07:00
Jun Wu
d678fe1702 encoding: replace 'ascii' with 'utf-8' automatically
Summary:
`ascii` was used as the default / fallback, which is not a user-friendly choice.
Nowadays utf-8 dominates:

- Rust stdlib is utf-8.
- Ruby since 1.9 is utf-8 by default.
- Python 3 is unicode by default.
- Windows 10 adds utf-8 code page.

Given the fact that:

- Our CI sets HGENCODING to utf-8
- Nuclide passes `--encoding=utf-8` to every command.
- Some people have messed up with `LC_*` and complained about hg crashes.
- utf-8 is a super set of ascii, nobody complains that they want `ascii`
  encoding and the `utf-8` encoding messed their setup up.

Let's just use `utf-8` as the default encoding. More aggressively, if someone
sets `ascii` as the encoding, it's almost always a mistake. Auto-correct that
to `utf-8` too.

This should also make future integration with Rust easier (where it's enforced
utf-8 and does not have an option to change the encoding). In the future we
might just drop the flexibility of choosing customized encoding, so this diff
autofixes `ascii` to `utf-8`, instead of allowing `ascii` to be set. We cannot
enforce `utf-8` yet, because of Windows.

Here is our encoding strategy vs the upstream's:

| item           | upstream |          | ours          | ours  |
|                | current  | ideal    | current       | ideal |
| CLI argv       | bytes    | bytes    | utf-8 [1]     | utf-8 |
| path           | bytes    | auto [3] | migrating [2] | utf-8 |
| commit message | utf-8    | utf-8    | utf-8         | utf-8 |
| bookmark name  | utf-8    | utf-8    | utf-8         | utf-8 |
| file content   | bytes    | bytes    | bytes         | bytes |

[1]: Argv was accidentally enforced utf-8 for command-line arguments by a Rust
wrapper.  But it simplified a lot of things and is kind of ok: everything that
can be passed as CLI arguments are utf-8: -M commit message, -b bookmark, paths,
etc. There is no "file content" passed via CLI arguments.

[2]: Path is controversial, because it's possible for systems to have non-utf8
paths. The upstream behavior is incorrect if a repo gets shared among different
encoding systems (ex. both Linux and Windows). We have to know the encoding of
paths to be able to convert them suitable for the local system. One way is to
enforce UTF-8 for paths. The other is to keep encoding information stored with
individual paths (like Ruby strings). The UTF-8 approach is much simpler with
the tradeoff that non-utf-8 paths become unsupported, which seems to be a
reasonable trade-off.

[3]: See https://www.mercurial-scm.org/wiki/WindowsUTF8Plan.

Reviewed By: singhsrb

Differential Revision: D17098991

fbshipit-source-id: c0ff1e586a887233bd43cdb854fb3538aa9b70c2
2019-09-12 15:06:36 -07:00
Jun Wu
0b501bab67 test-fb-hgext-treemanifest-treeonly-copyamend: stablize the test
Summary:
It can fail with:

  test-fb-hgext-treemanifest-treeonly-copyamend.t ...
  --- test-fb-hgext-treemanifest-treeonly-copyamend.t
  +++ test-fb-hgext-treemanifest-treeonly-copyamend.t.err
  @@ -124,6 +124,7 @@
     adding a/b/c/d/e/f/g/h/i/j/file3
     fetching tree '' efa8fa4352b919302f90e85924e691a632d6bea0, found via 9f95b8f1011f
     11 trees fetched over *s (glob)
  +  5 files fetched over 1 fetches - (5 misses, 0.00% hit ratio) over 0.00s

or:

  --- test-fb-hgext-treemanifest-treeonly-copyamend.t
  +++ test-fb-hgext-treemanifest-treeonly-copyamend.t.err
  @@ -124,6 +124,7 @@
     adding a/b/c/d/e/f/g/h/i/j/file3
     fetching tree '' efa8fa4352b919302f90e85924e691a632d6bea0, found via 9f95b8f1011f
     11 trees fetched over *s (glob)
  +  12 files fetched over 1 fetches - (12 misses, 0.00% hit ratio) over 0.00s

It fails more easily on Ubuntu. But it's also possible on CentOS.

Stabilize the test by allowing the optional output.

Reviewed By: singhsrb

Differential Revision: D17346110

fbshipit-source-id: ca6d1de5163e1b2bcb7bea5c619220d6f5e2c864
2019-09-12 10:53:23 -07:00
Jun Wu
43f081c18a test-scm-prompt: fix tests
Summary: `scm-prompt` is a bit special. They didn't trigger those tests when modified.

Reviewed By: wez

Differential Revision: D17346163

fbshipit-source-id: ffafc017373031905cbf1fc2f80a3a8e8a606094
2019-09-12 10:00:55 -07:00
Aleksei Kulikov
a0e092de37 snapshot: add a command to list the local snapshots
Reviewed By: markbt

Differential Revision: D17227370

fbshipit-source-id: 363f45431824b574cc298eb5c0f40c334f1d916b
2019-09-11 06:38:41 -07:00
Jun Wu
a55fe385eb dispatch: change 'no repository found' message
Summary:
Change the message so it looks more like a user error, not a crash in the
software. This is motivated by some people reporting `hg rage` crash with
`abort: no repository found` messages.

Reviewed By: sfilipco

Differential Revision: D17292658

fbshipit-source-id: 9988f54f2ff8fd48949bcd35c13309c117f3afc6
2019-09-10 18:29:50 -07:00
Xavier Deguillard
9e88acbdf7 remotefilelog: remove local loosefile generation
Summary:
The `remotefilelog.packlocaldata` has been on for a while now. Instead of
keeping the code around, let's simply remove it and fix all the tests that
assume a commit will generate loosefiles.

Reviewed By: quark-zju

Differential Revision: D17244837

fbshipit-source-id: e65ed16c9818be61be9ccbe19ce3fa18c890d70b
2019-09-10 13:10:42 -07:00
Jun Wu
57e6e896ad testutil/dott: simplify error messages
Summary:
The current error message is a bit noisy. Let's just get to the point about the
filename and line number that is interesting without tracebacks. This only
affects functions using the `autofix.eq` API, other kinds of exceptions will
have tracebacks as usual.

Before, run-tests.py (19 lines):

  --- test-empty-t.py.out
  +++ test-empty-t.py.err
  @@ -0,0 +1,14 @@
  +Traceback (most recent call last):
  +  File "hg/tests/test-empty-t.py", line 71, in <module>
  +    """
  +  File "hg/tests/testutil/dott/shobj.py", line 89, in __eq__
  +    autofix.eq(out, rhs, nested=1, eqfunc=eqglob)
  +  File "hg/tests/testutil/autofix.py", line 93, in eq
  +    raise AssertionError("actual != expected\n%s" % diff)
  +AssertionError: actual != expected
  +--- expected
  ++++ actual
  +@@ -1 +1 @@
  +-someheads
  ++allheads
  +

  ERROR: test-empty-t.py output changed

Before, run directly via python (13 lines):

  Traceback (most recent call last):
    File "test-empty-t.py", line 71, in <module>
      """
    File "hg/tests/testutil/dott/shobj.py", line 89, in __eq__
      autofix.eq(out, rhs, nested=1, eqfunc=eqglob)
    File "hg/tests/testutil/autofix.py", line 93, in eq
      raise AssertionError("actual != expected\n%s" % diff)
  AssertionError: actual != expected
  --- expected
  +++ actual
  @@ -1 +1 @@
  -someheads
  +allheads

After, run-tests.py (8 lines):

  --- test-empty-t.py:71 (expected)
  +++ test-empty-t.py:71 (actual)
  @@ -1 +1 @@
  -someheads
  +allheads

  ERROR: test-empty-t.py output changed

After, run directly (5 lines):

  % python test-empty-t.py
  --- test-empty-t.py:71 (expected)
  +++ test-empty-t.py:71 (actual)
  @@ -1 +1 @@
  -someheads
  +allheads

Reviewed By: xavierd

Differential Revision: D17277286

fbshipit-source-id: a48d4d1e817f67e221a901977e0c0f8bdc1a62ab
2019-09-10 13:01:33 -07:00
Jun Wu
1493c68d40 run-tests: make -i/--update-output/--fix autofix Python t.py tests
Summary:
Previously `python --fix test-foo-t.py` is the only way to autofix the test.
That's a bit annoying because `run-tests.py` has more features (ex. run many
tests together).

This diff changes `run-tests.py` to pass `--fix` to Python `-t.py` tests so
the autofix works in a familiar way. `--fix` was added as an alias to
`--update-output` to make it consistent with the Python UX.

Reviewed By: xavierd

Differential Revision: D17277287

fbshipit-source-id: e815a79895161862d844de165710cc36d6709727
2019-09-10 13:01:33 -07:00
Jun Wu
379d5e5490 testutil/dott: implement autofix for commands without outputs
Summary:
Comparing to `.t` tests, `dott` Python tests cannot autofix commands without
outputs.  This diff makes it able to do so. It's less strict than the AST
parsing (for example, it does not handle `#` comments precisely). But
practically it might be good enough. We can update it to use real AST parsing
if it becomes an issue.

This should make `dott` Python tests easier to use.

Reviewed By: xavierd

Differential Revision: D17277285

fbshipit-source-id: 11ef6ec4327a6547d49b544c63bc000a3c351947
2019-09-10 13:01:32 -07:00
Jun Wu
771fa19f18 testutil/dott: raise exceptions with better tracebacks
Summary:
The current `dott` library enforces `sh % "foo"` to output nothing. That's
done by checking in `__del__`. `__del__` is special and cannot raise exceptions
so the current code put exceptions in a "delayed" list and raise it later.
However, the "later" raise uses a new traceback that is useless.

This diff changes it to use `sys.exc_info` to save the traceback information
so we can re-raise with more accurate exception:

For example, the exception before looks like:

  % python test-empty-t.py
  Traceback (most recent call last):
    File "test-empty-t.py", line 71, in <module>
      sh % "cd .."
    File "fbcode/scm/hg/tests/testutil/dott/shobj.py", line 151, in __mod__
      return LazyCommand(command)
    File "fbcode/scm/hg/tests/testutil/dott/shobj.py", line 28, in __init__
      raise _delayedexception[0]
  UnboundLocalError: local variable 'code' referenced before assignment

The `shobj.py` in traceback is pointless.

With the change, it now looks like:

  % python test-empty-t.py
  Traceback (most recent call last):
    File "test-empty-t.py", line 71, in <module>
      sh % "cd .."
    File "fbcode/scm/hg/tests/testutil/dott/shobj.py", line 153, in __mod__
      return LazyCommand(command)
    File "fbcode/scm/hg/tests/testutil/dott/shobj.py", line 97, in __del__
      autofix.eq(out, "", nested=1, fixfunc=_fixoutput)
    File "fbcode/scm/hg/tests/testutil/autofix.py", line 74, in eq
      fix = fixfunc(code, parse, lineno, parse(path))
  UnboundLocalError: local variable 'code' referenced before assignment

Reviewed By: xavierd

Differential Revision: D17277288

fbshipit-source-id: 91f22b75b2e2efd632f5844b1d2554e7406be926
2019-09-10 13:01:32 -07:00
Xavier Deguillard
63e18be4d6 treemanifest: use Rust repack for server treemanifest repack
Summary:
We were still using the Python based repack, let's switch to the Rust one. As
far as I can tell, this code is unused, so the test change should be safe to
do.

Reviewed By: quark-zju

Differential Revision: D17207643

fbshipit-source-id: 89d0ba85327077dfc4e26c55ade3284beeb44b50
2019-09-10 11:36:00 -07:00
Aleksei Kulikov
b7ee506bfa snapshot: keep a list of snapshots in .hg/store/snapshotlist
Reviewed By: markbt

Differential Revision: D17226709

fbshipit-source-id: fefa31227f77295793ccaa3448f4488274f70848
2019-09-09 10:38:22 -07:00
Wez Furlong
0f9b49b65e hg: add debug command to trigger update hooks
Summary:
For Eden we currently have a gap in our post-mount behavior;
we don't perform the update hooks for a freshly cloned and mounted repo.

The thought is that we'll explicitly trigger them by invoking `hg
debugedenrunpostupdatehook` at the end of the mount sequence.

Reviewed By: quark-zju

Differential Revision: D17237197

fbshipit-source-id: 9c2212c61735068c287eb98761503ce31bfee8a6
2019-09-07 10:21:48 -07:00
Aleksei Kulikov
377e1200a7 snapshot: add -m option to set up a custom snapshot message
Reviewed By: markbt

Differential Revision: D17206496

fbshipit-source-id: a6e190ca87aa5309e359a5cecd6c6bc40634ca8d
2019-09-06 08:18:36 -07:00
Aleksei Kulikov
ccc05d0d65 snapshot: remove lfs dependency completely
Summary: Also remove debug commands that are strictly related to remote lfs.

Reviewed By: markbt

Differential Revision: D17184902

fbshipit-source-id: da38a2150212500bab62191ddcfab0990276605e
2019-09-06 08:18:35 -07:00
Aleksei Kulikov
22dce8230d snapshot: bundle metadata and the related files
Summary:
Instead of the lfs remote storage it was chosen to send the snapshot metadata via bundles.
Snapshot metadata consists of: the actual metadata blob + several other blobs (untracked files etc).
If we have several snapshot revisions in a single bundle, the blobs could repeat.
Then we should store each blob as a separate entry in a binary stream, keeping its id and contents.

Here we introduce a new bundle part type `"b2x:snapshotmetadataparttype"`.
```
1 byte of version info
[ # a list of binary entries, each corresponds to a separate file
  # (either a metadata file itself or a related -- externally stored -- file)
  <oid><length><data>
  :oid: is a 64char string with the hash of the file
  :length: is an unsigned int with length of the data
  :data: is binary data of length <length>, the actual file contents
]
```

So far there is an ongoing discussion on the exact format of serialization.
Actual state is at [the quip doc](https://fb.quip.com/R5OVAzabX8oo).

Reviewed By: markbt

Differential Revision: D17184222

fbshipit-source-id: 90f833ec71556e90d513e3be3f3efa7f870b037d
2019-09-06 08:18:35 -07:00
Aleksei Kulikov
732a5baa9a snapshot: use local snapshot storage instead of lfs
Summary: In the next diff I will replace remote lfs with bundle2

Reviewed By: markbt

Differential Revision: D17132405

fbshipit-source-id: a0dfff3ebad067abb0231cf31de08ae62affe7ce
2019-09-06 08:18:35 -07:00
Mark Thomas
465e91bbe5 debugmutation: don't use the unfiltered repo by default
Summary:
The `debugmutation` command uses the unfiltered repo to resolve the
user-provided revs.  It shouldn't do this unless the user passes `--hidden`.

Reviewed By: mitrandir77

Differential Revision: D17156722

fbshipit-source-id: 5ab7704acc598cf8b7c1640a3096ba0ce6ac73e9
2019-09-06 00:44:13 -07:00
Mark Thomas
8dc0110c6d debugmutation: improve format and render successors
Summary:
Update the debugmutation format to collapse long chains.  Add
`hg debugmutation -s` to follow the successor relationship (printing what the
commit became) instead of the predecessor relationship.

Reviewed By: mitrandir77

Differential Revision: D17156463

fbshipit-source-id: 44a68692e3bdea6a2fe2ef9f53b533199136eab1
2019-09-06 00:44:12 -07:00
Mark Thomas
d21fc6233a treemanifest: don't purge shared packs while repack is running
Summary:
If treemanifest finds there are too many shared packs (more than
`packs.maxpackfilecount`) then it will purge them.  This is a shame if there is
currently a repack in progress, as it will purge the packfiles from underneath
the repack, deleting lots of cache data that will be imminently repacked).

Skip the purge if there is a repack ongoing.

Reviewed By: mitrandir77

Differential Revision: D17155854

fbshipit-source-id: 20d46f29c252e508177b1fde08ca7a69841dcd7e
2019-09-06 00:40:52 -07:00
Jun Wu
0b570f65a7 stablerev: pass information using environment variables
Summary:
Instead of hardcoding `--target <target>` and hardcode `$2` in the script.
Let's just use environment variables so `target` and other things have explicit
names.

Explicit set `REAL_CWD` so the script can learn the current directory before
it gets reset to the repo root.

Reviewed By: xavierd

Differential Revision: D17213186

fbshipit-source-id: 6a4fc4cf2cbf6e2c623400bc6bc13f7758a46c49
2019-09-05 15:53:37 -07:00
Jun Wu
d66ac32198 metaedit: support -M / --reuse-message
Summary:
This makes metaedit support `-M / --reuse-message`, which I found handy when
rewriting prototype commits to formal commits.

Reviewed By: xavierd

Differential Revision: D17168991

fbshipit-source-id: fa768a2916ea3ef4db4c31a48989d10897379e92
2019-09-04 17:06:36 -07:00
Jun Wu
fd071d2076 cmdutil: change logmessage to take a repo
Summary:
Change `cmdutil.logmessage` to take a `repo` instead of `ui`. This makes the
next change easier.

Reviewed By: xavierd

Differential Revision: D17168990

fbshipit-source-id: 47c1707e5a9dbf06d07452b4c400903453992379
2019-09-04 17:06:35 -07:00
Jun Wu
1e027a58e7 fsmonitor: warn about slow full-repo scans
Summary:
I have seen multiple user complaints about slow hg commands that turned out to
be fsmonitor scanning the whole working copy. Print a warning in those cases.
Hopefully this can reduce our oncall burden a bit.

Reviewed By: xavierd

Differential Revision: D17170520

fbshipit-source-id: 8fd5721d123853136c84229d936c3e0c999f3d87
2019-09-04 14:14:51 -07:00
Jun Wu
5def63525a sigtrace: use smarttraceback and print to stderr
Summary:
Make sigtrace use smarttraceback so it prints more context.
As we're here, also make it print to stderr so we don't need to find the
traceback from /tmp.

Reviewed By: xavierd

Differential Revision: D17066277

fbshipit-source-id: 9a1000803fed27a71ec381b8ddbd76400dae99c9
2019-09-04 13:37:39 -07:00
Aleksei Kulikov
bead18e577 lfs: move abstract local blobstore to core mercurial
Summary: It will be used by snapshot extension too.

Reviewed By: markbt

Differential Revision: D17132134

fbshipit-source-id: 6c9fc285e0f1eb445bfa0abe0b6f4de4a1bd1db0
2019-09-04 11:09:36 -07:00
Aleksei Kulikov
c193470431 snapshot: prohibit regular checkout on snapshot
Differential Revision: D17093630

fbshipit-source-id: 4425c90fbdecfa3edc9f34f677e0be6b771aa0af
2019-09-04 11:09:35 -07:00
Stefan Filip
edfeb9f529 treemanifest: remove delta storing of manifest entries when autocreate
Summary:
It is somewhat difficult to fetch the raw entry on the p1 side in the Rust
Manifests. These entries are used to write deltas to revlogs or to datapacks.

Reviewed By: xavierd

Differential Revision: D17143551

fbshipit-source-id: 6624116324664354d199d5f6ac55712c8ed29b9d
2019-09-03 15:08:34 -07:00
Mark Thomas
013aa19333 mutation: don't allow divergence when rebasing
Summary:
In general, mutation tracking doesn't care about divergence.  However, in the
case of rebase, it doesn't make sense to allow divergence to occur if we can
avoid it by omitting some of the commits to rebase.

This makes rebase behaviour more like old obsmarker-based behaviour.  This
breaks a test for mutation copying markers, so update those to use metaedit,
which has the copying behaviour for both obsmarkers and mutation.  At some
point we should make rebase behave better in these cases.

Reviewed By: quark-zju

Differential Revision: D17136480

fbshipit-source-id: 9e465b7fc8bda33e7a746e4df68410713e2be37e
2019-09-02 03:13:51 -07:00
Mark Thomas
ebe5c4ae68 mutation: convert test-amend-nextrebase to mutation and visibility
Summary:
Convert the test case `test-amend-nextrebase` to use new mutation and visibility tracking.

In doing so, reveals a bug where `hg next --rebase` can rebase obsolete commits.

Reviewed By: quark-zju

Differential Revision: D17136483

fbshipit-source-id: dcda88d1e8c1f435d6211cf5b76791c5a76ee343
2019-09-02 03:13:50 -07:00
Mark Thomas
efe45b4a08 amend: add a test for next --rebase with visible predecessors
Summary:
Add a new test for `hg next --rebase` for when a predecessor of the commit
being rebased is also visible.  The predecessor should not be rebased.

Reviewed By: quark-zju

Differential Revision: D17136482

fbshipit-source-id: fa2c91ebc14c72f6a8c13c4549447809090489b3
2019-09-02 03:13:50 -07:00
Xavier Deguillard
4b28370d5e remotefilelog: local loosefiles should always be fully repacked
Summary:
The loosefiles repack was made incremental to greatly reduce the repack time
for users. Since the amount of local loosefiles should be way smaller than the
amount of shared ones, let's always run a full repack on the former. This
should allow us to kill all the local loosefiles, which will help in no longer
supporting them.

Reviewed By: quark-zju

Differential Revision: D17135975

fbshipit-source-id: 9480993b31aa57d0d6e6b7caffd282929183f782
2019-08-30 15:09:25 -07:00
Xavier Deguillard
91462ec10e remotefilelog: add a test to show incremental local data repack
Summary:
This illustrate that the local data repack isn't a full one. Note that the test
is a bit flaky due to 1) the underterministic nature of what folder to repack,
and 2) the choice of folder to repack being done twice (one for data, one for
history). Since I won't land this without the next one, this is probably fine.

Reviewed By: quark-zju

Differential Revision: D17135978

fbshipit-source-id: 641d257d0e308b2bb4d91fdc4c214b22e45b4911
2019-08-30 15:09:25 -07:00
Xavier Deguillard
6e0b6a2161 remotefilelog: Rust repack is the default
Summary:
Rust repack has been the default for a while now. Let's stop pretending we're
going to switch back to the Python repack by removing the config entirely.

Reviewed By: quark-zju

Differential Revision: D17135977

fbshipit-source-id: 5aaa0faa48e2b40a7314d5ab455f5eeaa4e4984d
2019-08-30 15:09:24 -07:00
Jun Wu
b178492317 changelog: disable inline revlog
Summary:
The inline revlog format merges `.i` and `.d` into one `.i` file. It was intended to reduce the
number of files for filelogs. For the changelog one extra file does not hurt.

This makes it easier to write native code parsing the changelog revlog index.

Reviewed By: xavierd

Differential Revision: D17125922

fbshipit-source-id: f48ffe0d2df71abec007a80e05b684dcbac71883
2019-08-30 14:58:02 -07:00
Thomas Orozco
fa4e12df09 wireproto logging: capture getpack
Summary:
ignore-conflict-markers

This updates Mercurial to add a loggetpack option for wire proto logging that
allows capturing getpack responses. This will be useful to verify correctness
for ovrsource on Mononoke (right now, Mononoke isn't serving traffic for hosts
that use getpack).

Reviewed By: StanislavGlebik

Differential Revision: D17091537

fbshipit-source-id: 755a429949d7645010dddab95202c613025f2984
2019-08-30 05:08:18 -07:00
Xavier Deguillard
309229fdf5 remotefilelog: do no build the entire ancestormap in remotefilectx.parents
Summary:
While working on a stack, I noticed that `hg amend -e` would sometimes download
a lot of history information. For a 4 files change, I saw 738 history entry
fetched individually...

Looking at the profile, this pointed towards remotefilectx.parents requesting
the entire ancestormap. Since that function really only need the nodeinfo,
let's only get that.

Reviewed By: DurhamG

Differential Revision: D17104263

fbshipit-source-id: fae1f673b2d2a641ae4f22d1099317cc5abd8447
2019-08-29 09:51:38 -07:00
Jun Wu
a459d31cae testutil/dott: use bindings.commands to run commands
Summary:
This makes it possible to execute Rust commands from the Python tests.

Test changes:
- test-command-template-t: non-utf8 command-line arguments are rejected at the
  function signature level
- test-dispatch-debug-prefix-t: the error is now printed by Rust code, which
  uses spaces instead of tabs.
- test-root-t: the test now passes

Reviewed By: xavierd

Differential Revision: D16866459

fbshipit-source-id: 386931c5497b04c53efc08fbb4de708812517ad9
2019-08-28 19:26:26 -07:00
Jun Wu
c18159134f testutil/dott: set commands.names
Summary:
This gives the Rust code path hints to names of Python command names.

Ideally, the Rust command dispatch logic can just load the Python command table
and figure out it more accurately, and more parts of dispatch.py (ex. extension
loading, debugger, profiler, atexit, etc) are moved to Rust clidispatch or
hgcommands. But that would be a larger change.

Reviewed By: xavierd

Differential Revision: D16866462

fbshipit-source-id: eb993091d5644710686b8f720fd07258b9a5968c
2019-08-28 19:26:26 -07:00
Aleksei Kulikov
33f371d27c snapshot: bugfix - do not miss the metadata in clean merge state
Summary:
So far we missed the metadata if there were no changes in the WC.
A metadata file was created but was not attached to the commit.

Differential Revision: D17070211

fbshipit-source-id: 646c8bceb575f4302ec60e35472cc55de086d7e0
2019-08-28 03:56:13 -07:00
Stefan Filip
4be6f11ab5 localrepo: reorder remove operations so they happen before add
Summary:
The Rust Manifests prevent having both a file and a directory with the same
name. This is a problem for the localrepo commit logic which will first add
the new entry, be that file or directory, and then remove the old one.

Reviewed By: quark-zju

Differential Revision: D16775350

fbshipit-source-id: 4515e42f9d2b1b2bc4861c16a39d291225cddc2a
2019-08-26 10:48:08 -07:00
Stefan Filip
98b32be924 manifest: remove the dirs function from the manifest
Summary:
There is no custom implementation for manfiest.dirs(). Generally speaking
the custom implementation is a good thing but doing the migration in the
current python codebase doesn't seem worth while at the moment.

Reviewed By: quark-zju

Differential Revision: D16775351

fbshipit-source-id: c428860d21088a50a0f754dc20d6ee224d2eae32
2019-08-26 10:48:07 -07:00
Jun Wu
a6ad29eadf phase: use commit hash internally
Summary: This removes a false positive detection of "revision number" usage.

Reviewed By: singhsrb

Differential Revision: D16955290

fbshipit-source-id: 5d8762c21b0ceb9b7576f220e0d177db3918abc1
2019-08-22 13:00:13 -07:00
Jun Wu
17f66b3e1f smartlog: avoid false positive detection of revnum usage
Summary:
If `smartlog()` is the user input, the revnum detection is enabled for the
whole scope of smartlog revset implemenation. The use of rev numbers triggers
the warning. But the user didn't use any rev number.

Change smartlog to disable the revnum detection for its internal calculation.
Carefully choose the scope so `smartlog(1+2)` will still be warned.

Reviewed By: singhsrb

Differential Revision: D16954997

fbshipit-source-id: 1a3d32c1c2bcba08bfac908623b6416cf1cd63a8
2019-08-22 13:00:12 -07:00
Aleksei Kulikov
88ba91d3dc snapshot: add negative tests of broken metadata
Reviewed By: markbt

Differential Revision: D16961999

fbshipit-source-id: 730766962fab1ed94bfa8991256ac963a78cf4c0
2019-08-22 09:32:04 -07:00
Aleksei Kulikov
b8088a8a9e snapshot: rename commands to non-debug ones
Summary:
Instead of `debugsnapshot` and `debugcheckoutsnapshot` we will use
`snapshot create|checkout`.

Reviewed By: markbt

Differential Revision: D16961037

fbshipit-source-id: 142d072672376c2ce6a248a4dceffdd94d56a4df
2019-08-22 09:32:04 -07:00
Aleksei Kulikov
216bd69c29 snapshot: add version info to snapshot metadata
Reviewed By: markbt

Differential Revision: D16941087

fbshipit-source-id: 10d1857060dafcda2005a14d731758a2221ad7fd
2019-08-22 09:32:04 -07:00
Jun Wu
adbe2b2b32 alias: ignore alias definitions with ":" in name
Summary:
Aliases with `:doc` in name are not real commands. Do not treat them as
commands.

The upstream patch https://phab.mercurial-scm.org/D5087 added other metadata
including `:help` and `:category`. We might end up having some in the future
so I blacklisted names with `:` in them, not just `:doc`.

Reviewed By: chadaustin

Differential Revision: D16955596

fbshipit-source-id: b6f3e1129b632e0ba43c800e7e6fdd2b52d3b40c
2019-08-21 21:13:38 -07:00
Jun Wu
b6101a12e0 clidispatch: rework error handling
Summary:
Change error type in clidispatch from `DispatchError` to `failure::Error`.

Pros:
- `failure` will attach a backtrace for free. (otherwise, backtrace handling is
  manual)
- Wrapping other errors (ex. `io::Error`, `cliparser::Error`) is optional.
  (otherwise, wrapping other errors is mandatory, and needs to be careful to
  not lose information)

Cons:
- No longer able to enumerate *all* possible error types. (but can still
  downcast to specific errors)

This seems to be a good tradeoff especially because of the backtrace handling - I
ran into a few issues where the location where the error happened really helped
debugging.

Since we can no longer enumerate all possible error types, the enum was changed
to individual structs to make the code shorter (ex. the struct can be downcasted
directly, instead of down-casting to the enum, then matching its variant).

The `HighLevelError` handling was simplified and moved to `hgmain`.

The new code path falls back to Python less aggressively, therefore some behaviors
were tweaked (ex. `-R` takes a bundle path).

Reviewed By: sfilipco

Differential Revision: D16796400

fbshipit-source-id: 1b17eb8d62503644b118c6b799778182bf222538
2019-08-21 12:59:28 -07:00
Jun Wu
0bc2824c82 clidispatch: make use of HgGlobalOpts
Summary: Convert global flags to `HgGlobalOpts` struct to make code shorter.

Reviewed By: sfilipco

Differential Revision: D16796407

fbshipit-source-id: b9d4c3dbec68c81908d439da4c353249347ca74a
2019-08-21 12:16:36 -07:00
Jun Wu
210bf49f5e clidispatch: replace Dispatcher with CommandTable
Summary:
The `Dispatcher` provides lots of features but its internal state only contains
the command table. Replace it with `CommandTable` and make the methods free
functions.

This makes function dependencies more cleaner, for example things like "locating
a repo", "getting the args" etc. won't require a `Dispatcher`.

A side effect of this change is the non-utf8 command line arguments are no longer
supported. This is already broken since our hg wrapper (accidentally) enforced
utf-8 command line. Therefore related tests are removed.

Reviewed By: sfilipco

Differential Revision: D16796395

fbshipit-source-id: a793ce7b8befe7caf62405c582fc932eb3daa099
2019-08-21 12:16:35 -07:00
Aleksei Kulikov
e8c5b4830f snapshot: rename manifest to metadata
Summary: Snapshot `metadata` won't be confused with regular commit manifest.

Reviewed By: markbt

Differential Revision: D16929553

fbshipit-source-id: 466b167aa1cc30f137e0c0b4601d70876509e03c
2019-08-21 10:36:34 -07:00
Aleksei Kulikov
71a0402c8a snapshot: fix dirstate behavior during snapshot checkout
Summary:
At first, that aim was to create a good and consistent test plan of snapshots:
```
# Snapshot test plan:
# 1) Empty snapshot (no changes);
# 2) Snapshot with an empty manifest (changes only in tracked files);
# 3) Snapshot with a manifest (merge state + mixed changes);
# 4) Same as 3 but test the --clean flag on creation;
# 5) Same as 3 but test the --force flag on restore.
```
Then I discovered some bugs while writing the tests.
1) In case of an empty manifest the `snapshotmanifestid` extra should be an empty string, not `None`.
This is because of the extra serialization rules.
2) The initial approach for doing the checkout did some unnecessary operations with dirstate,
which required it to rollback later.
Now the overhead is gone, and the strategy of checking out is as follows:
```
1. Regular hg update to the (1st) parent of the snapshot;
2. Apply all the changes via mergemod.update without pushing it to the dirstate;
3. Register these changes in the dirstate;
4. Tie the second snapshot parent to the working context, if it exists.

Reviewed By: markbt

Differential Revision: D16929417

fbshipit-source-id: 0319ac0e81f80956cdef5b2a696b642cc782f48d
2019-08-21 10:36:34 -07:00
Aleksei Kulikov
c9be937325 snapshot: remove --hidden flag when expicitly accessing snapshots
Summary: Snapshots have invisible commits underneath them, so that flag is redundant.

Reviewed By: markbt

Differential Revision: D16916268

fbshipit-source-id: 294f34af5aa7942be0bb2b58f0dc65979d593157
2019-08-21 10:36:34 -07:00
Aleksei Kulikov
2401518de9 snapshot: bugfix - make files missing instead of removed on checkout
Summary: Due to a bug the missing files from the snapshot manifest were marked as removed after checkout.

Reviewed By: markbt

Differential Revision: D16831796

fbshipit-source-id: 200ccf34b16392a73d38294f1fcb43bfa9a94690
2019-08-21 10:36:33 -07:00
Aleksei Kulikov
8cebfd9c65 snapshot: add --clean option to snapshot cmd
Summary:
It cleans the working copy, equivalent of `hg checkout --clean && hg
purge`.

Reviewed By: markbt

Differential Revision: D16831349

fbshipit-source-id: d765f2f36f561786ec57bc1e54fdf81695f1e7e0
2019-08-21 10:36:33 -07:00
Jun Wu
b6ab106a37 revset: detect revision numbers optimized in _list revset
Summary:
A revset optimization pass rewrites revsets like 1+2+3 to use the `_list`
revset function that has a fast path to bypass the `stringset` function.
Change `_list` to detect revision numbers too.

Reviewed By: singhsrb

Differential Revision: D16910791

fbshipit-source-id: 51036b7d6f16b5388bbaf996864946df91a9f093
2019-08-20 17:21:10 -07:00
Mark Thomas
540f1f0828 amend: use commit hashes rather than revision numbers for moverelative
Summary:
Use of revision number is being deprecated.  Change the moverelative commands
(`next`, `previous`, ...) to use nodes internally.

Reviewed By: mitrandir77

Differential Revision: D16898856

fbshipit-source-id: 71f6fc32776e2912795f086d11897d36b942b608
2019-08-20 11:45:23 -07:00
Jun Wu
36f974ebae clidispatch: register commands without CommandDefinition
Summary:
Previously, the command table state in `Dispatcher` is confusing:

    command_table: BTreeMap<String, CommandFunc>,
    commands: BTreeMap<String, CommandDefinition>,

Question: In what case do these BTreeMaps have different keys?

It does not make much sense. Therefore merge `CommandFunc` into
`CommandDefinition`, and remove the `command_table` field.

This affects the `register` API:

		fn register(&mut self, command: CommandDefinition, f: FN)

`f` is part of `CommandFunc`, which duplicates with `CommandDefinition`.

`CommandDefinition` contains 3 things: name, doc, and flags.

In the new `define_flags!` world, `flags` can be inferred from the type
of the function, so only `name` and `doc` are needed. Therefore change
the register function to:

		fn register(&mut self, f: FN, name: &str, doc: &str)

Update `hgcommands` to use the newer APIs. Commands can now be registered
without going through `CommandDefinition` explicitly.

Reviewed By: sfilipco

Differential Revision: D16733275

fbshipit-source-id: 68e404a5b271b72aad52f640123b1c083f31d76c
2019-08-19 19:27:31 -07:00
Jun Wu
ec304e1d1e commands: assign 'd' alias to 'diff'
Summary:
Git does not have command name prefix matching. We now use `commands.names`
config options as a hint to avoid going to the Python land for command
prefix matching. It works but is not "correct". If we drop the prefix matching
feature, then the problems are gone - fast paths won't need prefix matching
aka. the command name list, and slow path (ex. wrong command) can afford
loading Python for all command names.

`hg d` is the single most used prefix matching command. Assign an explicit
alias to it to avoid regression if we do drop prefix matching (or, make
that more expensive than resolving commands direcly).

Reviewed By: sfilipco

Differential Revision: D16733274

fbshipit-source-id: 8904288b8a1ddf1fc6e6ec54ffaa36e503ebdb77
2019-08-19 19:27:29 -07:00
Jun Wu
d0cf5aacfa dispatch: remove Python alias handling
Summary:
This removes Python alias handling so the alias handling is done entirely in
Rust.

There are some subtle changes - alias using prefix mathcing to ambiguous
commands will not show other aliases. Hopefully that won't be a big issue.
Users can always avoid prefix matching in alias to solve the issue.

Reviewed By: sfilipco

Differential Revision: D16733270

fbshipit-source-id: 54a4915d49c2b2f6e8664a225a9c0f25e1c38d17
2019-08-19 19:27:29 -07:00
Jun Wu
42e4cc19fc test-lfs-test-server: disable the test
Summary:
This test is currently broken if lfs-test-server is installed. Disable it
instead of relying on the test system does not have lfs-test-server.

Reviewed By: sfilipco

Differential Revision: D16733271

fbshipit-source-id: de0c9beb8e981e33e32e43435e2d06181cbae70e
2019-08-19 19:27:29 -07:00
Jun Wu
2f3cf9b23b dispatch: do not show help on UnknownCommand
Summary:
Similar to D14151200, instead of printing a long help that might flush out
important messages, make the error short but still point the user to `hg help`.

This makes the error message much shorter, and make the test change by the
upcoming diff smaller.

Besides, we no longer check disabled extensions, as we don't expect users to
tweak extension config by themselves.

Reviewed By: sfilipco

Differential Revision: D16733273

fbshipit-source-id: b39bd4b2af6f315273484ec582094609b8e331ae
2019-08-19 19:27:28 -07:00
Jun Wu
37b7928dc8 help: resolve aliases using Rust
Summary:
Resolve aliases directly in command help. This removes the dependency of the
Python alias handling.

There are some minor behavior changes. But they look reasonable.

Reviewed By: sfilipco

Differential Revision: D16733276

fbshipit-source-id: ad97def2c60828236bbd8784ffd8202abfdeeb15
2019-08-19 19:27:28 -07:00
Jun Wu
38a0a8ff95 dispatch: translate shell aliases to hg commands
Summary:
Translate alias like `echo = !echo foo` to `echo = debugrunshell '--cmd=echo
foo'`.  This enables the Rust shell alias handling code path. The Python
shell alias handling was removed.

The majority part of `test-alias.t` still passes. That includes some "weird"
shell alias features.

This has some test changes, through:

- `$HG_ARGS` is no longer supported. And tests depending on it are changed.
  `$@` will be the alternative for most cases.
  Practically, our `$HG_ARGS` users seem to come from
  https://stackoverflow.com/a/833387, which does not seem to use `$HG_ARGS`
  correctly (since `$HG_ARGS` includes the command name).
- Early-parse commands (ex. `hg log -b '--config=alias.log=!echo
  howdy'`) no longer works.
- The warning `--repository ignored` now shows up, since `debugrunshell`
  is a "no-repo" command.
- Global flags can no longer be used after shell aliases. Supporting them
  is a head-ache.
- `circular alias` error message changed because it's now reported by the Rust
  code, which does not report all alias names right now.

Reviewed By: sfilipco

Differential Revision: D16733266

fbshipit-source-id: b06bc7f8fc2f1c2701a17407d6a1656e17e4ba55
2019-08-19 19:27:28 -07:00
Jun Wu
53e9fbd706 test-alias: make shell alias tests easier to read
Summary:
The shell alias tests are hard to read because:

- It uses `cat << EOF`, which will escape the heredoc block.
- It uses `sh -c`, which adds another layer.

Change `EOF` to `'EOF'` to prevent escaping heredoc, and remove `sh -c` to make
the test easier to read. The `escaped3` test now works as expected.

Reviewed By: sfilipco

Differential Revision: D16819451

fbshipit-source-id: 687e9ce78dfed7d76b53cf90e6d871dffd3ab84d
2019-08-19 19:27:28 -07:00
Jun Wu
399556389a commands: add a way to run shell commands
Summary: This will make shell aliases fit in the normal hg command framework.

Reviewed By: sfilipco

Differential Revision: D16530521

fbshipit-source-id: c1b158bc2895add03fa92099564830e55e02f1b7
2019-08-19 19:27:27 -07:00
Stefan Filip
c527354cc8 help: fix test-check-help.t to recognize fold
Summary:
The latest update in the documentation references the `hg fold` subcommand
from the "core" mercurial files. This makes the `test-check-help.t` test
want to verify the `help` for `fold`. The problem is that the test does not
enable the `amend` extension that provides the fold command.

Following a previous fix to this test, I am enabling the amend extension for
the test. It makes sense to me given the current setup.

Reviewed By: singhsrb

Differential Revision: D16907781

fbshipit-source-id: b0ba31518b6d4c210eb5b8cc7985a945ab1180e4
2019-08-19 16:59:05 -07:00
Saurabh Singh
76b785da63 hgsubversion: fix the tests
Summary:
Essentially the commit hashes changed and thats fine. See D16836997
for more context.

Reviewed By: quark-zju

Differential Revision: D16860590

fbshipit-source-id: ddd82dfbcdfbea9d5ace68adaedeb05bda6e3d7a
2019-08-16 13:27:04 -07:00
Mark Thomas
43bc04968a commitcloud: backup and sync all non-public commits
Summary:
Commit cloud and infinitepush currently only back up draft commits, omitting
secret ones.  However, commit cloud sync with visibility enabled will try to
sync all visible commits, including the secret ones.  This means users with
secret commits won't be able to sync them to their other machines as they won't
have been backed up.

We eventually want to get rid of the secret phase, which means all non-public
commits should be synced.  Update commit cloud to backup and sync all
non-public commits, including secret ones.

Currently secret commits become draft when they are received by the other
machine.  Since we're planning to get rid of the secret phase, this should be
fine.

Reviewed By: mitrandir77

Differential Revision: D16830832

fbshipit-source-id: 2ce4447ffa750a2edcb194cdf92321c1393ff805
2019-08-16 10:24:44 -07:00
Aleksei Kulikov
0f11c07409 snapshot: fix windows tests and make hashes deterministic
Summary:
So far the hashes of manifest/commits may vary, mostly because of
different path separators on different platforms (`/` vs `\\`) and its serialization to string in the snapshot manifest.

Reviewed By: markbt

Differential Revision: D16856130

fbshipit-source-id: a19dff113b9b24f1c7f387b9bc5a5e39e83ef8af
2019-08-16 10:15:05 -07:00
Shu-Ting Tseng
150798aac8 translate from hg to git hash should use the extras
Summary:
Now that we are writing the git hash inside the commit itself, if we are translating
from hg to git hash, we should just use that rather than loading the entire map and
build a dict and look it up.

The performance of this translation will also improve quite a lot.

Some small sample benchmarking:

```
suiting@devvm5006:configerator  (659199b|remote/master)$ time ~/fbcode/scm/hg/hg log -r master -T '{node} || {gitnode}\n' --config exte
nsions.fbconduit=! --config extensions.hggit=
659199bf7c7850ea9ffa9e0ad50eb84597977dea || 69f05aeec13f09c44dd00d2a85fe9d461ba6841e

real    0m0.563s
user    0m0.004s
sys     0m0.007s
suiting@devvm5006:configerator  (659199b|remote/master)$ time ~/fbcode/scm/hg/hg log -r master -T '{node} || {gitnode}\n'
659199bf7c7850ea9ffa9e0ad50eb84597977dea || 69f05aeec13f09c44dd00d2a85fe9d461ba6841e

real    0m14.706s
user    0m0.006s
sys     0m0.006s
```

Reviewed By: quark-zju

Differential Revision: D16833526

fbshipit-source-id: 7d3096649cf24967d13596e70463bc125081ba4f
2019-08-16 07:09:31 -07:00
Carolyn Busch
09ceebfcac Debugstore command
Summary: New degbugstore command prints contents of blob in store give filenname and hash.

Reviewed By: xavierd

Differential Revision: D16791780

fbshipit-source-id: d4529f3f368677b4f65a5772f82a1655552fefa5
2019-08-15 19:36:31 -07:00
Xavier Deguillard
8a27f4d915 tests: fix hgsubversion tests
Summary:
Since D16681230, a commit made with no file changes will re-use it's parent
manifest. This can trigger the commit hash to be different, which broke some
subversion tests. Since hgsubversion will be going away soon, I took the
approach of using run-tests.py -i and in test-hgsubversion-custom-layout.py to
not run the test that fails.

Reviewed By: sfilipco

Differential Revision: D16836997

fbshipit-source-id: 58e50a9147c8c263fca74158af120ec8ec5d8c52
2019-08-15 15:47:49 -07:00
Jun Wu
8b4c670550 changelog: get access to config options
Summary: Pass `uiconfig` to changelog so it can read config options.

Reviewed By: sfilipco

Differential Revision: D16683785

fbshipit-source-id: a64cfbe2cefa6b20ec695d2766bcfe878c764323
2019-08-15 12:47:35 -07:00
Jun Wu
6d7c287ab2 ui: split config handling to a separate class
Summary:
A large portion of `ui` is config handling. Split it to a separate class so we
can pass that separate class to places that need pure configuration.

Some `develwarn`s are skipped since the new class does not have access to fout
or ferr.

Reviewed By: DurhamG

Differential Revision: D16683787

fbshipit-source-id: d823b9e5fc6f8ed08fff3401ab3502ad3c434f00
2019-08-15 12:47:35 -07:00
Adam Simpkins
ce3bf61c80 fix copyright headers in a few files
Summary: Fix copyright headers to pass our lint rules.

Reviewed By: xavierd

Differential Revision: D16824227

fbshipit-source-id: f9bc74f42e2c9d5c112f527eec479da9e1ce56fb
2019-08-15 11:33:07 -07:00
Aleksei Kulikov
ad771fcaec snapshot: minor codestyle fixes
Summary: Minor changes.

Reviewed By: mitrandir77

Differential Revision: D16829944

fbshipit-source-id: 08876408bab9a367b852e85e1d7ca86dc0da08a3
2019-08-15 10:48:42 -07:00
Aleksei Kulikov
97c6c6ddaf snapshot: add debugcheckoutsnapshot command
Summary:
Allow the user to check out on the snapshot by its revision id.
Snapshot == "a commit with extra containing a key `snapshotmanifestid`".
This corresponding value can be `None`, that would mean that snapshot does not contain untracked/missing/merge files.

Reviewed By: mitrandir77

Differential Revision: D16788479

fbshipit-source-id: bf4a9508acc940290b18123d3dd7b7fefae83782
2019-08-15 10:48:41 -07:00
Aleksei Kulikov
b45ba7a551 snapshot: add --force option to manifest checkout
Summary:
Now `hg debugcheckoutsnapshotmanifest` overwrites files if given the `--force` flag.
It also gives a more detailed output on the changes it makes.

Reviewed By: mitrandir77

Differential Revision: D16786334

fbshipit-source-id: b41d6241ffb478bd6c30a01c154b095d1ea92d78
2019-08-15 10:48:41 -07:00
Aleksei Kulikov
169465460a snapshot: add debugsnapshot command
Summary:
Add the `debugsnapshot` command, which will be renamed to `snapshot` later.

It creates a snapshot manifest that features information about
* untracked files,
* missing files,
* merge state artifacts from `.hg/merge` and `.hg/rebasestate`.
The snapshot manifest is stored in local lfs.

Then it creates the actual snapshot -- a fake commit, which has the snapshot oid in extra data.
It does not handle unresolved merge conflicts and other difficult states on this stage.

~~Finally, it restores the working copy and dirstate to status quo.~~
It doesn't need to be done, now we create only the commitctx, which does not wreck the dirstate.

Reviewed By: mitrandir77

Differential Revision: D16716359

fbshipit-source-id: 743f7427ce89c3fca6f844487bac1c456338e613
2019-08-15 10:48:41 -07:00
Mohammad Ayoub
075801c976 sync checkout locations on update
Summary:
Whenever a checkout is done, the new commit is sent to commitcloud.
This currently works with the hook on update, but the hooks on commit are not working

Reviewed By: mitrandir77

Differential Revision: D16687423

fbshipit-source-id: a0b861d301c84764f31787454cdec594b0519fa3
2019-08-15 08:37:14 -07:00
Stefan Filip
85d53547a3 remove: fix root path ("") exception handling
Summary:
Remove has special handling for the root path which wasn't updated when we
updated the root path representation from "." to "".

Reviewed By: singhsrb

Differential Revision: D16794418

fbshipit-source-id: bb769ce67128041c01010fa2d256c1db5091c564
2019-08-13 18:53:11 -07:00
Xavier Deguillard
33feafa95a localrepo: properly handle no manifest changes
Summary:
We've had a couple of users reporting Rust panics due to an history entry where
its node is also its own parent. The most recent report shows that during a rebase
the commit context contained a removed file while the file itself isn't present
in either parents.

Several fix for this were considered but abandoned, leaving us with a simple
workaround the issue.

Reviewed By: quark-zju

Differential Revision: D16681230

fbshipit-source-id: d5305477792b4450475137d304fe7b22dc0977af
2019-08-13 13:48:26 -07:00
Xavier Deguillard
3f21c278d4 remotefilelog: Rust repack is the default
Summary:
This option has been on for several months now, let's enable it by default in
the tests too. Since the behavior is slightly different, the tests had to be
adjusted:
  - The packfile hashes are different due to a different repack algorithm,
  - test-fb-hgext-remotefilelog-gcrepack.t removed due to gc not being a thing
    with the Rust repack,
  - test-fb-hgext-remotefilelog-repack-corrupt.t corrupt packs aren't detected
    and removed at repack time, but later,
  - test-fb-hgext-remotefilelog-repack.t we no longer re-delta context in the
    Rust repack

Reviewed By: quark-zju

Differential Revision: D16774858

fbshipit-source-id: 7b7a3d96598c1ded0f64237047c3d97510050e4a
2019-08-13 10:50:02 -07:00
Stefan Filip
07545bd75e util: make util.dirs() and util.finddirs() include root directory (API)
Summary:
Change originally made by martinvonz in the mercurial repository:
https://phab.mercurial-scm.org/D6403

> This changes the behavior of test-origbackup-conflict.t so it no
longer errors out when the backup path points to an existing
file. Instead, it replaces the file by a directory. That seems
reasonable to me.

Reviewed By: quark-zju

Differential Revision: D16716742

fbshipit-source-id: b40ff1637fa75ea0c140cb861999d2cea83197cb
2019-08-12 14:34:36 -07:00
Stefan Filip
e985cb2472 match: use "" instead of "." for root directory (API)
Summary:
Change originally made by martinvonz in the mercurial repository:
Backporting https://phab.mercurial-scm.org/D6401

> I think '' is generally a better value for the root directory than '.'
is. For example, os.path.join('', 'foo') => 'foo', while
os.path.join('.', 'foo') => './foo'.
This patch mostly makes it so we use '' internally in
match.py. However, it also affects the API in visitdir(),
visitchildrenset() and files(). The two former now also accept '' as
input. I've updated the callers of these methods. I've also added a
deprecation warning for passing '.' (for external callers). The only
caller I could find that was affected by files() returning '' instead
of '.' was in dirstate.walk(). I've updated that.
The next few patches show some workarounds we can remove by using ''
instead of '.'.

Reviewed By: quark-zju

Differential Revision: D16716743

fbshipit-source-id: 4cc18b8cdf2f8a9dc44c42729fb46796a16c3244
2019-08-12 14:34:36 -07:00
Aleksei Kulikov
98ae814cd0 snapshot: add merge/rebase data to snapshot
Summary:
This diff adds handling of mergestate and rebasestate -related data from the `.hg` directory.
That is the whole `.hg/merge` folder (both for merge and rebase state) and the `.hg/rebasestate` file.

We do not store any other information in lfs (e.g. number of parents for merge state).
Snapshot manifest oid will be added as an extra field to a fake snapshot commit, which will contain such data.

Differential Revision: D16708733

fbshipit-source-id: efc9b72b7593d85063307528c713c363e061065b
2019-08-12 03:51:58 -07:00
Jun Wu
0cced641f0 statichttprepo: remove statichttprepo
Summary:
We don't use statichttprepo. Remove it so future changelog changes won't need
to take it into consideration.

Reviewed By: markbt

Differential Revision: D16683789

fbshipit-source-id: de4f486e8eb6d372acfab5053769f7ad91c12db8
2019-08-09 16:17:54 -07:00
Jun Wu
168402664c unionrepo: remove unionrepo
Summary:
We don't use unionrepo. Remove it so future changelog changes won't need to
take it into consideration.

Reviewed By: markbt

Differential Revision: D16683788

fbshipit-source-id: bfc474d51d957959a6266e9c8eceda3c11d3cf0d
2019-08-09 16:17:54 -07:00
Jun Wu
330516f923 dagparser: add a binary dag serialization format
Summary:
The binary format allows us to checkin a large repo's dag and use it for
testing. The format is designed to be compat and easy for machine parsing.

`hg debugbindag` was added to generate such format from an existing repo,
and `hg debugpreviewbindag` was added to preview such binary format.

Size of serialized DAGs:

  repo     | method      | size (KB) | size (KB), zstd -19
  --------------------------------------------------------
  mozilla  | debugbindag |    101    |    66
           | debugdag    |    193    |    72
           | changelog.i | 213925    | 80118
  --------------------------------------------------------
  fbsource | debugbindag |   1400    |   700
           | debugdag    |    n/a *  |   n/a
  --------------------------------------------------------
  www      | debugbindag |    5.6    |   3.2
           | debugdag    |    n/a    |   n/a

Note:
`hg debugdag` and `hg debugbuilddag` exist, and they compress
relatively well. However, they have some (critical) issues:

- crashes on fbsource and www (*)
- complex syntax
- does not support selecting a subset of revs (ex. "::master")

Therefore I decided to invent something new.

Reviewed By: sfilipco

Differential Revision: D16294467

fbshipit-source-id: 754ab8942359ef73f5f53c427c7d38d94641fa75
2019-08-09 16:17:49 -07:00
Xavier Deguillard
405ca2d5e8 bindings: remove datastore
Summary:
This class can be used to use a Python store in Python but going through Rust.
We don't need this use case, so let's get rid of it.

Reviewed By: quark-zju

Differential Revision: D16726162

fbshipit-source-id: a0121bf61b178447ad958e2907185e97962046ee
2019-08-09 10:19:19 -07:00
Xavier Deguillard
d7399a765f tests: set tweakdefaults.rebasekeepdate to True
Summary: Rebase tests can be unpredictible otherwise.

Reviewed By: farnz

Differential Revision: D16701186

fbshipit-source-id: 3c7af531c27ada15ace16c616799e0f569e285a2
2019-08-08 10:22:21 -07:00
Aleksei Kulikov
1bb26d4ad2 snapshot: refactor extension code
Summary:
Created some classes and refactored the code.
Now it looks better. :)

Reviewed By: markbt

Differential Revision: D16690240

fbshipit-source-id: f26127d55c5cace7b88e225c85ec13cc278150c8
2019-08-08 04:13:39 -07:00
Aleksei Kulikov
6b7127c966 snapshot: add debug command to checkout on snapshot manifest
Summary:
It would really help to be able to checkout the manifests, restoring all the data from them.
Deleting the missing files, creating the unknown files, adding mergestate info to svfs (not available yet :) ).

Reviewed By: mitrandir77

Differential Revision: D16668312

fbshipit-source-id: 62af8a1fb11541c162f7b5ceb8d6d058cad9a319
2019-08-08 04:13:38 -07:00
Mark Thomas
6a6c0fea7a commitcloud: add automigrate to automatically connect to commitcloud
Summary:
Add automigrate to commitcloud, which will automatically connect the user's
repo to commit cloud on pull.

Reviewed By: mitrandir77

Differential Revision: D16666810

fbshipit-source-id: a1d0857164d2ce6bf1db5784360681f04d35ed90
2019-08-08 03:09:24 -07:00
Mark Thomas
2e3cda1ade commitcloud: cloud leave should always clear the workspace name
Summary:
Running `hg cloud leave` on a repo that was never connected should mark the
repo as explicitly disconnected so that automatic joining will not try to
connect the repo later on.

Reviewed By: quark-zju

Differential Revision: D16687470

fbshipit-source-id: 0552ffa42a1dac40874bba30eeb93509a2227aeb
2019-08-08 03:09:24 -07:00
Mark Thomas
be096ab1c6 commitcloud: make cloud rejoin always join if possible
Summary:
`hg cloud rejoin` limits joining to when the user has an authentication token
and the workspace already exists.  If the user uses a different authentication
method, or if the workspace is brand new, the rejoin does nothing.

Change this to always attempting to join, and only printing a message if the
join failed because of an authentication error, prompting the user to authenticate.

Reviewed By: mitrandir77

Differential Revision: D16666365

fbshipit-source-id: 3ea4542125a1b5266711fab2c31d9455ab764cef
2019-08-08 03:09:23 -07:00
Mark Thomas
80819cbf5b debugexistingcasecollisions: add command to check for existing case collisions
Summary:
Add a new command `hg debugexistingcasecollisions` which checks if any
directories contains two or more entries which may have the same filename on
case-insensitive filesystem.

Reviewed By: suitingtseng

Differential Revision: D16687557

fbshipit-source-id: cb032467e9b8a73fc1f6bf107387bc54c223c2ba
2019-08-08 03:01:44 -07:00
Aleksei Kulikov
cf0570d74a snapshot: add a command to upload snapshot manifest to remote lfs
Summary:
Add the `debuguploadsnapshotmanifest oid` command.

It checks that the local lfs has `oid`, then uploads it and all the related blobs to remote lfs.

Differential Revision: D16667158

fbshipit-source-id: 2978a6c0e7c58c3710f8253cf7b9ab36b24886ce
2019-08-07 05:57:45 -07:00
Aleksei Kulikov
cbf11e8ca8 snapshot: add command debugcreatesnapshotmanifest
Summary:
Add a self-descriptive command `debugcreatesnapshotmanifest`.
For now it supports only deleted and unknown files.

1) Uploads all the untracked files to the local lfs storage.
2) Creates a json-like snapshot with the following structure:
```
{
  "deleted": {
    "path/to/file": None, # this is done for consistency
    "path/to/another/file": None
  },
  "unknown": {
    "added": {
        "oid": "oid in local blobstore",
        "size": 42
    }
    "another/added": {
        "oid": "another oid in local blobstore",
        "size": 24
    }
  }
}
```
...and stores it in the local blobstore.

Reviewed By: markbt

Differential Revision: D16621864

fbshipit-source-id: 6c497d1bb756561b3c3368483b838a2307b0b5f9
2019-08-05 11:10:17 -07:00
Shu-Ting Tseng
bbc6d19715 use manifest lookup to speed up operations
Summary:
The original code path is extremely slow because it has to iterate all files in manifest.
The new path instead only has to lookup the entries in keptdirs and therefore is O(change).

Reviewed By: mitrandir77

Differential Revision: D16646075

fbshipit-source-id: cb2c152d236ffa6f01349c223c9470205c540379
2019-08-05 05:22:40 -07:00
Jun Wu
cadeb66132 testutil/dott: translate piped commands correctly
Summary: Previously, `|` was treated as an argument of a command. Fix it.

Reviewed By: singhsrb

Differential Revision: D16473729

fbshipit-source-id: 0c9a76cd01fc3a22bd43cd0b7d96ce9c6e61ce37
2019-08-02 17:04:00 -07:00
Jun Wu
30dfd6217b bindings: add bindings to stackdesc
Summary:
This exposes the stackdesc feature to Python. The API is polished to use Python
decorators.

Reviewed By: sfilipco

Differential Revision: D16023307

fbshipit-source-id: edcee59e77e7fe55cdb52d031a4fa3e483909ea0
2019-08-01 19:53:56 -07:00
Jun Wu
a3a7a6c860 testutil/dott: add a test about the translator
Summary: The test lists noticable features provided by the translator.

Reviewed By: xavierd

Differential Revision: D16473727

fbshipit-source-id: 617296886243a77b2af8e26d4ea576e63ff88fd3
2019-08-01 17:59:20 -07:00
Jun Wu
6253e8a50e testutil/dott: make translate use posix shell quote
Summary:
`util.shellquote` is platform-dependent. In case of the translator, it always
uses `shlex.split`. Therefore the posix shell quote should be used.

This makes the the test stable across multiple platforms. Namely, `"` is not
used on Windows.

Reviewed By: xavierd

Differential Revision: D16606904

fbshipit-source-id: 879e06b54fc427a6ad1aa959927a0df52f33269a
2019-08-01 17:59:20 -07:00
Jun Wu
5e701ebdaf testutil/dott: fix parsecmd
Summary:
`parsecmd` uses `for name in dictobj`, which can get different results due to
different random seed being used. Use an explicit list instead to avoid the issue.

Reviewed By: xavierd

Differential Revision: D16596261

fbshipit-source-id: c81665cb550a0ce76885aa7f3caee959d63f7b67
2019-08-01 17:59:20 -07:00
Jun Wu
5f1e0890a0 testutil/dott: split the translate function
Summary:
This makes it possible to test the translate behavior without writing anything
to filesystem.

Reviewed By: xavierd

Differential Revision: D16473728

fbshipit-source-id: 3c07b2b5e41d40444b98e7f02de840d2105082fe
2019-08-01 17:59:19 -07:00
Stefan Filip
71bff70aea manifest: rename filesnotin argument from match to matcher
Summary:
Similar to diff, the `match` argument can't be easily expressed using CPython
crate bindings. This argument is not used a lot so we can rename it.

Reviewed By: quark-zju

Differential Revision: D16571840

fbshipit-source-id: 19c7dea82924b7ec4c0b66d1675b9ad4569f8b62
2019-08-01 10:35:53 -07:00
Mohammad Ayoub
c3bb7153e0 change cloud sl --version_number to --workspace-version
Summary: Change --version_number flag to --workspace-version

Reviewed By: quark-zju

Differential Revision: D16561670

fbshipit-source-id: 797a7b2fee2c3e260263ae3029d793452def3033
2019-08-01 02:18:05 -07:00
Stefan Filip
71ab0b4b3d manifest: rename match to matcher in diff argument list
Summary:
`match` is a keyword in Rust. This is causing troubles in adding Rust bindings
for functions that use that as a keyword argument. Renaming the argument to
something else seems to be the easiest path forward.

Reviewed By: quark-zju

Differential Revision: D16496134

fbshipit-source-id: c923f49577564527a99d43dda3d3d9da43122b3e
2019-07-31 10:06:48 -07:00
Stefan Filip
5d1f390ca0 manifest: remove the clean argument from diff
Summary:
The diff algorithm takes the `clean` flag. When `clean` is used all the files
that are not changed between the two manifests are returned. In short the set
of files is equal to |files(M1) U files(M2)|.

This functionality would have to be implemented in the Rust manifest. I don't
feel that a flag on the diff algorithm should be used in this case. First, I
don't like how it interacts with the core diff algorithm, it changes it to the
point where it feel like it should be a different function. Second is that this
behavior can be achieved by getting all the files in the manifest and removing
the items in the diff. Third is that this operation is done quite rarely, being
so expensive.

The downside is that the places where this flag is used get a bit more
expensive.

Reviewed By: quark-zju

Differential Revision: D16496136

fbshipit-source-id: 205dcc23517b896de5c14634683bcbd5f2aa6666
2019-07-31 10:06:47 -07:00
Shu-Ting Tseng
acec61a376 hg svn info should print globalrev
Summary:
This is used by Jellyfish and sent to Phabricator. In the future, we won't have svnrev
and therefore we should use globalrev instead.

More context: https://fb.workplace.com/groups/248282915800791/permalink/372855146676900/

Reviewed By: singhsrb

Differential Revision: D16561651

fbshipit-source-id: 284ad26b1bf77f222086bb7e2104b1c2dbf65449
2019-07-31 09:16:23 -07:00
Shu-Ting Tseng
01394c9202 hg debugcrdump should also use globalrev
Summary:
This command uses svnrev directly. However once we migrate to www-hg, this fields will
go and we can only use globalrev instead.

Let's add that and put it behind a config.

More context: https://fb.workplace.com/groups/248282915800791/permalink/372855146676900/

Differential Revision: D16560447

fbshipit-source-id: de3100ed1e6cc39eaaeff2fe11af04d2f1e2c41a
2019-07-31 09:16:23 -07:00
Mateusz Kwapich
bfc5ee0878 fix O(workingcopy) hg amend <file> behaviour
Summary:
context: Mercurial is slow for peoople that can't use watchman and eden https://fb.workplace.com/groups/scm/permalink/2133433800039562/

Please let me know if this approach (hacking the wctx) is acceptable in your
opinion

Reviewed By: quark-zju

Differential Revision: D15668362

fbshipit-source-id: a94f39be2d845e751a8bb69ca8ca000ef46d9d2d
2019-07-31 08:48:20 -07:00
Jun Wu
bd75a8e099 cliparser: fix regression on error message
Summary:
Fix the regression caused by D16557266 on error message. The fix is not the
most efficient, though. But it should restore the behavior.

Reviewed By: singhsrb

Differential Revision: D16557654

fbshipit-source-id: 2eb6956f99c931f94201b875c8bebb2219a794f0
2019-07-30 08:43:39 -07:00
Mateusz Kwapich
6b7f8fe167 autoformat all of fbcode/scm with black
Summary: blackpylogo

Reviewed By: krallin

Differential Revision: D16543521

fbshipit-source-id: 75977d00329e1068a92a344c99e0ad0392601c54
2019-07-30 08:21:05 -07:00
Jun Wu
bf5047760d test-alias: update test showing a regression
Summary:
The last diff D16557266 caused a regression on the error message. Update the
test to show that.

Reviewed By: singhsrb

Differential Revision: D16557653

fbshipit-source-id: ce4a039f4c91a7bd61ea8e570de960880abae937
2019-07-30 01:10:33 -07:00
Jun Wu
5c24ff642e cliparser: special handle debug commands
Summary:
When doing command name prefix match, if there are a unique match for non-debug
commands, use it. This solves `hg d` regression.

Note: we cannot simply use `starts_with("debug")` to test debug commands. That
is because debug commands can have aliases (ex. `debug|dbsh` as the command
name definition, and `dbsh` is also a debug command that does not starts with
`debug`). Therefore it gets a bit complex.

Reviewed By: kulshrax

Differential Revision: D16557266

fbshipit-source-id: 42d814940c9217d9e554bd0fe2769a53e0ee467f
2019-07-29 19:35:32 -07:00
Jun Wu
28a78e89a5 tests: add a test showing "hg d" regression
Summary: `hg d` should not match debug commands.

Reviewed By: kulshrax

Differential Revision: D16557267

fbshipit-source-id: d7936ab530fce4e302b7e410f8abbe619898e941
2019-07-29 19:35:32 -07:00
Jun Wu
d878cea953 dispatch: expand aliases correctly
Summary:
Use the "first argument position" reported by the parsing library to expand the
command name correctly.

Before this patch:

    --repo foo foo
           ^^^ this foo gets expanded (incorrectly)

After this patch:

    --repo foo foo
               ^^^ this foo gets expanded

Reviewed By: kulshrax

Differential Revision: D16556869

fbshipit-source-id: 8eca98d80cdd8f0d3d329040d6f2eb81653db99f
2019-07-29 19:35:31 -07:00
Jun Wu
12968fc5b5 test-alias: add a test showing incorrect behavior
Summary:
Patterns like `--globalopt name name` could confuse the current logic. Add test
cases for it.

Reviewed By: kulshrax

Differential Revision: D16553454

fbshipit-source-id: dac5fd1a9f98093d13dbd85794e3b455c17dcf64
2019-07-29 19:35:30 -07:00
Jun Wu
72e3fc1d9a cliparser: simplify expand_aliases a bit
Summary:
The loop body can be changed to reduce some identation.

This changes the behavior a bit - an alias expanding to an emtpy string is now
an error. That's consistent with the original behavior.

Reviewed By: kulshrax

Differential Revision: D16530516

fbshipit-source-id: 3f5c2ebe9d8d1727cac706e4ff11f2678567c525
2019-07-29 19:35:28 -07:00
Jun Wu
5dd0629478 cliparser: add an error type about illegal alias
Summary:
When the alias cannot be split via shlex::split, raise an error directly
instead of silently ignoring it and fallback to Python error handling.

Reviewed By: kulshrax

Differential Revision: D16530519

fbshipit-source-id: d81534b198555b256f062dc4e6520fa40ace7700
2019-07-29 19:35:28 -07:00
Saurabh Singh
459d04df3f hgsubversion: allow disabling the svnrev template keyword
Reviewed By: quark-zju

Differential Revision: D16546466

fbshipit-source-id: d3d3005b250856d2e93fbd52f178e9cd8bdf6ef2
2019-07-29 13:29:39 -07:00
Jared Bosco
01465ad1d5 hgmain: replace hg root entirely with a native implementation
Summary: Replace original Python `hg root` implementation with Rust `hg root` implemented with the new command line dispatch library.

Reviewed By: quark-zju

Differential Revision: D16497604

fbshipit-source-id: e3d0e60d4bd4203897260c16e070ca3768ff1d22
2019-07-26 20:38:50 -07:00
Jared Bosco
6bf5f920ee hgmain: implement native hg root command with new dispatch library
Summary:
Implement `hg root` in Rust with the `clidispatch` library as well as adding all current Python commands so that prefix matching still works as expected.

This diff does not remove `hg root` from Python or expose native command documentation to Python, which will be the next diff.

Reviewed By: quark-zju

Differential Revision: D16454053

fbshipit-source-id: 78a9c70aeefb9adbb85c77001b15eab652417b2c
2019-07-26 20:38:50 -07:00
Mateusz Kwapich
5ce2387e15 fix the problem with flags starting from --no
Summary:
When we had a "--no-something" flag registered providing "--something"
did the same thing as providing "--no-something" which is highly undesirable
(see task)

Reviewed By: quark-zju

Differential Revision: D16520376

fbshipit-source-id: 9d407b830067d095abdbd9c0cee674f424ffc0f9
2019-07-26 14:13:11 -07:00
Mateusz Kwapich
073fcf2078 show the problem with handling args prefixed with 'no-'
Summary: context: T47908435

Reviewed By: quark-zju

Differential Revision: D16519889

fbshipit-source-id: 952df74f381af2c527cecabe0cd804e7a51bed10
2019-07-26 14:13:11 -07:00
Shu-Ting Tseng
8419106c36 fix flaky tests from hgsubversion
Summary:
The shenanigan was introduced in D16337012 where I tried to reuse pushrevisionwithconfigs.

I am breaking the chain now as it's tooooo hard to reuse and we've spent 4-5 diffs on this now.

Reviewed By: xavierd

Differential Revision: D16520271

fbshipit-source-id: 94cf8580cf3b852ecf7897861893bb51ce03d564
2019-07-26 13:30:12 -07:00
Xavier Deguillard
efad0cf903 cstore: remove py-cdatapack
Summary:
With fastdatapack gone, the cdatapack bindings are no longer necessary and can
be removed.

Reviewed By: singhsrb

Differential Revision: D16476584

fbshipit-source-id: 130a9c5aed4e4f005876c420961f09d398f6e6aa
2019-07-26 10:35:46 -07:00
Xavier Deguillard
f36d8a8fe1 remotefilelog: remove basepack
Summary: This is no longer used anywhere, we can remove it.

Reviewed By: singhsrb

Differential Revision: D16476582

fbshipit-source-id: fe6a8f33cbc3c37fb1d8fb33226352e41bcbaa2a
2019-07-26 10:35:46 -07:00
Xavier Deguillard
28d7ef620b remotefilelog: remove fastdatapack
Summary: This code isn't used anywhere, let's get rid of it.

Reviewed By: singhsrb

Differential Revision: D16476583

fbshipit-source-id: d42376dbb2cf631a170ade3e2764d1f70922d882
2019-07-26 10:35:45 -07:00
Aleksei Kulikov
59bb951024 amend: make next prefer draft commits
Summary: Add an option `update.nextpreferdraft` that makes `hg next` prefer single draft child commits.

Reviewed By: markbt

Differential Revision: D16500162

fbshipit-source-id: 3a20bb487d35b7acf92792e9a7b7424c9b163b64
2019-07-26 10:00:07 -07:00
Shu-Ting Tseng
86bdaeb464 make pushes faster in our reverse sync case
Summary:
Our reverse sync job is too slow when pushing to svn. It seems like the slowness comes
keep doing push-pull-rebase which doesn't seem necessary in our case.

From my understanding, we need to do push-pull-rebase because we have multiple writers.
In our sync job, we only have one writer and therefore can we skip the pulls and rebases?

Reviewed By: DurhamG

Differential Revision: D16442559

fbshipit-source-id: 926d1c516e8e6d59298d310fc67927ace37f72c9
2019-07-26 07:21:37 -07:00