Commit Graph

44251 Commits

Author SHA1 Message Date
Mark Thomas
d2c1764909 store: encode even longer names further
Summary:
The long filename encoding method introduced in D8527475 is insufficient for
files that have very long names that include some underscores.

For these files, we encode the underscores as `:`.  This character is valid for
filenames on Linux, but won't work on Windows.

Reviewed By: mitrandir77

Differential Revision: D9967059

fbshipit-source-id: 67ea662f48f9fcc40e00b36c86697f3be6aac978
2018-09-20 08:35:09 -07:00
Liubov Dmitrieva
0d0be6dc2a commitcloud: fix for reading option from the config
Summary:
this is a boolean option and the correct function should be used

Basically it was always true.

secrets_tool is our keychain like infrastructure, that is used to backup tokens.

This makes tokens available on any machine once backed up.

Reviewed By: ikostia

Differential Revision: D9967198

fbshipit-source-id: 8c1d8fc6b7a560c3e8879451c0c898717967f7dc
2018-09-20 08:05:42 -07:00
Liubov Dmitrieva
430e4a9160 commitcloud: mirror types we use must respect thrift types: fix date field type string->float
Summary: Date field is double in thrift schema of Commit Cloud Service.

Reviewed By: markbt

Differential Revision: D9952540

fbshipit-source-id: f07aa213e6ac3d534afd776dd248ca56c2f73f29
2018-09-20 08:05:42 -07:00
Liubov Dmitrieva
75817a809e commitcloud: make port and TLS options configurable to connect to Commit
Reviewed By: markbt

Differential Revision: D9942698

fbshipit-source-id: b0426498d67cea84d3831ee46a29b32145edb46e
2018-09-20 05:50:53 -07:00
Harvey Hunt
b9debb9853 Add python bindings to BookmarkStore
Summary:
Create Python bindings so that the BookmarkStore can be interacted with
from Python.

Reviewed By: quark-zju

Differential Revision: D9768565

fbshipit-source-id: 00d75b5250d8bc7dbeddd90d80ff4a23c60d00f9
2018-09-20 05:05:08 -07:00
Harvey Hunt
70a0c74d3b Implement a bookmark store for managing mercurial bookmarks
Summary:
Create a storage object that can be used to load bookmarks from a
mercurial file, modify and query the bookmarks in memory and then write back
to a mercurial bookmark file.

Reviewed By: quark-zju

Differential Revision: D9768564

fbshipit-source-id: ed469d0e588ae2200d614bf62a5a0b577e7c6f74
2018-09-20 05:05:08 -07:00
Harvey Hunt
c507d4e818 Implement Display trait for revisionstore Node
Summary:
Copy functions from Mononoke to implement the Display trait
for a Node.

Reviewed By: quark-zju

Differential Revision: D9768566

fbshipit-source-id: 6961026a9e4cdaf4a0f2592dc9284abebadb0aa3
2018-09-20 05:05:08 -07:00
Liubov Dmitrieva
058d65c5cc commitcloud: improve error messages for external shell out commands
Summary: this diff improves errors for security commands we use to store tokens on OSX

Reviewed By: markbt

Differential Revision: D9943539

fbshipit-source-id: 1b59ed22d8d524c6b9b1b4ddda5c73276c19c6e8
2018-09-20 04:22:59 -07:00
Jun Wu
b212efa921 configparser: preserve leading new-lines
Summary:
Preserve leading (but not tailing) new lines so the config (where `_` denotes a
space):

  x_=__
  __Foo
  __

is parsed as `"\nFoo"`.

This is useful in template configs.

Reviewed By: ryanmce

Differential Revision: D9929764

fbshipit-source-id: e30659df94937c7c2121627f42ea425191003fb1
2018-09-19 11:54:22 -07:00
Mark Thomas
a533c07518 commitcloud: revive commits that are visible in the cloud
Summary:
When syncing with the commit cloud, if we have commits that are hidden locally,
but visible in the cloud workspace, and no local obsmarkers waiting to be
synced, revive the cloud-visble commits.

