Commit Graph

56 Commits

Author SHA1 Message Date
Jun Wu
c6c4a8ba58 checkcode: remove old-style class check
Summary:
The old-style class warning only applies to Python 2. I want to use Python 3
dataclass in a future diff.

Reviewed By: DurhamG

Differential Revision: D33518830

fbshipit-source-id: 89a8b653f1ff083975911af7e3e095737635d622
2022-01-20 10:21:48 -08:00
Jun Wu
2a99866d7b codemod: update license headers
Summary:
The "Portions" license cannot be updated automatically. So this is a manual
update using:

  sd -s 'Portions Copyright (c) Facebook, Inc. and its affiliates.' 'Portions Copyright (c) Meta Platforms, Inc. and affiliates.' `rg -l Facebook`
  sd -s 'Copyright (c) Facebook, Inc. and its affiliates.' 'Copyright (c) Meta Platforms, Inc. and affiliates.' `rg -l Facebook`

Differential Revision: D33420114

fbshipit-source-id: 49ae00a7b62e3b8cc6c5dd839b3c104a75e72a56
2022-01-05 14:43:32 -08:00
Jun Wu
68df5d5872 python: prefer python 3.8
Summary:
CentOS 8 `python3` defaults to Python 3.6, which has issues with IPython
shell tab completion. Prefer Python 3.8 to avoid issues.

Note: I also tried Python 3.9 but it seems the Cython we use generates
incompatible code. So I'm sticking to Python 3.8 for now.

Reviewed By: markbt

Differential Revision: D33339419

fbshipit-source-id: 4708a6713ce9ce63ed4bd5e3cc08a3086ae57edb
2022-01-04 19:01:16 -08:00
Zeyi (Rice) Fan
a140edc209 codemod: our.intern.facebook.com -> internalfb.com
Summary:
```
fastmod 'https://our.intern.facebook.com' 'https://www.internalfb.com'
```

and some manual editing

Reviewed By: DurhamG

Differential Revision: D32964761

fbshipit-source-id: b6ef08a28b8c6533163443213e857b6388111d06
2021-12-08 19:40:13 -08:00
Durham Goode
efe1353320 tests: remove #requires py2
Summary:
We've been off Python 2 for almost a year. Let's remove the py2
requirement on some tests.

Note, this deletes a few unused extensions: edrecord, gpg, perfsuite, repogenerator, and grepdiff

Reviewed By: quark-zju

Differential Revision: D32654701

fbshipit-source-id: 31d93180d9b2db0b8a92a024f4b80592940a69e4
2021-12-06 14:59:43 -08:00
Yan Soares Couto
396e345703 patch: Accept contexts and not nodes in patch functions
Summary:
The `edenscm.mercurial.patch.diffhunks`, which is the heart of functionalities like `hg diff` and `hg show`, takes two nodes, and then gets the `changectx` from them to compare the changes.

That works for most cases, but doesn't allow things like `memctx` to be used, as it doesn't have a node.

This refactors so that function (and functions that call it) take a `ctx` instead.

 ---

EDIT: I just found out `repo[ctx]` returns `ctx`, so I could just pass in context as if it was a node (that is, only fix `changeset_printer` to pass `ctx` to `diffordiffstat`), but the fix on this diff still seems better, more consistent and less unclear, so I still think it should be merged.

Reviewed By: DurhamG

Differential Revision: D31802139

fbshipit-source-id: bc9d23a5e666cd0f57b69bce3ed9d58ae79e92d0
2021-11-01 09:17:04 -07:00
Durham Goode
742240b65f hggit: delete hggit
Summary: This is no longer used, now that configerator does it's sync via SCS.

Reviewed By: quark-zju

Differential Revision: D31006839

fbshipit-source-id: ddf7923a3c80ad47519bce0e5cb3895f62e7ae2e
2021-09-21 13:45:11 -07:00
Zhengchao Liu
f52d8185d2 replace readlink_retry_estale with os.readlink in cli
Summary:
Per comment in D30017261 (e9c039ab4a)

> [...] we can get rid of this ESTALE check. That dates back to when edenfs had a bug that returned ESTALE when reading the .eden directory sometimes.

Reviewed By: xavierd

Differential Revision: D30024979

