Commit Graph

43068 Commits

Author SHA1 Message Date
Martijn Pieters
b8110f185c Allow for better help handling and multiple registrations for a single function.
Summary:
We take help info from the docstring but that'd disallow multiple registrations for a single function that can handle multiple subcommands. Refactor to let the decorator set an override.

So before you'd do this:

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

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

Now you can do:

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

Reviewed By: ryanmce

Differential Revision: D7365390

fbshipit-source-id: 3d41542f1f197137ef13458e8d850cda8f53da74
2018-04-13 21:51:37 -07:00
Martijn Pieters
c9dd45c81f help: refactor to allow for patching
Summary:
I want to add to helpcmd but with nested functions that's a lot more
complicated then it needs to be.

Reviewed By: ryanmce

Differential Revision: D7365391

fbshipit-source-id: 02092dd55f8f9521324b8ed51fa3134817454d36
2018-04-13 21:51:37 -07:00
Liubov Dmitrieva
ee6457a0fb obsshelve: add highlight
Summary:
obsshelve: highlight shelved changes in smartlog (you can see with --hidden)

we highlighted only active shelved changes, those that has been unshelved are just ordinary hidden changes.

Reviewed By: ryanmce

Differential Revision: D7383800

fbshipit-source-id: 2df4092514d58315a6a204411feed99819df5c93
2018-04-13 21:51:36 -07:00
Liubov Dmitrieva
58b4fc9380 obsshelve: add tests for new revsetpredicate
Summary: obsshelve: add tests for new revsetpredicate

Differential Revision: D7397947

fbshipit-source-id: f2940ef20e594aea93832860a3dccfa2c4cf787a
2018-04-13 21:51:36 -07:00
Liubov Dmitrieva
d0972892e5 shelve: add revsetpredicate to select shelved commits
Summary:
add revsetpredicate to select shelved commits

if we are going to backup shelved commits, we should be able to select them

Reviewed By: ryanmce

Differential Revision: D7381561

fbshipit-source-id: 35aa0ad9a77fa9df94e91b571279eaa4301c85f3
2018-04-13 21:51:36 -07:00
Phil Cohen
2c66516728 add subclass for AbandonedTransactionFoundError
Summary:
Raise this instead of RepoError. This way commands can catch and auto-recover the
repo, if appropriate. Right now I only do this inside megarepo commands.

Reviewed By: DurhamG

Differential Revision: D7363245

fbshipit-source-id: 0a6cab92a4ff6e50cd269bdddadee47be6199ebd
2018-04-13 21:51:36 -07:00
Phil Cohen
2e5e764e25 a basic perf suite implementation
Reviewed By: DurhamG

Differential Revision: D7341042

fbshipit-source-id: e87bd1bfe198fc4c5e1e2239b761c543d6acbf01
2018-04-13 21:51:36 -07:00
Jun Wu
81b678d400 color: change diff related colors to 256 colors
Summary: Use 256 colors if supported, or fallback to 16 colors.

Reviewed By: singhsrb

Differential Revision: D7388275

fbshipit-source-id: e7be447f2b900e384e9280f92ea8f881747493e4
2018-04-13 21:51:36 -07:00
Jun Wu
3d8a2aa583 color: support fallback configs
Summary:
Allow color config to be something like `color132:red` that is to use 256
color if supported, but fallback to `red`.

To get a consistent test output. `run-tests.py` is changed to disable 256
color support explicitly.

Reviewed By: singhsrb

Differential Revision: D7388277

fbshipit-source-id: da74ae8fc70c971901d56a6985976db44cbec0d9
2018-04-13 21:51:36 -07:00
Jun Wu
7f793ca8d3 color: define 256 colors on supported terminals
Summary:
This would allow us to use 256 colors, which seems to be widely available
on modern terminals (including mosh and tmux).

Reviewed By: singhsrb

Differential Revision: D7388279

fbshipit-source-id: 726a364ed5d3acc449f0d7ada14c42e4b68424ec
2018-04-13 21:51:36 -07:00
Jun Wu
7afcefd83c color: add a method to detect 256color support
Summary:
This allows us to treat terminals with 256 color support differently.

The motivation is, the bright colors seem to work fine on Linux. But they
appear to have minor differences on OSX terminals (iTerm2 or Terminal.app).
Using explicit 256 colors is better.

Reviewed By: singhsrb

Differential Revision: D7388276

fbshipit-source-id: 970ee18f0f5bb9cc4bb5c39b2b46b354525b3d55
2018-04-13 21:51:36 -07:00
Jun Wu
97584a7de7 color: change diff related colors to bright versions
Summary:
As suggested by wez, "dim" is less supported than the bright colors.
So let's use the bright versions instead. Basically, replacing "red",
"red dim" with "brightred" and "red".

