Commit Graph

437 Commits

Author SHA1 Message Date
Mark Thomas
36c697f8e0 help: new default help
Summary:
Replace the default help for Mercurial with a curated list of interesting
commands, categorized by their use case.

Reviewed By: phillco

Differential Revision: D10356916

fbshipit-source-id: 65e578a4bfde7b0ad04e7107f4e77d8ea882d78a
2018-10-15 09:37:18 -07:00
Chad Austin
596b412cff record: remove another reference to the record module
Summary:
The Eden prefetch test started failing after D10360759 landed. Remove
another reference to the record module.

Reviewed By: simpkins

Differential Revision: D10368263

fbshipit-source-id: 1a781ebe09cb9d77c59be72a5117ffd7e4bfe848
2018-10-12 16:32:19 -07:00
Saurabh Singh
cd49463e2c show: move the extension into core
Summary:
The extension only offers one command i.e. `show` which can move into
core.

Reviewed By: ikostia

Differential Revision: D10302192

fbshipit-source-id: 9473ec8c80e52506e1b7de62b2c90a51c29419c1
2018-10-12 07:03:11 -07:00
Saurabh Singh
d0d21c955f show: replace with the fbshow extension
Summary:
The functionality we care about is provided by the `fbshow` extension.
Therefore, lets replace the `show` extension with the `fbshow` extension.

Reviewed By: ikostia

Differential Revision: D10302193

fbshipit-source-id: e6d137f52427d5e6f124714d06b5b55ef0db7c3c
2018-10-12 07:03:11 -07:00
Kostia Balytskyi
7068d0d8fb shelve: move obsshelve into shelve and fix a bug
Summary:
The bug:
This happens because `repo['']` resolves to a `wctx`. This might be undesirable
in its own right, but before we fix that, we can work it around here.

Reviewed By: singhsrb

Differential Revision: D10261261

fbshipit-source-id: 8cb0e96762ffba24030f9e6bae8b0d0c108e3938
2018-10-12 06:30:04 -07:00
Saurabh Singh
6317ba0ca2 amend: replace with the fbamend extension
Summary:
The functionality we care about is provided by the `fbamend`
extension. Therefore, lets replace the `amend` extension with the `fbamend`
extension.

Reviewed By: farnz

Differential Revision: D10320739

fbshipit-source-id: 5700d39f488777fcc4033f60ce0a51cda15ef2ad
2018-10-11 06:59:23 -07:00
Saurabh Singh
f6e0d2d1ee inhibit: remove the extension
Summary:
The logic we care about has been moved to core so we can delete the
`inhibit` extension.

Reviewed By: markbt

Differential Revision: D10276448

fbshipit-source-id: 44cabe5d561344cf8f196127ce52491e4654b598
2018-10-10 10:01:45 -07:00
Mark Thomas
f47bd8c33d treestate: move treedirstate to core
Summary:
Parts of the treedirstate implementation were left in the extension.  Since
treestate is now in core, and the two are intertwined, treedirstate should be
in core, too.

In doing so:
- Change the garbage collection behaviour to match that of treestate.
- Use the treestate config options for configuring repacking and garbage
  collection.
- Make more of the code common.

Reviewed By: quark-zju

Differential Revision: D10258265

fbshipit-source-id: 89e82bc7662a3d1251fa9886751897cfc46cd66a
2018-10-10 03:53:20 -07:00
Mark Thomas
f353521eb9 revset: move age extension to core
Summary:
The age extension provides a couple of revsets relating to commit ages.  Move
these to core.

Differential Revision: D10239000

fbshipit-source-id: 6ebf3aa263b72e4bbbe25bd516f77b17145e6e7f
2018-10-08 12:01:44 -07:00
Mark Thomas
99b3d7c398 share: remove shareutil and _sharedprimaryrepo
Summary:
These are no longer necessary.  Callers should use the sharedvfs to access the
shared repo's .hg directory.

Reviewed By: quark-zju

Differential Revision: D9699163

fbshipit-source-id: 9b9cd584d721c174a7eab06f6abcedc3a943233b
2018-09-28 07:23:02 -07:00
Jun Wu
9fb16dc4ec profiling: remove redundant "enabled" argument from "profiling.profile"
Summary:
The `profiling.profile` method already takes a `ui` object which contains
information about whether to enable profiling or not. The `enabled` argument
is redundant. Remove it.

Reviewed By: singhsrb

Differential Revision: D9828553

fbshipit-source-id: 7face72aa23364ce7ca56feaf4f4ead95ef69bb9
2018-09-14 19:05:35 -07:00
Adam Simpkins
17bf9dd01b ensure that logging errors don't mask the original error
Summary:
D9363420 added code to perform extra logging of exceptions.  Unfortunately if
an error occurs inside the logging code (for instance, if it tries to log
binary data that cannot be json-encoded) it masks the original exception
message and backtrace with the logging exception.