This prevents two repos from oscillating between two views when they have
a conflicting set of obsolescence information that has not been cloud shared.

Reviewed By: liubov-dmitrieva

Differential Revision: D9845984

fbshipit-source-id: 2f44ff8dbc636e2afa56d5efbb3ea5114472c41c
2018-09-19 02:34:56 -07:00
Mark Thomas
216c7fc2c5 commitcloud: add test demonstrating workspace oscillation
Summary:
If two repositories have conflicting obsmarker information that has not been
shared through commit cloud, then they can enter a state where they fight over
the visibility of the commit, and the cloud workspace oscillates between two
views.  This adds a test to demonstrate this occurring.

Reviewed By: quark-zju

Differential Revision: D9845983

fbshipit-source-id: d5c74bed25da5721f273e53df10bf7b88efe2850
2018-09-19 02:34:56 -07:00
Saurabh Singh
79f9165070 gitrevset: move to using namespaces instead of wrapping stringset
Summary:
Using namespaces is a much cleaner and predicable way to handle commit
identifiers. Therefore, it makes sense to migrate to using namespaces in place
of stringset.

Reviewed By: quark-zju

Differential Revision: D9888462

fbshipit-source-id: 848445a508f1d814f90e32ff24b9366461841e36
2018-09-17 17:05:23 -07:00
Saurabh Singh
c1e276b215 globalrevs: do not wrap extensions if hgsql is bypassed
Summary:
In the current implementation, the `globalrevs` extension complains if
the `hgsql` extension is enabled but bypassed. This creates issues in cases
where the `hgsql` extension is bypassed intentionally as in D5012225. This
commit changes the logic in `globalrevs` extension to not wrap any extensions
if the `hgsql` extension is bypassed intentionally instead of raising an
exception.

Reviewed By: quark-zju

Differential Revision: D9883231

fbshipit-source-id: c57eaad4f661b69752a6457e6ecdd43f377285c1
2018-09-17 13:22:05 -07:00
Saurabh Singh
90a0b1f22d fbconduit: move to using namespaces instead of wrapping stringset
Summary:
Using namespaces is a much cleaner and predicable way to handle commit
identifiers. Therefore, it makes sense to migrate to using namespaces in place
of stringset.

Reviewed By: quark-zju

Differential Revision: D9843833

fbshipit-source-id: 7f1a6ea23d0abb6a46058226e7b4a30803a88f86
2018-09-17 12:36:58 -07:00
Saurabh Singh
757dadbeb9 fbconduit: remove the prefix lookup for subversion repositories
Summary:
It seems the preferred way is using something like:

```
hg log -r r<number>
```

There have been no successful runs for the command using the prefix `rE` in
last 180 days: https://fburl.com/scuba/e0yknasz. And we haven't heard any
complaints from the users around the same. It seems safe to delete the code
relating to this.

Reviewed By: quark-zju

Differential Revision: D9844080

fbshipit-source-id: ebe9f9de70b505e77f9871e3246846983369ed32
2018-09-17 10:22:02 -07:00
Mark Thomas
ab55bd31c6 newdoc: fix test failures and warnings
Summary:
Remove newdoc from test-check-code - it's a Sphinx project, so MiniRST
checks don't apply.  Also remove the unused imports from the Sphinx config
file.

Reviewed By: farnz

Differential Revision: D9851834

fbshipit-source-id: c17e83fd96d39423eeedfb8a6cfae382f88c4d5f
2018-09-17 08:56:40 -07:00
Mark Thomas
f0957edea7 newdoc: Add documentation from the upstream Mercurial wiki
Summary:
Add information about writing and debugging tests and extensions, as well as
some internals documentation.

Reviewed By: quark-zju

Differential Revision: D9789497

fbshipit-source-id: f1123ea85e76d4ab919dafa26a13142b6cddb3c9
2018-09-17 03:35:14 -07:00
Mark Thomas
7772a2e653 newdoc: add skeleton for Developer Guide
Summary: Add a skeleton for a new Developer Guide.  This is built using Sphinx.