Reviewed By: singhsrb

Differential Revision: D7387254

fbshipit-source-id: f741d9e1c12115acdd1a3a2cae1658d8fae534bf
2018-04-13 21:51:36 -07:00
Jun Wu
c93ed71dcd color: add bright colors
Summary:
Most terminals support 16 colors these days. This is manually tested
with: tmux (2.2), mosh (1.3.0), screen (4.04) from Linux (xfce) and
OS X Terminal.app and iTerm 2.

Note: aside from "screen" with default configuration, the terminals
also have 256 colors support. "screen" can support 256 colors if it's
started with TERM=xterm-256color.

See https://en.wikipedia.org/wiki/ANSI_escape_code for details.

Reviewed By: singhsrb

Differential Revision: D7387258

fbshipit-source-id: e7b2437fee2b4e593077bb3f44143c86ece93a8f
2018-04-13 21:51:36 -07:00
Liubov Dmitrieva
f776a334b5 obsshelve: use real user for shelve commits
Summary:
The reason why we would like to have a real user there is that

we may want to start push shelved changes in commit cloud, so

we should have correct user on the commit

Reviewed By: ryanmce

Differential Revision: D7380732

fbshipit-source-id: 27b07f992a3e394016ce69e1dc9694a4dd1c336b
2018-04-13 21:51:36 -07:00
Liubov Dmitrieva
ce46d0b01f fix import warnings and add log request time
Reviewed By: StanislavGlebik

Differential Revision: D7365309

fbshipit-source-id: 5984fa811b8d1cb9eb996700e6352ec9966b18ad
2018-04-13 21:51:35 -07:00
Liubov Dmitrieva
8eb1968255 obsshelve: do not use secret phase
Summary: obsshelve: do not use secret phase

Reviewed By: ryanmce

Differential Revision: D7380531

fbshipit-source-id: 21538d42a43f019b894dd1a77ba0adc67798936a
2018-04-13 21:51:35 -07:00
Jun Wu
ae0142473d progress: suspend progress when shelling out
Summary:
The progress bar runs in another thread and may draw " <=> " which pollutes the
current screen.

Make `ui.system` suspend the progress bar automatically. This should work for
the "invoking editor" case. I think sshaskpass and curses might also need to
suspend the progress bar but those are trickier.

Reviewed By: singhsrb

Differential Revision: D7377492

fbshipit-source-id: 833ac724bbe4f9c630ca37567dc088f7279dd67e
2018-04-13 21:51:35 -07:00
Jun Wu
3859d00394 indexedlog: implement flush for the main index
Summary:
The flush method will write buffered data to disk.

A mistake in Root entry serialization is fixed - it needs to translate dirty
offsets to non-dirty ones.

Reviewed By: DurhamG

Differential Revision: D7223729

fbshipit-source-id: baeaab27627d6cfb7c5798d3a39be4d2b8811e5f
2018-04-13 21:51:35 -07:00
Jun Wu
8f5c35c8d2 indexedlog: initial main index structure
Summary:
Add the main `Index` structure and its constructor.

The structure focus on the index logic itself. It does not have the checksum
part yet.

Some notes about choices made:
- The use of mmap: mmap is good for random I/O, and has the benefit of
  sharing buffers between processes reading the same file. We may be able to
  do good user-space caching for the random I/O part. But it's harder to
  share the buffers between processes.
- The "read_only" auto decision. Common "open" pattern requires the caller
  to pass whether they want to read or write. The index makes the decision
  for the caller for convenience (ex. running "hg log" on somebody else's
  repo).
- The "load root entry from the end of the file" feature. It's just for
  convenience for users wanting to use the Index in a standalone way. We
  probably

Reviewed By: DurhamG

Differential Revision: D7208358

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

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

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

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

Reviewed By: quark-zju

Differential Revision: D7350928

fbshipit-source-id: d03014cf7edd2f089f670d11465c70940d96c070
2018-04-13 21:51:35 -07:00
Kostia Balytskyi
6f265bb8d5 hg: when shelling our from rage, pass shell=True to subprocess.Popen
Summary:
Without `shell=True`, `Popen` does not find `.bat` files, just `.exe` files.
The way `arc` is deployed (to at least some people) does not create a `.exe`
shim and only has a `.bat` in the PATH.

FYI: https://stackoverflow.com/questions/41860668/why-does-this-python-subprocess-command-only-work-when-shell-true-on-windows?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

Reviewed By: quark-zju

Differential Revision: D7370386

fbshipit-source-id: ad9e2006893e71b2a9e8cd1a480f9188e412a931
2018-04-13 21:51:35 -07:00
Jun Wu
545f670504 pathencoding: utility for converting between bytes and paths
Summary:
A simple utility that does paths <-> local bytes conversion. It's needed
since Mercurial stores paths using local encoding in manifests.

