Commit Graph

460 Commits

Author SHA1 Message Date
Xavier Deguillard
c552dd8af8 bookmarks: add the items method to lazyremotenamedict
Summary:
The iteritems method doesn't exist in Python3, add the items one and remove the
pycompat.itermitems wherever we iterate over the lazyremotenamedict.

Reviewed By: quark-zju

Differential Revision: D20926027

fbshipit-source-id: de9d297126e8190f008cb5d09cc5a128d68c2213
2020-04-10 09:55:57 -07:00
Jun Wu
fe3be0bddd py3: fix test-import-t.py
Reviewed By: xavierd

Differential Revision: D20952872

fbshipit-source-id: bea03953576a76f6f65f908f4ce12f3082d02871
2020-04-09 18:44:06 -07:00
Jun Wu
05cd3783ba py3: fix test-import-git.t
Reviewed By: xavierd

Differential Revision: D20952870

fbshipit-source-id: a5b58195b7efa924f1e8806f920671dbaab1e724
2020-04-09 18:44:06 -07:00
Jun Wu
1fbbf9488e py3: fix test-import-context.t
Reviewed By: xavierd

Differential Revision: D20952874

fbshipit-source-id: 18e2db7a35612f9f33fbc49f0703b20abb880938
2020-04-09 18:44:05 -07:00
Jun Wu
4841a5c8cc py3: fix test-import-eol.t
Reviewed By: xavierd

Differential Revision: D20952875

fbshipit-source-id: ad85c492929b39757e255c1aedcb2bbaa582fce2
2020-04-09 18:44:05 -07:00
Jun Wu
470dfdc8f5 py3: fix test-import-bypass.t
Reviewed By: DurhamG

Differential Revision: D20952873

fbshipit-source-id: 3282c757830460b3e683958f09fe6e6870b4fb9a
2020-04-09 18:44:05 -07:00
Jun Wu
73f93a438b py3: fix test-help.t
Reviewed By: xavierd

Differential Revision: D20953745

fbshipit-source-id: 7d6dd303e5789ae8c0a6a32ed40d884aa1f24803
2020-04-09 18:25:54 -07:00
Jun Wu
514f0141f8 patch: use diffhelpers from Rust bindings
Summary:
Drop other diffhelpers implementations.
The Rust implementation does a better job on type checks and won't segfault.

Reviewed By: xavierd

Differential Revision: D20935367

fbshipit-source-id: f59240f3a661efe1ca6e451922bcb3ca6ee6ae22
2020-04-09 18:25:53 -07:00
Jun Wu
ccb8237545 py3: fix updatestate for eden update
Summary:
Solves the following issue.

  Traceback (most recent call last):
    File "eden_update.py", line 93, in update
      vfs.write("updatestate", destctx.hex())
      # destctx = <changectx 1364fe9f6141>
    File "vfs.py", line 142, in write
      return fp.write(data)
      # data = '1364fe9f61411a001b78bd2bb4bf556e0fdfb4d6'
  TypeError: a bytes-like object is required, not 'str'

Reviewed By: simpkins

Differential Revision: D20957027

fbshipit-source-id: f9d55b005c1686064278d22634f0b6ca9d8d8f86
2020-04-09 18:12:45 -07:00
Xavier Deguillard
ad34cc5476 bundle2: bunch of fixes for Python3
Reviewed By: DurhamG

Differential Revision: D20930267

fbshipit-source-id: 5df5f7d1fbcd4875b4ee93be8ff84f8190972770
2020-04-09 16:27:43 -07:00
Jun Wu
ab6c8cf9ac py3: fix test-rebaes-conflicts.t
Reviewed By: xavierd

Differential Revision: D20929677

fbshipit-source-id: 7e1a67b78b6eaaea8edb9a1a1241001d9f57f0f6
2020-04-09 13:20:36 -07:00
Durham Goode
f31d9f1f89 py3: fix streaming clone and bundle output
Summary: Makes test-bundle.t pass in python3

Reviewed By: quark-zju

Differential Revision: D20923758

fbshipit-source-id: 5e874cedc8419e87d1f9024c575ee6928805fad6
2020-04-09 09:23:54 -07:00
Xavier Deguillard
61e146d2ab patch: fix binhunk
Summary: The binhunk is for binary data, therefore we need to use byte strings.

Reviewed By: xavierd

Differential Revision: D20290069