fbshipit-source-id: 645097c8f689c916245845561fd3d824ff7df8b4
2021-08-02 15:00:17 -07:00
Jun Wu
d0d8e61daf setup: check Python.h existence
Summary:
Non-buck build cannot succeed if Python.h is missing.
Let's check it explicitly so we don't pick a bad Python.

Reviewed By: DurhamG

Differential Revision: D29179295

fbshipit-source-id: 421c824053d066914a6611f05815527768f257ee
2021-06-16 15:08:52 -07:00
Jun Wu
960cdcc4b9 setup: pick the right Python more aggressively
Summary:
It turns out that `python3` might be a symlink to a fbcode Python that cannot
perform the build in some (not all) environment. Let's try more names like
`python3.8`, `python3.7`, etc.

Reviewed By: DurhamG

Differential Revision: D29178933

fbshipit-source-id: da6cae351f25a90ab8a9da85282d09f79505c5e7
2021-06-16 15:07:23 -07:00
Durham Goode
7469868f65 make: avoid fb python for make builds
Summary:
Our BigSur mactest machines have python3 defaulting to some internal
fbprojects python install. This is breaking our OSS builds. Let's change
pick_python to avoid that install.

Note, sys.stdout was changed to print because during my manual testing on Mac,
sys.stdout did not actually print the value, despite the flush.  Using print()
did work.

Reviewed By: quark-zju

Differential Revision: D28101632

fbshipit-source-id: 2907d644b2baa8a53a9a2d7da176d33cd83dfbd5
2021-05-04 14:43:32 -07:00
Jun Wu
db8f90ea76 makefile: pick Python that is more likely to build with setup.py
Summary:
The `python` in `PATH` might be the fbcode Python that has `-nostdinc` in its
`CFLAGS`. That Python is problematic because it cannot compile C extensions.

Reviewed By: DurhamG, markbt

Differential Revision: D27661488