Reviewed By: quark-zju

Differential Revision: D9789496

fbshipit-source-id: d32233e76701789ca5f2327bea270a366776b34e
2018-09-17 03:35:14 -07:00
Mark Thomas
0ca4acd250 localrepo: add storerequirements feature
Summary:
Add the `storerequirements` feature to the repo.  This means the store may have
a `requires` file, and clients must check it for any store features that they
may be missing.  This allows new requirements to be added that affect the store
when the repo is shared.  Currently there are no store features.

This commit adds support for the feature, and only new repos have the
requirement added.  A future commit will optimistically upgrade repos to
include the requirement.

Reviewed By: quark-zju

Differential Revision: D9699156

fbshipit-source-id: 95c1ab6973d44c02abc69b78a15311fe6a8696fd
2018-09-15 03:22:34 -07:00
Mark Thomas
1b115babba share: add a test demonstrating bad behaviour with requirements
Summary:
The share extension doesn't currently check the requirements of the shared
repo.  This means the shared repo's requirements can't be used to stop older
versions of Mercurial modifying future store versions that they don't
understand.

Reviewed By: quark-zju

Differential Revision: D9699169

fbshipit-source-id: 5a3a6d3389ecd682168f2660b425f4d762771f99
2018-09-15 03:22:34 -07:00
Mark Thomas
b3b2341088 scmutil: allow filecache to use multiple vfss
Summary:
Allow the filecache class to take tuples of `(filename, joiner)` as well as
just filenames.  The joiner overrides the `filecache.join` method for that
specific filename.

This will be used in a future change where we want to use multiple vfs objects
for a single filecache.

Reviewed By: quark-zju

Differential Revision: D9699157

fbshipit-source-id: 7d67c9e604d15a1832dc0fbfccb2fc443631f677
2018-09-15 03:22:34 -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
Jun Wu
a9ed32f839 tests: set maxdifflines to 1000 for buck test
Summary:
Buck test does not print outputs directly to the terminal. So it's better to
not limit the diff size.

Reviewed By: singhsrb

Differential Revision: D9842709

fbshipit-source-id: f17c7321d75761fdac21b9def52dec38f7e0b60c
2018-09-14 19:05:35 -07:00
Jun Wu
fb02b06bab fsmonitor: add 'debugrefreshwatchmanclock' command
Summary: See the command docstring for the use-case.

Reviewed By: phillco, strager, singhsrb

Differential Revision: D9836447

fbshipit-source-id: 22ff603ce3e0cd95ea4e400ed24a96c0ea636e6b
2018-09-14 18:25:52 -07:00
Saurabh Singh
e6f4ea31d3 namespaces: make specifying namespace priority mandatory
Summary: This would lead to less surprises than using the default priority.

Reviewed By: quark-zju

Differential Revision: D9818647

fbshipit-source-id: 59214eff84ea0b485ab8ff42b86df1c605a319f5
2018-09-13 16:53:54 -07:00
Saurabh Singh
1030d2b7e5 namespaces: remove redundant name specification in namespace object
Summary:
This is unnecessary after the recent modifications in the namespace
code.

Reviewed By: quark-zju

Differential Revision: D9815973

fbshipit-source-id: d7c6b07226be35ebbbe5354d5c520c9807cc0aa6
2018-09-13 13:59:38 -07:00
Jun Wu
b9e5d34651 distutils_rust: reformat
Summary: Solves a "trailing spaces" issue complained by test-check-code.t

Reviewed By: phillco

Differential Revision: D9815679

fbshipit-source-id: f7e93ea69a1462a3ac1cd675f181d5cd0bdbc5f5
2018-09-13 13:26:32 -07:00
Jun Wu
1d63ffc25a lock: remove stale POSIX symlink lock automatically in makelock
Summary:
Previously, removing stale POSIX lock is done at different places:

- Stale flock lock is removed by `posix.makelock`. The "read + check + unlink"
  is done atomically (taking the directory lock).
- Stale (legacy) symlink lock is removed by `lock.py`.
  The "read + check + unlink" is not done atomically, which seems like a scary
  bug [since 2016](d314a89fa4).

This patch cleans the logic up so removing stale POSIX lock is done
properly at `util.makelock`.

Note that Windows logic is not changed yet, so it's in theory broken.
Ideally we'd like to use flock-ish locking on Windows too. But that's
outside the scope of this diff.

Reviewed By: ikostia

Differential Revision: D9770935

fbshipit-source-id: fc58f30348f8a9aba22df415c6d2b2dfeb6a87d9
2018-09-13 12:20:51 -07:00
Jun Wu
a58e75fae8 lock: unlink temporary symlink placeholder on POSIX
Summary:
On POSIX, a lock is created in these steps:

  1. Take the directory lock to make "test stale lock & unlink" atomic.
  2. Test and remove stale lock.
  3. Create a legacy symlink (placeholder) lock.
  4. Create a temporary file, flock it.
  5. Rename the temporary file to override the symlink lock.

Step 3 is to be compatible with legacy hg programs. However, the error handling
is not great - in case 4 or 5 errored out (ex. Ctrl+C), the symlink file is left
untouched. This diff removes it.

Reviewed By: ikostia

Differential Revision: D9770936

fbshipit-source-id: a004d6326381e304552088bcf322c052254321dd
2018-09-13 12:20:50 -07:00
Kostia Balytskyi
0380c26787 hg: make distutils_rust support long paths on Windows
Summary:
This makes sure that we can instruct `setup.py` to make every Rust binary
long-paths aware on Windows. Yay.

Reviewed By: markbt

Differential Revision: D9809915

fbshipit-source-id: e58787d41c7e8bc5698283fd67dfb3cc6d21321d
2018-09-13 09:35:18 -07:00
Mark Thomas
4df24e1861 treemanifest: don't truncate list of candidate manifests
Summary:
`treemanifest._generatepackstream` truncates the list of possible base
manifests to length 2, because `cstore.treemanifest.walksubdirtrees` can only
support two base trees to compare against.  However, it does this too soon, we
can select a different 2 base manifests for each comparison out of the possible
pool.

Reviewed By: quark-zju

Differential Revision: D9788298

fbshipit-source-id: 4ba8753ccc34e09563bebdf90602211a999a02ea
2018-09-13 03:51:34 -07:00
Mark Thomas
361c96f1d3 treemanifest: add test demonstrating compare trees problem
Summary:
This test arranges it so that `treemanifest._generatepackstream` is called with
three possible base manifests, each of which is appropriate for a different
commit.  Because this function truncates the list of candidate base manifests
too soon, we end up with too much data in the bundle.

Reviewed By: quark-zju

Differential Revision: D9788299

fbshipit-source-id: 2147a63108e11750083862abc73c386867549ba2
2018-09-13 03:51:34 -07:00
Mark Thomas
89143e87a9 treemanifest: add debugbundle handler for treeparts
Summary:
Add a debugbundle handler for treemanifest tree parts.  At the moment this just
prints out the size of the treepart.  In the future it can be extended to show
more information.

Reviewed By: quark-zju

Differential Revision: D9788297

fbshipit-source-id: c298548062ab48e6589b1c0f3e502590168eddbf
2018-09-13 03:51:34 -07:00
Jun Wu
1b3e623616 entrypoint: add missing "#!" header
Summary: Otherwise `./entrypoint.py` will be executed as a shell script.

Reviewed By: singhsrb

Differential Revision: D9800130

fbshipit-source-id: 656fb37aae97f1d5757a3f5bba0af701abc84d03
2018-09-12 16:44:28 -07:00
Jun Wu
67db9ced8b test-check-execute: make it a fast test
Summary: `hg files .` is fast. Therefore use it.

Reviewed By: singhsrb

Differential Revision: D9800126