fbshipit-source-id: 9cd763b76df389a1f7b65aecf0be4aa36a85cf91
2020-04-09 09:23:54 -07:00
Xavier Deguillard
3622204e43 util: keep bytesinput as unicode based
Summary:
On python3, no need to replace stdin/stdout with a bytes based one, keep them
as is.

Reviewed By: xavierd

Differential Revision: D20290068

fbshipit-source-id: b10b69185a52c79e7c67f69f6a8a96937c64a550
2020-04-09 09:23:53 -07:00
Durham Goode
df37fef5b3 py3: fix test-basics.t
Summary: Simple fix to output bytes

Reviewed By: xavierd

Differential Revision: D20921348

fbshipit-source-id: befa8abab0a7943fd2d20614dcacf3ef25f1e9ba
2020-04-09 09:23:53 -07:00
Xavier Deguillard
935b80f837 templater: diff is returning bytes chunks
Summary:
Not sure if this is the proper solution, but the template engine refuse to work
with anything but utf8 strings, but the diff operation only work on bytes.
Let's convert the return of diff to utf-8.

Reviewed By: DurhamG

Differential Revision: D20927680

fbshipit-source-id: 25c2947cac417448ca3521c2d5478fa8eebef04f
2020-04-09 09:10:57 -07:00
Xavier Deguillard
6dadf6fdd9 node: use binascii.Error in Python3
Summary:
In Python3, the error returned from binascii.unhexlify changed, from a generic
TypeError to a binascii.Error. Therefore, wrap the binascii function and catch
the binascii.Error before raising a TypeError.

Reviewed By: DurhamG

Differential Revision: D20924129

fbshipit-source-id: 33f852ea97396af715ef73630e0dd1b4324eb707
2020-04-08 23:46:09 -07:00
Stefan Filip
25fd8b9034 py3: fix test-hint.py
Summary:
I can't say that I understand `mdiff.splitnewlines`. In my test it does not
behave the way it reads and I don't know why. The stripping that it's supposed
to do doesn't happen for some reason. It behaves like splitlines.
I believe that rcutil used '\n' for line termination because it was relying on
Python to do the conversion to system line end. I updated to use os.linesep
now that we encode the contents.

Reviewed By: quark-zju

Differential Revision: D20935377

fbshipit-source-id: 0958fdff03950ab0a4b2da02e4333b5438ac5c70
2020-04-08 22:00:35 -07:00
Stefan Filip
5afca4fadd py3: fix test-manifest.py
Summary:
Bytes and Str usages mostly. __iter__ seems to have been incorrectly
converted to python 3 previously.

Reviewed By: xavierd

Differential Revision: D20933166

fbshipit-source-id: 10e63e90bd83c70a51dd808e9b5073ab8d766e71
2020-04-08 19:14:15 -07:00
Xavier Deguillard
76ecec0e57 bisect: make it python3 compatible
Summary: We should read/write to it via as utf8.

Reviewed By: DurhamG

Differential Revision: D20923404

fbshipit-source-id: 86cdc329395d60c88637f24d3c7c5caedcc7111a
2020-04-08 19:08:51 -07:00
Mark Thomas
c02f38dfb7 mutation: public commits are never obsolete
Summary:
The computation of commit obsolescence is inconsistent.  If we compute the full
set of obsolete commits in `mutation.obsoletecache.obsoletenodes`, then we
correctly ignore public commits as they cannot be obsolete.

However, if we compute the obsolescence state for a single public commit with
`mutation.obsoletecache.isobsolete`, and that commit somehow has a visible
successor, then we will incorrectly consider the commit as obsolete.

Similarly, `allpredecessors` and `allsuccessors` should stop when they hit a
public commit.

Reviewed By: quark-zju

Differential Revision: D20892778

fbshipit-source-id: 223cb8b2bc9f2f08124df6ff51c2eb208bb8eb5f
2020-04-08 06:33:14 -07:00
Jun Wu
4d951d777b util: add more APIs for pytracing
Summary: This makes the tracing features easier to use.

Reviewed By: DurhamG

Differential Revision: D19797703

fbshipit-source-id: fb5cb17cd389575cf0134a708bcd9df3b90e9ab4
2020-04-07 21:35:31 -07:00
Xavier Deguillard
d5793b1796 colors: do not disable colors in the pager
Summary:
Somehow, enabling VT can fail when writing to the pager, but this doesn't
mean that the pager doesn't support VT mode, so let's just ignore the error
when the pager is active.

Reviewed By: DurhamG

Differential Revision: D20906374