This issue is specific to python 2.x.  Python 3.x reports both exception
backtraces in this case.  However, in python 2.x putting a `try...except`
block inside an `except` block ends up overwriting the original exception
info, even when the inner exception is handled.

Moving the inner `try...except` block to its own function is sufficient to
avoid this problem in python 2.x

Reviewed By: singhsrb

Differential Revision: D9764805

fbshipit-source-id: c5a9e65fcd7505ccb478500d62c06c2c94308332
2018-09-10 22:58:25 -07:00
Jun Wu
25eb53f3e7 alias: make resolution unaffected by definition order
Summary:
Previously, the alias resolution is affected by the alias definition order. So
things like:

  [alias]
  myglog = log -G
  myvlog = myglog -v

works. But

  [alias]
  myvlog = myglog -v
  myglog = log -G

doesn't. D8767902 changed ordering semantics and broke some people's aliases,
because if both `myvlog` and `myglog` are defined in system hgrc, their order
cannot be changed from a user hgrc.

Instead of having subtle behavior here depending on the order. Let's just do
not rely on the order. This diff makes it so, by resolving aliases using latest
(alias-if-possible) definitions, with only one special case: "foo = foo ..."
uses the original non-alias "foo" command.

The "alias ... shadows command ..." debug message was removed as it's
no longer accurate.

Reviewed By: simpkins

Differential Revision: D9417710

fbshipit-source-id: f4228eba3c8c728163a54bcf053c379fa86bd123
2018-08-21 12:06:18 -07:00
Phil Cohen
3d3d84bea3 dispatch: log raised exception messages and types with ui.log
Reviewed By: DurhamG

Differential Revision: D9363420

fbshipit-source-id: 08fe04b7a72bc14b8f3fccbe1c40ad15d896e5b4
2018-08-16 17:51:25 -07:00
Simon Farnsworth
03a6aad6f7 ui: remove machine-generated blocked tags
Summary: We initially split out lots of different causes of slowness into their own unique tags, so that we could identify the source of slowness. Now that we've identified all the big causes, wrap them all back up into summary categories - we can change back to detailed tags at callsites if we want to separate out phases.

Reviewed By: ikostia

Differential Revision: D8664314

fbshipit-source-id: 6e141382479ca044847db1611f885e08f24f986b
2018-06-29 05:34:00 -07:00
Adam Simpkins
1cba650b9e remove the dispatch entry point code
Summary:
This code is no longer needed now that the buck built binary uses the same
entry point as the setup.py built code.

Reviewed By: quark-zju

Differential Revision: D8675727

fbshipit-source-id: 1b3a44371453aa16c530f73b48611958082ee080
2018-06-28 13:05:23 -07:00
Kostia Balytskyi
54156ab809 windows: handle the broken pipe case cleanly
Summary:
The scenario we are handling is as follows:
1. the user runs a long-running Mercurial command with a lot of output, like
`hg log`
2. Mercurial runs pager, which is a subprocess, like `less` and changes its
stdout/stderr to point to pager's stdin.
3. The user exits from the pager (by pressing `q`, for example)
4. The pipe connecting Mercurial stdout/stderr with pager's stdin is now dead.
5. Mercurial tries to write something into its stdout, a failure occurs
6. The finally section restores stdout/stderr to be a tty
7. A failure gets caught up in the stack and printed to stderr, now a tty

A failure is vague here. On Linux, it means a `SIGPIPE`, on Windows, just and
exception that is manifested in Python as `IOError` with `errno=EINVAL`.

This is how Linux deals with it:
1. registed a signal handler for `SIGPIPE`, make this handler raise a
Mercurial-defined `error.SingalInterrupt`, which is a child exception class to
`KerboardInterrupt`
2. catch `KeyboardInterrupt` in `dispatch.dispatch`, handle the broken pipe
case there

For Windows this does not work, since there's no `SIGPIPE`, so
`SignalInterrupt` never gets raised, so we never handle the `IOError`.

This diff just explicitly handles the `IOError` in `dispatch.dispatch` and
silently consumes the `errno.EINVAL` case.

Reviewed By: quark-zju

Differential Revision: D8610555

fbshipit-source-id: 6cadba6a9ec296f03b1b616b763e56ec55da3a70
2018-06-26 10:50:49 -07:00
Mateusz Kwapich
b7bf572019 move hintutil.show after runcommand
Summary: This will allow us to trigger hints from functions that wrap runcommand itself.

Reviewed By: quark-zju

Differential Revision: D8591974