fbshipit-source-id: d22c42599f7a4e923d0261f6cd670dd111965ef9
2018-09-12 16:44:27 -07:00
Jun Wu
aab14173e3 helpers-testrepo: fix the script
Summary:
Broken by D7563731.  Running `exec` in a test will replace the test process.
That means the tests are basically doing nothing. Wrap `exec` in a subshell to
fix it.

Reviewed By: singhsrb

Differential Revision: D9800124

fbshipit-source-id: d4f7f29502dcd2db542f5dd03827a06cc9abd783
2018-09-12 16:44:27 -07:00
Jun Wu
bc116de7f7 entrypoint: do not use util.platform
Summary: `util.platform.x` is anti-pattern. Use `util.x` instead.

Reviewed By: phillco, singhsrb

Differential Revision: D9800127

fbshipit-source-id: 3edf0324622b7eeade9e8dc9b007a093dd8bf4a9
2018-09-12 16:44:27 -07:00
Saurabh Singh
6187668183 globalrevs: add namespace to lookup based on global revision numbers
Summary:
We need to look up commits in the repository based on the strictly
increasing global revision numbers. This commit adds the following way of doing
so:

 - `m<number>`: `hg log -r m<number>` would match the commit having `number` as
   the strictly increasing global revision number.

Reviewed By: quark-zju

Differential Revision: D9764819

fbshipit-source-id: b9d3a80852c7acebd0c939a4d4f43c3c9a6cb0ab
2018-09-12 15:09:30 -07:00
Jun Wu
2866deab96 entrypoint: do not follow symlink when resolving libdir
Summary:
Buck dev build uses symlinks. Following them would insert wrong libdir in
`sys.path`.

Reviewed By: simpkins

Differential Revision: D9794884

fbshipit-source-id: 14111d0d61ded33f500e2a5d5474a29b175d861c
2018-09-12 14:50:33 -07:00
Alexandre Marin
cdd06e9ef2 importer - correctly deal with p4 changelist description encoding
Summary:
This fix uses mercurial's encoding.tolocal on the Perforce changelist description
instead of trying to decode it as ascii and ignoring/throwing away non-ascii
characters.

Reviewed By: singhsrb

Differential Revision: D9777614

fbshipit-source-id: 713bd63831c965687b7328de06016b4f351b0469
2018-09-12 14:21:48 -07:00
Jun Wu
b398eaaa6e namespaces: define builtin namespaces with priorities
Summary:
Migrate builtin namespace definition to use the registrar. So we can deprecate
`addnamespace`.

`after` is not expressive enough in certain cases, although it's easier to
understand. Add a `priority` parameter for more explicit ordering handling.

Reviewed By: singhsrb

Differential Revision: D9780363

fbshipit-source-id: 85b9cfb91a7c937eea95f2a279a43c11e561b5fc
2018-09-12 12:35:28 -07:00
Jun Wu
acc7039436 configparser: permit spaces in more cases
Summary:
Be more permissive about spaces. Namely:
- Spaces after a section name like `[foo]    ` are allowed.
- Spaces in config names are allowed.
- Spaces at trailing lines are ignored and no longer insert an `\n` to the previous config.

This makes it closer to the older config parser behavior. But it's still
different on some cases, like `[foo]]`, `[foo] # bar`, `[foo]]` still do not
parse.

Benchmark shows no obvious (within 10%) slowdown. So this is probably fine.

Reviewed By: strager

Differential Revision: D9620253

fbshipit-source-id: 8489ef8e83606d0557db56e8da0a017d55ff1514
2018-09-12 12:05:32 -07:00
Jun Wu
0d525a00c6 remotenames: migrate to use registrar
Summary:
This makes it easier and cleaner for other extensions to specify namespace
orders. Eventually we'd make the old way to add namespaces private.

Reviewed By: singhsrb

Differential Revision: D9780361