fbshipit-source-id: 7cba52817bc8e4dc91d5d50e856ad8af7fc9542c
2020-04-07 19:36:55 -07:00
Jun Wu
5a69be9e70 commands: add debugvisibleheads
Summary:
Add a command to print visibleheads. This was part of my attempt to check if
visibleheads can accidentally include public commits and if there are a way
to remove it. I ended up thinking D20808884 might actualy solve the only case
that visibleheads include public heads.

I also tried to add strong verification so that the visibility layer never
writes public nodes. That's for non-narrow-heads use-cases. However, the
phasescache + repoview layer is kind of messy in a way that inside a
transaction there is only one "repo" that has the right in-memory, dirty
"phasescache" and other repos will load the (stale, wrong) phasescache from
disk. That means if we test phases in visibility before transaction flushes,
we won't be able to access the latest phases information correctly. So I
gave up this approach too.

Anyway, I wasn't able to add a new interesting test, but the utility built for
the test seems useful. Therefore this change.

Reviewed By: sfilipco

Differential Revision: D20829136

fbshipit-source-id: 5ebafefac820ebb4044db63b7892ffaa341c0573
2020-04-07 19:10:45 -07:00
Jun Wu
42b1577340 context: provide what commit it is when we cannot load the manifest
Summary:
The manifest node is hard for debugging. Attach the commit as the context and
print it out.

Reviewed By: sfilipco

Differential Revision: D20829139

fbshipit-source-id: ff65d902f56bc79c2d5f2c3ec9cf79a620fd70fc
2020-04-07 19:05:03 -07:00
Jun Wu
35659be2a5 error: add a way to provide context to errors
Summary:
This allows providing context about errors, similar to Rust's "context"
features.

Reviewed By: sfilipco

Differential Revision: D20845160

fbshipit-source-id: 789a4c1b7356fd6eb4b1bcb71efd205d2d45e984
2020-04-07 19:05:03 -07:00
Jun Wu
6a09828a7f pager: add "internal:streampager" as an option to use the Rust pager
Reviewed By: DurhamG

Differential Revision: D20887175

fbshipit-source-id: 6b4cec2ce83578fe39bc3058d09cbb42b32a9d78
2020-04-07 15:57:07 -07:00
Jun Wu
9715911327 templatekw: fix predecessors with only mutation enabled
Summary: The template should use mutation instead of obsutil if mutation is enabled.

Reviewed By: markbt, simpkins

Differential Revision: D20901109

fbshipit-source-id: a2b587ddf2a03965886f753e54e075d5d9064f05
2020-04-07 15:11:30 -07:00
Stefan Filip
d1ba21803a version: warn users when they are running an old build
Summary:
Old is defined by being based on a commit that is more than 30 days old.
The build date is taken from the version string.
One observation is that if we fail to release in more than 30 days then all
users will start seeing this message without any way of turning it off. Doesn't
seem worth while to add a config for silencing it though.

Reviewed By: quark-zju

Differential Revision: D20825399

fbshipit-source-id: f97518031bbda5e2c49226f3df634c5b80651c5b
2020-04-07 14:25:38 -07:00
Xavier Deguillard
ffc487e2de color: do not try to enable VT mode for tests
Summary:
Tests are redirected, but we still want colors in them (to verify that ANSI
escape code works). Since VT mode will always fail, simply do not try to
enable it in this case.

Reviewed By: DurhamG

Differential Revision: D20875423

fbshipit-source-id: bd6b0046de9558d957e0df082d4392ad00e0b551
2020-04-06 13:07:52 -07:00
Xavier Deguillard
46d13ee650 ui: cache formatted
Summary:
Somehow the constant isatty and config reading shows up in my profile. Since
this is not intended to change, just cache it.

Reviewed By: DurhamG

Differential Revision: D20830511

fbshipit-source-id: de36c0a958f6a6046a05db0abf976994435b9e3c
2020-04-06 11:10:53 -07:00
Xavier Deguillard
d0b63fcd01 color: only warn about VT mode when formatted
Summary: We don't want tests to show this warning.

Differential Revision: D20851847

fbshipit-source-id: bae87a980a2da4088aff6ed0b4a3a85971166817
2020-04-06 08:48:58 -07:00
Xavier Deguillard
7bcf163d55 color: remove all the win32 terminal handling
Summary:
Let's mandate a 256 color terminal in Windows. We also update less to default
to using VT mode: https://github.com/gwsw/less/pull/29

With this, the colors appears to be working as expected on Windows!

Reviewed By: quark-zju