fbshipit-source-id: e8e4742d6728ca347b85d10adc2e2ab7ab06ef16
2018-06-25 07:34:11 -07:00
Jun Wu
56246aa66c dispatch: add a config option to control exit code
Summary:
Previously, hg returns -1 (255) on "unknown errors". That could conflict with
other things. For example, http://tldp.org/LDP/abs/html/exitcodes.html suggests
1, 2, 126 ... 255 have special meanings defined by a common shell.  Namely,
`ssh` also returns 255.

Another long complaints about hg exit code is the use of 1 to indicate
"no changes". Although that's explained at [1], a lot of scripts still find it
surprising.

This diff adds a `ui.exitcodemask` config option, which makes it to alter the
exit code. Set it to 254 will change 1 to 0 for some script use-cases. Set it
to 63 or so will avoid conflicts with software like `ssh`.

Many existing scripts still expect 255 to be the return code. So we cannot
change the default value that easily. To avoid surprises (like, put the config
option in `/etc/mercurial/hgrc.d/exitcode.rc`), the config set by config
files is ignored if `HGPLAIN` is set and `HGPLAINEXCEPT` does not contain
`exitcode`.

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2012-January/037711.html

Reviewed By: DurhamG

Differential Revision: D7921817

fbshipit-source-id: 764b0de030fc727aa5df7305c2b8bc92f576cd33
2018-06-13 16:14:01 -07:00
Jun Wu
e8c21b7691 template: add a way to support command-level template cleanly
Summary:
There mercurial template language is a powerful language. But it has some
limitations right now:

- It's focused on "commit". If there is no commit, things become harder.
- The related formatter concept is coupled with "a list of things". If there
  is no list, things become impossible.
- Some commands use formatter/template partially, and that does not play
  very well with `ui.write`, and is difficult to document.

This patch starts to solve all the issues, by introducing command-level
template state, and with the vision:

- Anything could be used as an "environment" passed to the template
  language, a commit, a file, a line, a "command" with customized
  properties, etc.
  - If a template keyword function is incompatible with the environment, it
    should fail gracefully.
- The template language is a super set of other things. `-Tjson` should not
  be magical, but an alias of `{some complex expression | json}`.
  - Discourage the use of formatter.
- Template keywords can be registered and documented.

This would remove the limitations of the template language and unleash its
full potential.

Note there are still some cases where the formatter is desirable. For example,
`hg log` with a large revset should be able to stream its output. The command
template feature added right now only renders things at the end of a command,
and is not (and requires significant effort to be) streaming-friendly.

Reviewed By: mitrandir77

Differential Revision: D8221078

fbshipit-source-id: 26fed50025c4676af277686382ce2d36f1faed97
2018-06-06 15:43:25 -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
Durham Goode
b0b561e2bd readonly: add more info to readonly 'Permission denied' errors
Summary:
We're seeing "Permission denied" errors on some of our automation, but
it's difficult to track down where it's coming from. Let's make each message
more descriptive.

Also updates, hgsql to handle the hg-rsh hook, which I noticed while
investigating.

Reviewed By: phillco, farnz

Differential Revision: D8188414

fbshipit-source-id: 5f8c99e8ba896c2636b1a04716125bc6a9df0591
2018-05-29 11:56:35 -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
Jun Wu
a6fcceea31 chg: make sure client and server have a matched version
Summary:
Generate a `u64` integer about the "version" at build time, and make chg
client check the version before connecting to the server.

This would ensure a chg client would only connect to a matched version of
the server.

- In setup.py, compute the "versionhash", write it as
  `mercurial.__version__.versionhash`.
- In dispatch.py, `mercurial.__version__` needs to be explicitly loaded
  before forking.
- In commandserver.py, send the versionhash to the client with the "hello"
  message.
- In chg.c, verify the versionhash. If it does not match, unlink the socket
  path and reconnect.

Reviewed By: farnz

Differential Revision: D7978131

fbshipit-source-id: 50acc923e72e40a4f66a96f01a194cf1a57fe832
2018-05-24 09:12:00 -07:00
Michael Bolin
a5e1820702 Split out a new hgevents extension from fsmonitor.
Summary:
This splits out the logic in the `fsmonitor` extension that is responsible for
publishing `hg.filemerge` and `hg.update` state changes to Watchman into
its own extension, `hgevents`. This is because we want the behavior of
`hgevents` when Hg is running in Eden, but we do not want the remaining
behavior of `fsmonitor` when Hg is running in Eden, so splitting the logic
into separate extensions is the most straightforward way to achieve that.

To achieve the split, we move some more logic that is common to both
`fsmonitor` and `hgevents` out of `hgext/fsmonitor/__init__.py` and into
`hgext/extlib/watchmanclient/__init__.py`. Then we move these lines
out of `extsetup()` in `fsmonitor` to create `extsetup()` in `hgevents`:

```
    extensions.wrapfunction(merge, 'update', wrapupdate)
    extensions.wrapfunction(filemerge, '_xmerge', _xmerge)
```

We also have to pull all of the transitive dependencies for this logic
into `hgevents`.

Finally, we also have to define a `reposetup()` function in `hgevents`
that does a subset of what `reposetup()` does in `fsmonitor`. Specifically,
it ensures that a Watchman client is created for a `repo`, as appropriate,
so that it can be used to dispatch state changes to Watchman in
`state_filemerge` and `state_update`.

Note that the utility functions `createclientforrepo()` and
`getclientforrepo()` have been added to ensure that only one
Watchman client is created (and shared) when both `fsmonitor`
and `hgevents` are enabled.

Today, when an Hg repo is created in Eden, we set `extensions.fsmonitor=!`
in the `.hg/hgrc`:

diffusion/FBS/browse/master/fbcode/eden/hooks/hg/post-clone.py$69

Therefore, to get existing repos (both Eden and non-Eden) to pick up
the `hgevents` extension automatically, we add it to the list of
`[extensions]` in `common.rc`:

diffusion/FBS/browse/master/fbcode/scm/hg/fb/staticfiles/etc/mercurial/repo-specific/common.rc$53-60

as this is where `fsmonitor` is configured. We do not enable it in
`scm/hg/fb/staticfiles/etc/mercurial/facebook.rc` because
there is no reason to enable `hgevents` on Hg servers. Therefore, we
also decline to add `hgevents` to the set of `DEFAULT_EXTENSIONS` in
`scm/hg/mercurial/extensions.py`.

Reviewed By: quark-zju

Differential Revision: D8003628

fbshipit-source-id: 4f23881f8c25f4638f5475c292537b0352ae8d15
2018-05-21 09:30:28 -07:00
Mark Thomas
d1b5faa3ac hint: allow hints to be defined and triggered in config
Summary:
Add a new config section, `[hint-definitions]` that describes additional hint
messages.  This can also be used to override built-in hint definitions.

Add a new template function `triggerhint(name)` that triggers the given hint.

Reviewed By: quark-zju

Differential Revision: D8056847

fbshipit-source-id: 5ffc945343133eb635ae0820190ecad9f16bc731
2018-05-18 11:19:35 -07:00
Jun Wu
cad09500d3 chg: defer i18n initialization
Summary:
Previously, i18n are initialized at module import time, and cannot be
reinitialized if HGPLAIN is changed. That makes chg server has to hash
HGPLAIN, and use different servers if HGPLAIN is set.

Change i18n to be only initialized at `dispatch._dispatch` time, after chg
server updating environment variables. So a same chg server could serve
different languages or encodings.

Reviewed By: singhsrb

Differential Revision: D7845334

fbshipit-source-id: 6fba19cc07efdfa60a0e328cf2cc981cfed4bcc8
2018-05-08 17:02:22 -07:00
Jun Wu
15fe9250df dispatch: pre-import modules for chg service
Summary:
Pre-import modules so when they are imported by `extensions.py`, they will
get a cache hit.

Note: use a dict explicitly since it's much faster than re-`import`:

  In [2]: %timeit import hgext.rebase
  The slowest run took 13.43 times longer than the fastest. This could mean that an intermediate result is being cached.
  1000000 loops, best of 3: 444 ns per loop

  In [3]: d=sys.modules
  In [4]: %timeit d['hgext.rebase']
  10000000 loops, best of 3: 38 ns per loop

  In [7]: %timeit sys.modules['hgext.rebase']
  The slowest run took 31.89 times longer than the fastest. This could mean that an intermediate result is being cached.
  10000000 loops, best of 3: 67.3 ns per loop

Even importing two modules and constructing a tuple is 2.5x faster than directly
"import" one module:

  In [8]: %timeit (sys.modules['hgext.rebase'], sys.modules['hgext.absorb'])
  The slowest run took 10.78 times longer than the fastest. This could mean that an intermediate result is being cached.
  10000000 loops, best of 3: 177 ns per loop

Reviewed By: singhsrb

Differential Revision: D7840236