fbshipit-source-id: 25b96d87a1372a4bb177224804423cc423c86c20
2018-09-11 19:51:56 -07:00
Jun Wu
1dc9519dda registrar: add a namespace predicate
Summary:
Previously, there is no easy API to add a namespace with desired order. There
is `extensions.afterloaded`, but that only works for `ui/extsetup`, not for
`reposetup`.

This diff add a namespace predicate so registering a namespace is similar to
registering a revset. It also provides an optional `after` parameter to define
the desired order, like:

  from mercurial import registrar, namespaces

  namespacepredicate = registrar.namespacepredicate()

  namespacepredicate("svn", after=["remotenames"])
  def svn(repo):
      return namespaces.namespace("svn", ...)

Existing namespaces will be migrated by upcoming changes.

This is useful for things wanting to resolve custom names, like globalrevs and
commit cloud.

Reviewed By: singhsrb

Differential Revision: D9775703

fbshipit-source-id: f15827b042d605b9cebc1ee1af6479903f47ee9c
2018-09-11 19:51:56 -07:00
Jun Wu
8a42f77192 test-pushvars: add a test about Python hook
Summary:
The Python hook got "kwargs" without "HG_" prefix. Add an explicit test for it.

Also remove unnecessary configs and change the shell to bash, since we don't
run tests using vanilla "sh".

check-code is updated so it no longer complains about the use of `bash`.

Reviewed By: markbt

Differential Revision: D9561962

fbshipit-source-id: 76a190dde1b0aeb0032a65c173ce6368a28e8cf6
2018-09-11 18:06:13 -07:00
Jun Wu
02ea73b1d5 test-fileset: fix the test on Windows
Summary:
The previous pattern coverts "\\" to "/" too aggressively. Fix the following
test:

  --- test-fileset.t
  +++ test-fileset.t.err
  @@ -50,7 +50,7 @@
     a2
     $ fileset 'a_b'
     $ fileset '"\xy"'
  -  hg: parse error: invalid \x escape
  +  hg: parse error: invalid /x escape
     [255]

Reviewed By: markbt

Differential Revision: D9550579

fbshipit-source-id: db3e32ba90f0c356e5837c692528d546fdd57be4
2018-09-11 18:06:12 -07:00
Jun Wu
ffcb92c371 infinitepush: escape file paths on Windows
Summary:
I got paths like:

   c:\\....\\c:\\....\

I guess that comes from a simple `os.path.join` with repo root.
Escape the path so it works on Windows.

Reviewed By: markbt

Differential Revision: D9550577

fbshipit-source-id: 0a2624ec0686df10ecf9cda8d50965354f04cecf
2018-09-11 18:06:12 -07:00
Jun Wu
4d602995eb datapack: call refresh less frequently
Summary:
Refresh happens if `time.time() > lastrefresh + REFRESHRATE (0.1)`.
`lastrefresh` is previously set before the actual refresh logic. That is
problematic if the refresh itself took more than 0.1 seconds, in which case the
refresh logic will be performed too frequently.

Set `lastrefresh` after the actual refresh logic to make it better.

Reviewed By: phillco

Differential Revision: D9770954

fbshipit-source-id: 06d7aa653406be53f88daeda7ec2239251e54845
2018-09-11 16:21:06 -07:00
Jun Wu
8cf490dea5 treemanifest: add a progress bar on "_findrecenttree"
Summary:
This function often takes a long time on my laptop. Therefore add a progress
bar.

Reviewed By: phillco

Differential Revision: D9770952

fbshipit-source-id: fbc2a2847b813e973afc56b935476de55fb48ba3
2018-09-11 16:21:06 -07:00
Jun Wu
19ccbac6c8 xdiff: fix memory leak of the xdiff wrapper
Summary:
Fixed by Yuya at upstream. See https://www.mercurial-scm.org/repo/hg/rev/ad76032d27da.

We probably want to use Cython or Rust to write native extensions.

Reviewed By: phillco

Differential Revision: D9770953

fbshipit-source-id: f7856ca516cf37677fddfbb42c094440c6349572
2018-09-11 16:21:06 -07:00