For POSIX, the code is zero-cost - no real conversion or error can happen.
This is in theory cheaper than what treedirstate does.

For Windows, the "local_encoding" crate is selected as Yuya suggested the
`MultiByteToWideChar` Win32 API [1] and "local_encoding" uses it. It does
the right thing given my experiment with GBK (Chinese, simplified) encoding.

```
  ....
  C:\Users\quark\enc>hg debugshell --config extensions.debugshell=
  >>> repo[0].manifest().text()
  '\xc4\xbf\xc2\xbc1/\xce\xc4\xbc\xfe1\x00b80de5d138758541c5f05265ad144ab9fa86d1db\n'
  >>> repo[0].files()
  ['\xc4\xbf\xc2\xbc1/\xce\xc4\xbc\xfe1']
  extern crate local_encoding;
  use std::path::PathBuf;
  use local_encoding::{Encoder, Encoding};
  const mpath: &[u8] = b"\xc4\xbf\xc2\xbc1/\xce\xc4\xbc\xfe1";
  fn main() {
      let p = PathBuf::from(Encoding::OEM.to_string(mpath).unwrap());
      println!("exists: {}", p.exists());
      println!("mpath len: {}, osstr len: {}", mpath.len(), p.as_path().as_os_str().len());
  }
  exists: true
  mpath len: 11, osstr len: 15
```

In the future, we might normalize the paths to UTF-8 before storing them in
manifest to avoid issues.

Differential Revision: D7319604

fbshipit-source-id: a7ed5284be116c4176598b4c742e8228abcc3b02
2018-04-13 21:51:35 -07:00
Kostia Balytskyi
731f87492f hg: make rage errors more friendly
Summary:
We've seen cases when `suprocess.Popen` fails [1], [2]. It might happen if
`arc` binary is not in `$PATH` env var. Let's fail gracefully.

[1] https://fburl.com/7hcq73as
[2] https://fburl.com/u1v0es8q

Differential Revision: D7365459

fbshipit-source-id: ce838f434cb81211c334d6f170fd25ef30edaabd
2018-04-13 21:51:35 -07:00
Liubov Dmitrieva
1c8877987d https connector
Summary: https connector for commit cloud

Reviewed By: mjpieters

Differential Revision: D7306672

fbshipit-source-id: c95388964a1aced82579c0d55ccdd0a9ef391e81
2018-04-13 21:51:35 -07:00
Durham Goode
d87789e3e7 hg: store repo on manifestlog instead of changelog
Summary:
Previously we were storing the changelog on the manifestlog and using
it to resolve linkrevs before serializing them. It turns out the changelog can
be invalidated at a different rate than the manifestlog, so we could encounter
issues where the manifestlog held a reference to the old changelog.

To fix this, let's hold a reference to the repo and access the changelog from
there when we need it. This introduces a circular reference between the
manifestlog and the repo, but it's probably fine for now until we can get rid of
the need for changelog invalidation.

Reviewed By: singhsrb

Differential Revision: D7360321

fbshipit-source-id: 2317c7fcd6b307a50b64f0c5df97dda2955f3e21
2018-04-13 21:51:35 -07:00
Mark Thomas
0827683bf0 remotefilelog: show names of files being downloaded in the progress bar
Summary:
When remotefilelog downloads filelog information for a particular file, set the
progress bar item to that file.  This means if we get stuck on a particular
file, there is feedback to the user as to which file that is.

Reviewed By: quark-zju

Differential Revision: D7329503

fbshipit-source-id: 94416962cdc4c97994f76e8ed9203823aeca3d64
2018-04-13 21:51:35 -07:00
Mark Thomas
0d739795cc progress: add fancyrenderer for colorful progress bars
Reviewed By: quark-zju

Differential Revision: D7329656

fbshipit-source-id: b6592319177387d615547ff27f8f38efe85838ba
2018-04-13 21:51:34 -07:00
Mark Thomas
8d01284b55 progress: re-implement progress bar engine
Reviewed By: quark-zju

Differential Revision: D7329657

fbshipit-source-id: 4ba5152269ea8a598f13f0ae1e9e792c3b9542bb
2018-04-13 21:51:34 -07:00
Mark Thomas
aa338235f8 util: add util.ring, a ringbuffer of fixed length
Reviewed By: quark-zju

Differential Revision: D7329654

fbshipit-source-id: fa918ba5e77dc444705737be7e34bbb3c70f91ef
2018-04-13 21:51:34 -07:00
Mark Thomas
e09288137b ui: deprecate ui.progress
Summary:
Remove ui.progress as a method of updating progress.  All progress bars now go
through new-style progress bars.

This also splits out the rendering of progress bars from the reporting of
progress.  All tests are updated to use new-style debug progress bars, which
simply report the position of the progress bar.  Rendering of progress bars
will be tested separately once the progress bar engine has been rewritten.