fbshipit-source-id: 243205522fcaf53d5af6a3c9afc4d28160072de5
2021-04-08 14:20:12 -07:00
Mike Watters
09fb4128a5 support git worktrees
Summary:
a [git worktree](https://git-scm.com/docs/git-worktree) allows for a single repository to have multiple local checkouts in different directories (allowing parallel work on multiple branches of the same repo).

in such a worktree, `.git` is a file and not a directory:
```
$ cat .git
gitdir: /path/to/actual/repo/.git/worktrees/name
```

the `_git_prompt` helper in `scm-prompt.sh` expects only directories:
```
$ echo "$(_git_prompt /path/to/worktree/.git)"
# (output is empty)
```

this amends the helper to support them:
```
$ echo "$(_git_prompt /path/to/worktree/.git)"
f140443f|REBASE-i|T123456

$ echo "$(_git_prompt /path/to/parent/.git)"
T54321
```

Reviewed By: quark-zju

Differential Revision: D27509147

fbshipit-source-id: 9a4ab55af99538c6425ad5721c3266386dbda453
2021-04-08 12:46:41 -07:00
Sean Kamath
ae5db40fdd Changing commit hash length to 9 in hg prompt
Summary:
Copied from D17312417 (e1f4dbeb3d), because that did what I needed done, but incremented by 1.

I would like to change the length of the displayed hash in scm-prompt
to 9. Why such an impactful diff? Because hg sl shows 9 characters, and I
always get confused when the hash in my prompt doesn't match hg sl

Reviewed By: kulshrax

Differential Revision: D25934253

fbshipit-source-id: 15f2bc8bc7d666de1a077d2bafd74ab3c9753341
2021-02-10 17:07:35 -08:00
Jun Wu
91ab840c4b logginghelper: stop logging obsstore size
Summary: We don't use obsstore. Its size is irrelevant.

Reviewed By: singhsrb

Differential Revision: D25876066

fbshipit-source-id: 5657c3ca08f5ed1cb5a3d1a5b3395ab74756b7e5
2021-01-12 14:09:08 -08:00
James Donald
c7fe8b849e Fix merge on Windows when path contains spaces
Summary: editmergeps.bat was separating a filename with spaces into args[0] and args[1] when calling editmergeps.ps1. Use proper quoting to send files with spaces as a single argument.

Reviewed By: ikostia

Differential Revision: D25194324

fbshipit-source-id: 065f677c9015681b310e1cfc46f52ff563a35f99
2020-11-27 03:57:03 -08:00
John Reese
d13e0b137f apply pyfmt with usort to opted-in sources
Reviewed By: zertosh

Differential Revision: D24880203

fbshipit-source-id: 2034cdfc2712209e86d3d05c119c58f979b05c52
2020-11-10 21:25:54 -08:00
John Reese
737849c9dd apply black 20.8b1 formatting update
Summary:
allow-large-files

black_any_style

Reviewed By: zertosh

Differential Revision: D24325133

fbshipit-source-id: b4afe80d1e8b2bc993f4b8e3822c02964df47462
2020-10-14 20:21:52 -07:00
Jun Wu
34d8dca79a dispatch: run command in non-main thread
Summary:
This extends the Ctrl+C special handling from edenapi to the entire Python
command so Ctrl+C should be able to exit the program even if it's running
some blocking Rust functions.

`edenapi` no longer needs to spawn threads for fetching.

Reviewed By: singhsrb

Differential Revision: D23759710

fbshipit-source-id: cbaaa8e5f93d8d74a8692117a00d9de20646d232
2020-09-18 18:47:24 -07:00
Jun Wu
80bf264e24 debugshell: add "api" object
Summary: It is handy to test edenapi methods directly.

Reviewed By: kulshrax

Differential Revision: D23750709

fbshipit-source-id: 33c15cecaa0372ba9e4688502e7d8f3fdda7c3b8
2020-09-18 13:28:33 -07:00
Jun Wu
3acb04ea22 contrib: remove revlog related perf tests
Summary:
Those tests are going to break with the latest changelog. We're moving away
from revlog so let's just remove the tests.

Reviewed By: DurhamG

Differential Revision: D22657198

fbshipit-source-id: 6d1540050d70c58636577fa3325daca511273a2b
2020-07-30 20:32:34 -07:00
Jun Wu
d3df634f14 changelog: use Rust RevlogIndex for descendants
Reviewed By: DurhamG

Differential Revision: D22368830

fbshipit-source-id: ccfc1128012014223c86c52fab6cf3845827e3f1
2020-07-15 13:16:47 -07:00
Viet Hung Nguyen
b7817ffbd8 xdiff: renamed third-party xdiff functions
Summary:
Renamed xdiff functions to avoid linking issues when using both libgit2-sys and xdiff.

When using repo_import tool (https://fburl.com/diffusion/8p6fhjt2) we have libgit2-sys dependency for importing git repos. However, when we derive blame data types, we need to use xdiff functionalities (from_no_parents: https://fburl.com/diffusion/pitukmyo -> diff_hunks: https://fburl.com/diffusion/9f8caan9 -> xdl_diff: https://fburl.com/diffusion/260x66hf). Both libgit2 and eden/scm have vendored versions of xdiff library. Therefore, libgit2-sys and eden/scm share functions with the same signatures, but have different behaviours and when we tried to derive blame, it used libgit2-sys's xdl_diff instead of eden's. This resulted in getting segfaults (https://fburl.com/paste/04gwalpo).
Note: repo_import is the first tool that has tried to import both and the first to run into this issue.

Reviewed By: StanislavGlebik

Differential Revision: D22432330

fbshipit-source-id: f2b965f3926a2dc45de1bf20e41dad70ca09cdfd
2020-07-09 01:20:32 -07:00
Jun Wu
8e199e9a44 debugcomplete: show aliases with -v
Summary:
Make zsh_completion complete standard aliases like `checkout`.
This restores the behavior before D18463299 (54451585ce) stack.

Reviewed By: farnz

Differential Revision: D22396737

fbshipit-source-id: 745761041d6d1dec6adba2efb102e2021a01b36b
2020-07-07 16:47:45 -07:00
Jun Wu
dabce28285 repoview: further remove repoview references
Summary:
Since repoview is removed, those concetps are useless. Therefore remove them.

This includes:
- repo.unfiltered(), repo.filtered(), repo.filtername
- changelog.filteredrevs
- error.FilteredIndexError, error.FilteredLookupError,
  error.FilteredRepoLookupError
- repo.unfilteredpropertycache, repo.filteredpropertycache,
  repo.unfilteredmethod
- index.headsrevsfiltered

Reviewed By: DurhamG

Differential Revision: D22367600

fbshipit-source-id: d133b8aaa136176b4c9f7f4b0c52ee60ac888531
2020-07-06 14:04:27 -07:00
Paul Davis
e462d84681 Enable abort and continue use cases in zsh hg histedit autocompletion
Summary: Enable the most common autocomplete use cases in zsh hg histedit autocomplete

Reviewed By: fanzeyi

Differential Revision: D22032612

fbshipit-source-id: 1fd47d30564c51a010785d7d0553e3a5d16f163a
2020-06-15 12:16:53 -07:00
Jun Wu
812b9c546b contrib: remove obsstore related perf commands
Summary: This unblocks switching mutation on for test-contrib-perf.t

Reviewed By: sfilipco

Differential Revision: D21913605

fbshipit-source-id: 045e7ad7d71709e5f52171ab28b8da605fd2d540
2020-06-10 19:29:58 -07:00
Tao Zhao
b54708627b scm-prompt.sh: optionally show dirty state of working directory
Summary:
Added an optional feature to scm-prompt.sh to show the dirty state of the working directory.

Users need to opt in by set the environmental variable `SHOW_DIRTY_STATE` to yes (or whatever nonempty string) in their shell rc file. The idea is that users who do not need/want this feature should see minimal performance hit of their prompt.

Unfortunately, in some (large) repos, calling `hg status` or `git diff` to figure out the dirty state can slow down showing the prompt quite a bit. So, in this case, user can opt out individual repo by setting `shell.showDirtyState` in .hg/hgrc or .git/config.

Reviewed By: ahornby

Differential Revision: D21493543

fbshipit-source-id: 13f7cf2dd2f8d00b58cf2a63dc2cbbf770028411
2020-05-28 10:24:52 -07:00
Jun Wu
06f03628aa infinitepush: remove legacy auto pull logic
Summary: The revset autopull now covers the infintiepush autopull logic.

Reviewed By: DurhamG

Differential Revision: D21526664

fbshipit-source-id: 90cfdebc99bb69b3e45eadcbf4b0d764e0cd68c6
2020-05-14 12:47:35 -07:00
Mark Thomas
052e7c3877 check-code: convert to Python 3
Summary:
Update `contrib/check-code.py` to Python 3.

Mostly it was already compatible, however stricter regular expression parsing
revealed a case where one of our tests wasn't working, and as a result lots of
instances of `open(file).read()` existed that this test should have caught.

I have fixed up most of the instances in the code, although there are many
in the test suite that I have ignored for now.

Reviewed By: quark-zju

Differential Revision: D21427212

fbshipit-source-id: 7461a7c391e0ade947f779a2b476ca937fd24a8d
2020-05-07 09:07:50 -07:00
Mark Thomas
8788654efd i18n: use _x to signal untranslated strings
Summary:
The latest version of Black removes unneccessary parenthesis.  Mercurial's
test-check-code currently uses extra parentheses to signal untranslated strings, so
Black's reformatting breaks this test.

Capitulate to Black by adding a new `_x` translation marker that means "untranslated".

Reviewed By: quark-zju

Differential Revision: D21426335

fbshipit-source-id: a6c26d7c6365c49530a7dee3a5f9ed71ff166835
2020-05-07 09:07:49 -07:00
Jun Wu
3514ac0de8 remotenames: autopullprefix -> autopullpattern
Summary:
Patterns are more powerful than prefixes. Some full revset names are
obviously not valid remote name - for example, `remote/master :: .`.
They cannot be ruled out using prefixes but can using patterns.

As we're here, add some caching for the regex compiler.

Reviewed By: DurhamG

Differential Revision: D20831015

fbshipit-source-id: af8c4eed4a3153fd71480b8972c55feed4641392
2020-04-24 11:16:22 -07:00
Jun Wu
880b33b0b7 revset: implement auto pull for commit hashes using repo.pull API
Summary: This might remove less clean logic in infinitepush.

Reviewed By: sfilipco

Differential Revision: D20804855

fbshipit-source-id: da5ed24dd912b5f86839e671a9d6b0e9356b7c86
2020-04-24 11:16:20 -07:00
Thomas Orozco
56251513bf git-sl: remove Mercurial import
Summary:
This isn't actually a Mercurial extension, so we can't be importing Mercurial
imports here. I'm not sure this is actually being used because we apparently
have 2 copies of this (see D20793452, which is also how I came upon this), but
it's probably worth not breaking it.

Reviewed By: farnz

Differential Revision: D20794695

fbshipit-source-id: daaf0f5822567b55a787669073421fd1ce604e08
2020-04-02 12:32:34 -07:00
Alden Hu
64b98944d1 git-sl supports worktrees
Summary:
git started printing a "+" sign in front of a branch checked out in another worktree:
ab3138146f

and it breaks "git sl"

removing "+" the same way as "*" when parsing "git branch" result to resolve.

Reviewed By: krallin

Differential Revision: D20793452

fbshipit-source-id: 5c0b6be5afbed607b144c652f68a3ab93052f76a
2020-04-01 09:25:27 -07:00
Durham Goode
cb2e471763 treestate: make treestate a hard requirement
Summary:
We want to delete all the non-treestate dirstate implementations. Let's
start throwing an exception if treestate is not enabled. We temporarily have a
bypass in case we break an important usecase in the process.

This also sets the standard new repo to be created in treestate mode, but adding
treestate to newreporequirements.

This was landed once as D19204621 but was backed out because eden backing repos
were using the odl formats and hadn't been upgraded. We fixed that, and now the
data shows ~10 people still using repos in this condition
(https://fburl.com/scuba/dev_command_timers/zxb5hsg2). Some of them are broken
repos, some are ancient eden repos and a simple eden rm and eden clone should
fix them, some are simply old non-eden repos that no one has run commands in in a while.

Reviewed By: xavierd

Differential Revision: D20472234

fbshipit-source-id: 509b4f22b6ac4741b205ef69decfb26e56aebaf8
2020-03-16 18:39:52 -07:00
Adam Simpkins
1c6360fe73 add more annotations for edenscmnative.parsers
Summary:
Add type annotations for the `edenscmnative.parsers` methods that handle
serializing and deserializing the dirstate data.

Reviewed By: quark-zju

Differential Revision: D19958218

fbshipit-source-id: 6e20efbc1b0a6ba15b297e47a1e6eec8ed47ee52
2020-03-11 16:21:30 -07:00
Adam Simpkins
0bc787c4c0 remove the mercurial.policy module
Summary:
This module previously used to handle deciding how a particular module should
be imported if it had multiple versions (e.g., pure Python or native).
However, as of D18819680 it was changed to always import the native C version.

Lets go ahead and remove it entirely now.  Using `policy.importmod` simply
makes it harder for type checkers to figure out the actual module that will be
used.

The only functionality that `policy.importmod()` still provided was verifying
that the module contained a "version" field that looked like what was
expected.  In practice these version numbers are not bumped often, so this
doesn't really seem to provide much value in checking that we imported the
correct version that we expected to be shipped with this release.

Reviewed By: xavierd

Differential Revision: D19958227

fbshipit-source-id: 05f1d027d0a41cf99c4aa93cb84a51e830305077
2020-02-21 13:54:19 -08:00
Adam Simpkins
fabc6d628f start adding type annotations for the cext code
Summary:
Add *.pyi type stub files for most of the native C extensions.
This allows Pyre to type check functions that use these extensions.

These type annotations likely aren't complete, but contain enough information
to allow Pyre to pass cleanly on the existing type-checked locations in the
code using these modules.

Reviewed By: xavierd

Differential Revision: D19958220

fbshipit-source-id: 85dc39a16e595595a174a8e59e419c418d3531be
2020-02-21 13:54:19 -08:00
Adam Simpkins
6f824649ff use absolute includes to the third-party xdiff code
Summary:
Update includes to the third-party xdiff.h file to use absolute includes
from the repository root.  This allows many parts of our internal build
tooling to work better, including automatic dependency processing.

Reviewed By: xavierd

Differential Revision: D19958228

fbshipit-source-id: 341dd8c94f1138cf4a387b92e1817b2a286d6aa1
2020-02-19 13:05:06 -08:00
Adam Simpkins
d736cca388 fix type annotations in eden_dirstate_map.py
Summary:
Some of the methods in eden_dirstate_map.py had comments that were close to
type annotations that were added a couple years ago.  Update them to proper
type comments that can be recognized by Pyre and mypy.

Also remove the unused create_clone_of_internal_map() method.

Reviewed By: chadaustin, xavierd

Differential Revision: D19958225

fbshipit-source-id: b753c030acb15cf4f8d8c536614e657ee1bcba52
2020-02-19 13:05:05 -08:00
Carolyn Busch
d49c251d13 py3 iteritems -> pycompat.iteritems
Summary: More replacements of dict.iteritems with pycompat.iteritems(dict) for py3 compatibility.

Reviewed By: singhsrb

Differential Revision: D19704211

fbshipit-source-id: 544cb292c0241a293fc4ab83c3d9472dcf4328b6
2020-02-04 15:29:39 -08:00
Jun Wu
9602130aab py3: chg: fix compatibility
Summary:
Fix various type issues when running chg under Python 3.
Enable chg in setup3.py build.

This should make tests run faster. For example, test-rebase-detach.t
now completes in 8 seconds, down from 29 seconds.

Reviewed By: xavierd

Differential Revision: D19702535

fbshipit-source-id: 8928b1b920b9b52fd03dc86f996da18f2405f146
2020-02-03 18:26:57 -08:00
Zeyi (Rice) Fan
e214ad8df9 testing utilities py3 compatibility
Summary:
We temporarily pin these test tools to run with Python 2 so the tests can pass no matter if it is run with 3 or 2.

This diff also makes the fake biggrep client to be Python 3 compatible.

Reviewed By: farnz

Differential Revision: D19611681

fbshipit-source-id: 0c980165934899902b152e27a0a444d6a6c9eb2f
2020-01-29 17:07:32 -08:00
Mark Thomas
82715fd2ea py3: iter{keys,values,items} -> pycompat.iter{keys,values,items}
Reviewed By: quark-zju

Differential Revision: D19608323

fbshipit-source-id: dd186ef16d6422a56af41fcaa850d9838ae9a240
2020-01-28 16:27:28 -08:00
Genevieve Helsel
f0a27646b5 change maxint -> maxsize
Summary: ran print_function, maxint -> maxsize (maxint depreciated)

Reviewed By: lisroach, quark-zju

Differential Revision: D19588359

fbshipit-source-id: fc66b388a1775553a4b8e30a56fd1483800693d6
2020-01-28 10:37:53 -08:00
Adam Simpkins
3a71160859 py3: convert some encoding.environ uses to os.environ
Summary:
Our plan for switching to Python 3 is to update many types to use Unicode
strings when appropriate.  In particular, we should just go ahead and use
Unicode for environment variables, since this is the Python 3's default
behavior.

This drops the check-code.py check that warns developers against using
`os.environ` directly, and converts several call sites to use `os.environ`
directly instead of using `encoding.environ`

Reviewed By: markbt

Differential Revision: D19591566

fbshipit-source-id: e4ac44dcd5f19cd0bf65ac904fc85edad95a9aed
2020-01-27 21:23:19 -08:00
Durham Goode
b2cc1a40f3 contrib: update perf.py to wrap dirstate in a transaction
Summary:
As part of making the dirstate always participate in the transaction,
let's wrap it's use in perf.py.

Reviewed By: quark-zju

Differential Revision: D18213036

fbshipit-source-id: cd4a7d942556f032d32cbe0630d16414b819ea34
2020-01-14 17:49:03 -08:00
Jun Wu
5da0c6903d util: switch to Rust time parsing
Summary:
The Rust bindings now provide a subset of time parsing features.  Replace the
old Python implementation. This has multiple benefits:
- Strong gurarnatee that Rust and Python behave the same.
- Parse relative time (ex. `5 minutes ago`)
- Parse date beyound i32 range (ex. >= year 2038)

Reviewed By: DurhamG

Differential Revision: D18946332

fbshipit-source-id: 721f47bc5b2835d7ca0a05ab34ea4faa1a411a4e
2020-01-09 11:51:31 -08:00
Durham Goode
d8663cb534 treestate: backout making it a hard requirement
Summary:
It turns out some old repos are still using the legacy treedirstate
format, which broke when I made this a hard requirement. Let's roll this back
for now.

Reviewed By: singhsrb

Differential Revision: D19313773

fbshipit-source-id: ded78be033cb04323a2e1d237059947dee509df9
2020-01-08 11:33:28 -08:00