Differential Revision: D20826922

fbshipit-source-id: 5d2a149e2698b3ccc7bf6388b5cd97da20898eb7
2020-04-03 13:47:32 -07:00
Xavier Deguillard
01e921aa19 crecord: fix windows arrow keys
Summary:
For whatever reason, ncurses doesn't interpret the arrow keys properly... Use
whatever is returned from it instead.

Reviewed By: kulshrax

Differential Revision: D20821432

fbshipit-source-id: 019426a1333538a479fb3dd8d147fb9cb4ba6559
2020-04-03 08:26:26 -07:00
Jun Wu
4ae44e316a remotenames: move repo._accessedbookmarks to core repo._remotenames._accessedbookmarks
Summary:
Move the attribute so it won't cause an AttributeError when remotenames is not
enabled.

As we're here, also move it to repo._remotenames from repo. This makes the repo
object a bit clearner and avoids loading the accessed bookmarks if remotenames
are not accessed at all.

Reviewed By: singhsrb

Differential Revision: D20821070

fbshipit-source-id: b5a01016451ee202f778cadb2dd418400406fa6b
2020-04-02 19:25:33 -07:00
Jun Wu
2aec2dbcb6 commitcloud: migrate to tech-debt-free repo.pull for pulling
Summary:
The new API does nothing that cloud sync does not want: bookmarks, obsmarkers,
prefetch, etc. Wrappers to disable features are removed.

This solves a "lagged master" issue where selectivepull adds `-B master` to
pull extra commits but cloud sync cannot hide them without narrow-heads. Now
cloud sync just does not pull the extra commits.

Reviewed By: sfilipco

Differential Revision: D20808884

fbshipit-source-id: 0e60d96f6bbb9d4ce02c04e8851fc6bda442c764
2020-04-01 19:40:57 -07:00
Jun Wu
5730719bd9 revset: automatically pull remote bookmarks prefixed remote/ or default/
Summary:
This makes it possible to do things like `hg up remote/foo` without having to
`hg pull -B foo` first.

Reviewed By: DurhamG

Differential Revision: D20531122

fbshipit-source-id: e95b2f0a49e4b815c136450d1f352a7973cb72ed
2020-04-01 19:40:55 -07:00
Jun Wu
707b7dea42 localrepo: add a tech-debt-free repo.pull API
Summary:
The new `repo.pull` API aims to be tech-debt free. It does:
- Pull nothing instead of everything if nothing is specified.
- Update remote names that are explicitly specified, not everything the server
  has.
- Do not update local bookmarks.

The direct motivation is to implement autopull `remote/foo` behavior while not relying on the pull command.

Reviewed By: DurhamG

Differential Revision: D20531119

fbshipit-source-id: 80c3bdd5556126d81af099a74f1345ecc94904b7
2020-04-01 19:40:55 -07:00
Jun Wu
bd4ac25e5f infinitepush: move listkeyspatterns to core
Summary: This will be used by the next diff.

Reviewed By: DurhamG

Differential Revision: D20661056

fbshipit-source-id: 3b4793bc0737bd64196da5b99c2d4da6f5e48efb
2020-04-01 16:58:33 -07:00
Mark Thomas
0d4db87a26 cmdutil: add a hint for the new graph renderer
Summary: Add a hint that points to customization and troubleshooting guides for the new graph renderer.

Reviewed By: xavierd

Differential Revision: D20763338

fbshipit-source-id: ee6d2464ae5955f0f0bf52d1994adfa2b74b3367
2020-03-31 09:57:44 -07:00
Xavier Deguillard
2c052d055d eden: commitpending doesn't exist in ContentStore
Summary:
Instead, it's present in the fileslog. Use that instead.

This is the error I just got while doing a `hg top`:
error updating fbcode/eden/scm/lib/revisionstore/src/contentstore.rs: facebook::eden::HgImportPyError: AttributeError: 'bindings.revisionstore.contentstore' object has no attribute 'commitpending'

Reviewed By: quark-zju

Differential Revision: D20715560

fbshipit-source-id: 59c4b62ae8d0f182824e126e68b174c0ef3cdba0
2020-03-30 09:05:36 -07:00
Jun Wu
ebdc3836b9 narrowheads: fix repo requirements at "hg init" time
Summary:
Some tests fail because `hg init` sets the wrong initial store requirements and
then perform a narrow-head migration down, which prints extra messages. Fix them
by making sure the initial store requirements are the same as what the migration
code path expects.