Reviewed By: quark-zju

Differential Revision: D7329488

fbshipit-source-id: 14f8ab67365ddd98b74986aa25d9abc7a0546144
2018-04-13 21:51:34 -07:00
Mark Thomas
d67787ff6a upgradegeneraldelta: use new-style progress bars
Reviewed By: mjpieters

Differential Revision: D7329492

fbshipit-source-id: 49cac8963e36702569fdfa32856fca59452629b0
2018-04-13 21:51:34 -07:00
Mark Thomas
896813a257 treemanifest: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329497

fbshipit-source-id: aa19b579e6b57dd08271abf94f370e5491515d96
2018-04-13 21:51:34 -07:00
Mark Thomas
e59d61a2f5 remotefilelog: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329507

fbshipit-source-id: 9648bb7ec34a682238fc9ede96e8cdf63a45bdf9
2018-04-13 21:51:34 -07:00
Mark Thomas
79e7eb9a8e relink: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329513

fbshipit-source-id: a801e9c13f6c4912bffa9c08994e899761c1fc08
2018-04-13 21:51:34 -07:00
Mark Thomas
1ee8d6bace rebase: use new-style progress bars
Reviewed By: mjpieters

Differential Revision: D7329479

fbshipit-source-id: 75b53d9ca34b3670c60a79138a388f096a4a7275
2018-04-13 21:51:34 -07:00
Mark Thomas
2f6ee7d5e2 patchbomb: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329489

fbshipit-source-id: 3ac24272c286d47a61ed131ba217a2a9d07d9839
2018-04-13 21:51:34 -07:00
Mark Thomas
ced425bc04 p4fastimport: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329509

fbshipit-source-id: 5006ab9555d37102e430a6c6d9994d869ec512dc
2018-04-13 21:51:34 -07:00
Mark Thomas
4d96e98cae linkrevcache: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329505

fbshipit-source-id: 674729586260d218c3d070d0d36a8e57def817a7
2018-04-13 21:51:34 -07:00
Mark Thomas
b91b10e988 lfs: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329485

fbshipit-source-id: 4d6763ca6eed94a72ba59b1f8c8e4a506d8b5929
2018-04-13 21:51:33 -07:00
Mark Thomas
b1d366cb34 histedit: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329484

fbshipit-source-id: 038b8405a76aba4b4bc540c752beda6f1cfd4a4c
2018-04-13 21:51:33 -07:00
Mark Thomas
50792d83d8 hgsubversion: use new-style progress bars
Reviewed By: mjpieters

Differential Revision: D7329498

fbshipit-source-id: 138dcd425ceb6e8e35c134555bfb07c1680e5674
2018-04-13 21:51:33 -07:00
Mark Thomas
b46a47be82 hgsql: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329506

fbshipit-source-id: 3aa83389ace823cfc933a48076403ceda510387a
2018-04-13 21:51:33 -07:00
Mark Thomas
fd9fbe1f27 hggit: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329502

fbshipit-source-id: e12c77f511034ecedd521709523c3674c133d181
2018-04-13 21:51:33 -07:00
Mark Thomas
d28e778f85 fixcorrupt: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329520

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

Differential Revision: D7329504

fbshipit-source-id: 8037f704f88ea8b7d02ef323932143298fef5c66
2018-04-13 21:51:33 -07:00
Mark Thomas
52d272277f fastannotate: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329490

fbshipit-source-id: 3c8bf8b0590b1d3e5bf567849de4b7c88ea8b894
2018-04-13 21:51:33 -07:00
Mark Thomas
eb318ffa63 convert: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329501

fbshipit-source-id: 5312f905b513200904c79acbdb1c7b17968a8aba
2018-04-13 21:51:33 -07:00
Mark Thomas
af359e3856 churn: use new-style progress bars
Reviewed By: quark-zju

Differential Revision: D7329481

fbshipit-source-id: 4bf764216e23c1e38efe19340eabd7a29f960e64
2018-04-13 21:51:33 -07:00
Mark Thomas
1575ac85e1 httpconnection: remove old-style progress bar
Summary:
httpconnection uses old-style progress bars in a way that isn't easy to
replicate using new-style progress bars.  Remove it for now, it can be added
back in later in the right place.

Reviewed By: quark-zju

Differential Revision: D7329486

fbshipit-source-id: 814c55d7a5bb5c97fc6b3967510ed656110038c8
2018-04-13 21:51:33 -07:00
Mark Thomas
fb4c6e652c verify: use new-style progress bars
Reviewed By: mjpieters

Differential Revision: D7329516

fbshipit-source-id: 4e18bd639f292c3dcb8b6c33f1322b85ed40c043
2018-04-13 21:51:33 -07:00