fbshipit-source-id: ca351c61ec63ffdaf401e561944e97963b434b3c
2018-05-08 17:02:22 -07:00
Jun Wu
bf577875b3 chg: use a separate entry point
Summary:
Motivated by recent D7784903 which kills chg because it holds blackbox.log
file descriptor, and that patch is causing race conditions running with chg
(chg's sock atomic rename might fail if the directory is deleted).

There are other ways to solve the direct issue. This diff takes a more
aggressive but much cleaner approach. Basically, the `hg serve` framework is
too late for chg's usecase - the repo was already loaded, extension
side-effects have been already done at that time - chg has to use
workarounds to be compatible with that. Even with a best effort, it is still
possible to have weird interactions with shared repo because how hg loads
extensions.

The new approach is to pre-import a list of bundled extensions but do not
run their `uisetup`s.  This solves a couple of hard problems:

 - Compatibility - `uisetup` runs per request. That behaves exactly as what
   an extension author expects.
 - Less memory usage - there is no `repo` object is loaded in memory.
 - Reduced process count - since extension config change does not require a
   new chg server, the count of server processes would decrease (ex.
   `--config extensions.blackbox=!` won't require a new chg server)
 - Not holding fd to edenfs, since neither blackbox nor repo is loaded. This
   makes it possible to remove the hacky killing chg logic in D7784903.

The downside is performance, since extension loading, and `uisetup` will run
every time. Benchmark shows that's could be 50ms-ish. But we could move
forward by moving extension logic to core incrementally to get rid of that
cost too.

This is basically a simplified version of my previous stack starting
with [1]. The original commit message was:

  This is the beginning of a series that does a re-architect to chg mentioned
  in [1], to achieve better compatibility.

  The compatibility issues are mainly around "uisetup"s and "reposetup"s:

    - Developers are usually unaware that uisetup runs only once per chg
      process. We cannot reliably devel-warn them. The result is, potential
      broken code are written. For example, it's really hard for chg to deal
      with "experimental.evolution" changed from unset to manually set in
      config files because setconfig is used if that config option is not set.
    - An unnecessary "reposetup" caused by "hg serve" may have unwanted
      side effects. This can become troublesome if the repo requires things
      like remotefilelog or lz4revlog, and the user sets HGRCPATH to run
      tests.

  The current chg implementation assumes that "loading" an extension is not
  side effect free - if extension related config has changed, a restart is
  needed. The new idea is, "loading" = "importing" + "run ui/extsetup", the
  "importing" part can be side-effect free for some extensions. And benchmark
  shows "import" takes most of the time consumed, while "uisetup" is usually
  very fast. We can afford running "uisetup"s per request.

  To be able to (pre-)"import" extensions without running any "uisetup"s, a
  different entry point is needed. Otherwise as long as we go through the
  normal dispatch / runcommand ("hg serve") flow, "uisetup"s cannot be
  avoided.

  Aside from better compatibility, we can also remove some hacks:

    - chg client: no longer needs to extract sensitive argv
    - chg server: confighash can be changed to only hash environment variables
      (reduce the number of server processes)
    - chg server: srcui.walkconfig hack is no longer necessary

  This patch adds a new script "chgserve" as the new entry point. Currently,
  it is just a minimal implementation that makes "CHGHG=chgserve chg ..."
  work, without doing any pre-importing. The change could also be done in the
  "hg" script. But since chg is still experimental, let's keep "hg" untouched
  for now.

  [1]: www.mercurial-scm.org/pipermail/mercurial-devel/2016-July/085965.html

[1]: 6f91a1a69f

Reviewed By: singhsrb

Differential Revision: D7840237

fbshipit-source-id: e3d613b41fe4b721238b86c5bf84434d32cf0609
2018-05-08 17:02:22 -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
45c18ef40d dispatch: set norepo for cmdalias explicitly
Summary: This resolves a crash with nested aliases.

Reviewed By: singhsrb

Differential Revision: D7681011

fbshipit-source-id: 1c7df5d89de5dc9d970f2839d3b0d40ab3df49b8
2018-04-18 20:08:01 -07:00
Durham Goode
a4d4fb3e29 metrics: rename logblockedtimes to logmeasuredtimes
Summary:
In an upcoming diff I want to add more timing measurements for various
parts of the Mercurial code (like how long status takes, vs checkout, vs
prefetch, etc). Let's rename the logblockedtimes logic to be more generic, since
it is doing basically the same thing.

Reviewed By: singhsrb

Differential Revision: D7676406

fbshipit-source-id: 9aa8c90ce562fa3ad5b654f7b3191b2c16a440c2
2018-04-18 17:05:32 -07:00
Durham Goode
7ae20ad0fd logging: allow correlating hg commands with external jobs
Summary:
Some services like sandcastle want to be able to correlate their job
with specific hg commands in our scuba data. Let's allow them to specify a job
id we can filter on.

I considered having multiple columns, like job type and job id, but I figured
the service can use whatever format they like, and we can used derived columns
to filter on different parts of the string as needed.

Reviewed By: mjpieters

Differential Revision: D7672264

fbshipit-source-id: e4723274bad2812358176e71da791e759b346ac0
2018-04-18 13:47:48 -07:00
Jun Wu
14783221f6 hint: add a simple framework for registering hint messages
Summary:
This allows us to have a unified way to print hint messages at the end of a
command. It would be helpful for feature discovery in general.

Reviewed By: mjpieters

Differential Revision: D7392132

fbshipit-source-id: 8b4e94cc2176266652459ecca3428bd86d95bfe2
2018-04-13 21:51:48 -07:00
Durham Goode
df8173b17b hg: add --configfile global option
Summary:
This adds the ability to specify a config file to be used during the
command. This is useful during clones for letting the clone command use the
given repositories system specified repo-specific hgrc file.

Reviewed By: quark-zju

Differential Revision: D7311576

fbshipit-source-id: a97d8ebada2e0bea27c75a7650df8ede00dc10c6
2018-04-13 21:51:31 -07:00
Jun Wu
b7eb2e64e3 mdiff: use xdiff for diff calculation
Summary:
Let's switch to xdiff for its better diff quality and performance!

The test changes demonstrate xdiff's better diff quality.

Reviewed By: ryanmce

Differential Revision: D7135206

fbshipit-source-id: 1775df6fc0f763df074b4f52779835d6ef0f3a4e
2018-04-13 21:51:21 -07:00
Stanislau Hlebik
584943bdd6 fix show failure if alias is set
Summary: dispatch.lazyaliasentry didn't work with slices i.e. lazyasliasentry[:2] failed. This diff fixes it

Reviewed By: farnz

Differential Revision: D7109779

fbshipit-source-id: c704cd44fea0944ae4be68df36d32df98b7fc09b
2018-04-13 21:51:19 -07:00
Jun Wu
d56ebc52af buck: fix tests with opt build
Summary: D6937883 turns out to be ineffective. Let's fix it in another way.

Reviewed By: DurhamG

Differential Revision: D6940006

fbshipit-source-id: 082d0ddcf464d7056426bde2feab52a7717eb057
2018-04-13 21:51:09 -07:00
Jun Wu
2946a1c198 codemod: use single blank line
Summary: This makes test-check-code cleaner.

Reviewed By: ryanmce

Differential Revision: D6937934

fbshipit-source-id: 8f92bc32f75b9792ac67db77bb3a8756b37fa941
2018-04-13 21:51:08 -07:00
Kostia Balytskyi
662ade9719 hg: make sure blocked times logged during atexit handlers are logged
Summary:
Previosuly, we would miss anything logged in the `ui.atexit`-registered
handler, since the actual logging would happen before those handlers were
called.

Reviewed By: quark-zju

Differential Revision: D6912321

fbshipit-source-id: 77600b7ae535b4da56fef1f92b51998de8e304e2
2018-04-13 21:51:06 -07:00
Jun Wu
f623fe9d3c main: add mercurial.main as an entry point
Summary:
The old mercurial.dispatch entry point works, except it breaks
extensions wrapping `dispatch.*` (ex. `dispatch.runcommand`).

That is because things happen in this order:
- Buck's python wrapper imports `mercurial.dispatch` as mod1.
- hgdemandimport is enabled.
- An extension imports `mercurial.dispatch` and it got mod2.
- mod2 != mod1. So any changes to mod2 won't be used.

Using a separate module (`mercurial.main`) as the entry point
solves the problem.

Reviewed By: DurhamG

Differential Revision: D6879873

fbshipit-source-id: 9779edac64bbeb53dd98dfab1b21575c3a60af01
2018-04-13 21:51:02 -07:00
Jun Wu
d942f5a88e hg: basic support for building hg using buck
Summary:
Adds some basic building blocks to build hg using buck.

Header files are cleaned up, so they are relative to the project root.

Some minor changes to C code are made to remove clang build
warnings.

Rust dependencies, fb-hgext C/Python dependencies (ex. cstore,
mysql-connector), and 3rd-party dependencies like python-lz4
are not built yet. But the built hg binary should be able to run
most tests just fine.

Reviewed By: wez

Differential Revision: D6814686

fbshipit-source-id: 59eefd5a3ad86db2ad1c821ed824c9f1878c93e4
2018-04-13 21:50:58 -07:00
Phil Cohen
72085d2e96 testdir: fix test-extension.t for DEFAULT_EXTENSIONS
Differential Revision: https://phabricator.intern.facebook.com/D6718663
2018-01-14 14:53:52 -08:00
Durham Goode
f13c34a644 serve: move hg-ssh readonly logic into hg serve
Recently hg-ssh was changed to block writes via in-memory hook configuration
instead of by passing config hooks, and dispatch.py blocks any invocation of hg
serve --stdio that has options passed. We have infrastructure that sets up read
only serve processes without using hg-ssh, and it was broken by this change.

Let's add a --read-only option to hg serve so non-hg-ssh solutions can still
launch hg in read-only mode. This makes it also work with non-stdio serve
processes as well.
(grafted from 7a0ed9aad8526f689343a5a02aa4a66e5f3be1f2)
(grafted from bf33f750447d8b0dfeae2a311e1d1eb93e19d6a0)
(grafted from 9ada6a6e4ac2a92325592cd58edd9160e17c9e31)
(grafted from 50e676e99c3b7cc929ceaaebbd3c684a8a58f9d8)
(grafted from 01833a49fa4dca204dc0e606f21279530925307c)
(grafted from 301af2e1a42fe912acf90ae9a87ca6a20ce5cd5d)
(grafted from 6ae2eaad3edbfdfb04ac5880a86341e69980529c)
(grafted from fcdedd417b29d28797840fc2393e0ff846fa54c8)
(grafted from ddda3705adfb2ac103f506d694d2b30028dfaca9)
(grafted from 138e3cf3bc394c4ff507341a390e1876c7104042)
(grafted from f8073d595e87086213525dbb642962b84158ee9a)
(grafted from 96bac04dc722030250a53616f0fb55125829f25e)
(grafted from 2aeed48cc3b3324b564343d8515aed1ecec69b14)
(grafted from 4fb2e02a273c868febdae9530b0a07a53a0e92a7)
(grafted from c57b28835f0b880c075d5b8aa99ddb9da54b21b1)
(grafted from 35fd78b021bec96db63e8dd99f98efc3b2342380)
(grafted from 9ac14f96c9a82068f07a709374f359283c206791)
(grafted from 4b64c191a9aacd52ea58ae8ec943605667759398)
(grafted from 1db390a79e32db12dde7a225e26b86ed245f9473)
(grafted from 9a999ed1ce50af8e5fa03dc270488c37304d8c94)
(grafted from b6791f2eb83f176192c9df50c736bc4c54fab5a6)
(grafted from 4b6e87c5be38d9971399e4ad989e4261f283b93a)
(grafted from ae660c075b4af0849d1ff5d36404ef66aeea9933)
(grafted from ff0f3bf0834b38a527654495369cd538ca8744f4)
(grafted from bff8177767c9023295ff93bc520114bb909952a8)
(grafted from 05a833e4071b9da7b447669f6bd8a3f62c1d3c27)
(grafted from be8ab299731fb8295efbe10a014798c7a177d4a0)
(grafted from beec2bc2ebd9eaf7093bba5fca8fef07c669d970)
(grafted from 03d88ba3cd8795d17a99dc1b50ac55e1937d38e1)
(grafted from 92a33bc0d275a96c61553f8bccefcd32f1360931)
(grafted from 3d37833f54e37356f3e32db2ad8fb2ffe4fa14f2)
(grafted from 77fa3393787a9410e14afc26465abb5561253075)
(grafted from 9d908f86cc7986c167cef5cdccaabb565fd2bc04)
(grafted from 0dbc2023c42f72aea6b608e5111725163dcbb64b)
(grafted from 3acf4e9bb718617efaf31abcba583b9b7be2559d)
(grafted from c671696a06e418f5f040427efb3e51fe4c9fa6cd)
(grafted from 309f11e682eb3c6fa497bf767cbcbef3b0dbaf4b)
(grafted from 4f828ef4b70a6a16fe747d5f6393042bff204b5e)
(grafted from 71193e84a71d029dedc744882978285cbe5722e6)
(grafted from 2929832c61c9727bd884f94da5afa29e80334a96)
(grafted from 2ff8a9f1761f82ffa8ebd2a96d86f7de7c712d9c)
(grafted from b438cb1e6cff36e7e197da7669def8a5e528053c)
(grafted from a9ed103481b779af9e160d2b81a9bfe81cc7d173)
(grafted from d139e95d22dc811002dafef1ecaac5dac99825fe)
(grafted from b4e41a9f2c3a6328ada72810407686d11833347c)
(grafted from 2b3826c7b3bdf669b397f1ad31ae106a05d7b05b)
(grafted from 23737fb5e1d6874cf79a1eb841dd1614c0295a1b)
(grafted from 69588396b17d3dafeece8bc9e2101559d871d9fb)
(grafted from b3252a277a53b1657e6bcf31359b413d2becffcc)
(grafted from 12c8e6062d34d4d6cf0b0128084278800a1ed8f7)
(grafted from 8ce5c67748afbe6e82fc3f822e35ddc58cb03694)
(grafted from b0f656426efcf9a70386b1c781507f40ab95af49)
(grafted from 147ae96993dcffbed2f39f31795ef3d60631d43f)
(grafted from 2ecb34a565accf638e6004c59aa5b2d2361f9428)
(grafted from 6bfc53cd4c479b4e789d4086a2c7c2f4045a288f)
(grafted from bf73f92394a079928db6d4b0b3e7aa78448af91a)
(grafted from b69a654342339eb740527fc84af523eb53edeb71)
(grafted from 3f090f44e8a33cde8d5708454a5292d0976269e6)
(grafted from ac4432275d3b750405e53f67b1267579764f4fee)
(grafted from dbfd0bce0eded53dc7d824393f03ddd2f2e693fb)
(grafted from bf7087d072ca6c5d5dac2ddef4c43339d02f6133)
(grafted from b9d63feb8c90f83e74f3e9a89328419c81088082)
(grafted from 718e93a4e545f3e16d09c66f210a567427f1068a)
(grafted from e0ba57c8bf13ccc45b7eaa62d64e03038cd002ad)
(grafted from 5c849011421ad00ef190c2bf15c640656424f681)
(grafted from e833de714167fe6039b42f1cd1890b0470a32ea2)
(grafted from 480872890137130564910a29ed8ef3890810f0c4)
(grafted from 6224dc455a24542cf7d55721fceb14a08e92d391)
(grafted from 24ced5d2b0d6fb837a3994a80ef808e29f62ccc5)
(grafted from 452eb5c8624cc22867fafa692c6c7905e46da27a)
(grafted from cdc9f1b121878c26c986eca2233b5d03ea50ad74)
(grafted from 8b3a45fe3a612fdbee3a1f291f41bfaadfd16a6f)
(grafted from 2a07c0b3cb9785a9f8d5d669b885044e4d4544b1)
(grafted from 56d892df53cfdf3a13f38cd386a437ea59ef0d77)
(grafted from b63c65fad2d28a86a3bc3871d58e45019b11e6a1)
(grafted from 8618bd56f309543d8577000a4310fdf8648f1087)
(grafted from e04c7ddddc5cc40d6347d2336b81d5be2289243e)
(grafted from 5951fe6318d02a9b739f0174f3aecc3d5eead31c)
(grafted from 0f4d380f641a55791ca9eef13cd49da24cf40a7a)
(grafted from d7ecf3376e572d77b670cbe2184370b08d38dcf7)
(grafted from a75534c9e6d7a481303096e44e265593fb5b0b2f)
2018-01-03 05:35:56 -08:00
Pulkit Goyal
616684d4c9 py3: handle keyword arguments correctly in dispatch.py
Differential Revision: https://phab.mercurial-scm.org/D1630
2017-12-10 04:46:13 +05:30
Yuya Nishihara
86043c7487 dispatch: replace _earlygetopt(strip=True) with new parser
The execution order in cmdalias.__init__() is adjusted to set stripped args
to self.givenargs, which is no longer updated in place.
2017-11-23 23:18:56 +09:00
Yuya Nishihara
c2c866a852 dispatch: replace _earlyreq*() with new fancyopts-based parser 2017-11-23 22:23:59 +09:00
Yuya Nishihara
2e53122de6 dispatch: alias --repo to --repository while parsing early options
This prepares for replacing old _early*opt() functions. My initial attempt
was to extend options table to support 'repository|repo' syntax. It worked,
but seemed too invasive. So I decided to add an optional argument to
fancyopts() instead.

This also changes the nevernegate dict to be keyed by a canonical_name,
not by an option-name for clarity.
2017-11-25 17:03:52 +09:00
Kevin Bullock
c86342f882 merge with stable 2017-12-01 15:21:05 -06:00
Yuya Nishihara
5ff5d9b38c dispatch: add HGPLAIN=+strictflags to restrict early parsing of global options
If this feature is enabled, early options are parsed using the global options
table. As the parser stops processing options when non/unknown option is
encountered, it won't mistakenly take an option value as a new early option.
Still "--" can be injected to terminate the parsing (e.g. "hg -R -- log"), I
think it's unlikely to lead to an RCE.

To minimize a risk of this change, new fancyopts.earlygetopt() path is enabled
only when +strictflags is set. Also the strict parser doesn't support '--repo',
a short for '--repository' yet. This limitation will be removed later.

As this feature is backward incompatible, I decided to add a new opt-in
mechanism to HGPLAIN. I'm not pretty sure if this is the right choice, but
I'm thinking of adding +feature/-feature syntax to HGPLAIN. Alternatively,
we could add a new environment variable. Any bikeshedding is welcome.

Note that HGPLAIN=+strictflags doesn't work correctly in chg session since
command arguments are pre-processed in C. This wouldn't be easily fixed.
2017-11-23 22:17:03 +09:00