Reviewed By: simpkins

Differential Revision: D20698637

fbshipit-source-id: 1422a4ea78222617d0e3f9631ad883d5a3fe6bb7
2020-03-27 12:55:06 -07:00
Jun Wu
8bd55436a4 pull: automatically pull selective bookmarks unless it's a no-argument pull
Summary:
This enforces certain selective pull logic in core. Namely, rewrite `pull -r X`
to `pull -r X -B master`.

Unlike selectivepull in remotenames, `pull` (pulls everything) won't be
rewritten to `pull -B master` (which pulls less commits and names).

Therefore this change always adds more commits to pull, and therefore should not
break existing users. Eventually we want the "not pulling everything" behavior,
but right now this just fixes `pull -r X` to also update important remote names.

Reviewed By: markbt

Differential Revision: D20531121

fbshipit-source-id: af457b5ddb1265b61956eb2ee6afb7b7208293e0
2020-03-26 10:54:09 -07:00
Jun Wu
e105af5a54 exchange: replace remotenames.important-names with selectivepull names
Summary: Now we have functions to get selectivepull names in core. Use that instead.

Reviewed By: markbt

Differential Revision: D20531118

fbshipit-source-id: a0c20c491baf1b0ad71e80f870703bb4b983f19c
2020-03-26 08:26:27 -07:00
Jun Wu
c7549d5b71 remotenames: move selective pull bookmarks calculation to core
Summary: This makes it possible for core to always pull related bookmarks.

Reviewed By: markbt

Differential Revision: D20531120

fbshipit-source-id: 52f0834b517e03567e240f57616370d79a227abe
2020-03-26 08:26:27 -07:00
Jun Wu
baae0138ff remotenames: move revset and templatekw to core
Summary:
This makes it possible to use template like `{remotenames}` or revset like
`remotenames()` without enabling the remotename extension.

Rarely used revsets like `upstream()` and `pushed()` are not moved.

Reviewed By: markbt

Differential Revision: D20529360

fbshipit-source-id: ea95b3324f974e112909cdd79ce662940a4f9b7c
2020-03-26 08:26:26 -07:00
Jun Wu
cc1b1bd6a9 remotenames: move namespace to core
Summary:
This makes it possible to resolve remotenames without enabling the remotenames
extension.

The config check `if repo.ui.configbool("remotenames", "bookmarks")` is dropped
intentionally as we only use remotenames for bookmarks, not named branches.

Since this only enables resolving more names, without disabling or changing
other features, and the remotename namespace priority is lower than local
bookmarks (ex. if a local `master` exists, then `master` will be using the
local bookmark, not the hoisted remote name), it should not cause breaking
changes.

Reviewed By: markbt

Differential Revision: D20529359

fbshipit-source-id: 4126faee1bb7f43ba547fab05dd6197b2e65c1fc
2020-03-26 08:26:26 -07:00
Jun Wu
a94f29c65a remotenames: move repo._remotenames to core
Summary:
This moves part of remotenames that provides the `repo._remotenames` object to
core.  It should not change behaviors but merely makes `repo._remotenames`
available in core.

Reviewed By: markbt

Differential Revision: D20529358

fbshipit-source-id: 11c8538a0190101b09a4cb082018e73643a257e2
2020-03-26 08:26:26 -07:00
Xavier Deguillard
16f09d25a3 pyworker: add a retry backchannel to Python
Summary:
While failures in the Rust updater aren't expected, at least one valid case
requires requires retrying the operation in Python: old-style LFS pointers.
When these are stored in packfiles/indexedlog, only the Python code knows how
to deal with them, and thus the operation needs to be retried there.

Reviewed By: DurhamG

Differential Revision: D20603709

fbshipit-source-id: 7d24ba573f0ff540906d909f1b4440fd4d3469a6
2020-03-25 12:29:26 -07:00
Durham Goode
c9c381a744 extras: force commit extras to be type str
Summary:
When we deserialize commit extras they come out as a str->str dict, so
let's make sure clients add values that are also strings. We do this by type
checking a serialization time. This fixes an issue where D19942522 assumed
extras were strings and hit a type error for globalrevs, which were ints.

Apparently the code that reads globalrevs from the extras never treats it as an
int anyway, so none of the reading code needed to be updated to convert the
string back to an int.

Reviewed By: singhsrb

Differential Revision: D20631889

fbshipit-source-id: 8c8b3c9a9f3369376e08146d670f2d6321df141f
2020-03-24 18:30:03 -07:00