Commit Graph

46348 Commits

Author SHA1 Message Date
Jared Bosco
5f02e5cd5c dispatch: replace _parse's call to fancyopts with native code
Summary: Replacing another fancyopts call to be parsed by native Rust code.  This diff introduces slightly hacky feeling behavior in order to handle cycles and resolving aliases, but will be fixed in a follow-up diff where Rust will fully expand the aliases completely removing the need for this confusing alias resolving, chaining, and execution.

Reviewed By: quark-zju

Differential Revision: D15902758

fbshipit-source-id: 11d9a479989a23de09bf96f8020d2fded6c06351
2019-07-20 01:06:33 -07:00
Jared Bosco
3c30d27350 copytrace: remove copytrace flag from mutating global options table
Summary:
Copytrace modified the global definitions table which was making it very difficult to keep track of side-effects as the code was executed, as well as making it harder to replace the fancyopts calls with native Rust.

Since the copytrace behavior can be achieved through a configuration, it now will no longer modify the global definitions table, and will display the correct flag for a user to use in order to get this same behavior.

Reviewed By: quark-zju

Differential Revision: D15902449

fbshipit-source-id: 1c254162d56823e65085b7047bb37513f187b487
2019-07-20 01:06:33 -07:00
Jared Bosco
40ca990aac dispatch: replace a fancyopts call with native code
Summary: Replace the next usage of fancyopts in dispatch.py with native rust code, and ensure all tests pass with this replacement.

Reviewed By: quark-zju

Differential Revision: D15857997

fbshipit-source-id: ec8722bfe661731a14cb324e97846f861bd60bc8
2019-07-20 01:06:33 -07:00
Jared Bosco
ee1fcc3d2d bindings: create cliparser native binding to replace fancyopts early parsing
Summary:
The current Python parsing library fancyopts does an early parse for global flags, as well as slightly different logic for parsing out flags.

Switching this fancyopts call should allow fancyopts to be completely replaced by the native code path, and start using Rust parsing for hg.

This enforces command line arguments to be utf8. At Facebook, our `hg` wrapper already crashes if that is not the case. So it shouldn't cause new issues.

Reviewed By: quark-zju

Differential Revision: D15837079

fbshipit-source-id: 95634ebc814f8865960181f23282e5283068057c
2019-07-20 01:06:32 -07:00
Jared Bosco
95b0be5bdc dispatch: remove strictflags and related tests
Reviewed By: quark-zju

Differential Revision: D15833690

fbshipit-source-id: 3469d8def660b116c0f82c674a19f06b18f29211
2019-07-20 01:06:32 -07:00
Jared Bosco
9984985969 cliparser: port python global flags to rust definition
Summary: The global flags currently in Python should be ported to Rust definitions

Reviewed By: quark-zju

Differential Revision: D15782273

fbshipit-source-id: 1cfdb3bbab946d18dc3c899163286e30fa69c2c7
2019-07-20 01:06:32 -07:00
Jared Bosco
b41f91b70d cliparser: allow flags to be partial matched by prefix
Summary:
Flags should be able to be matched partially by a prefix-match.

If a given prefix returns more than one possible Flag, it is therefore ambiguous and should not choose for the user.

An exact match should always take precedence.  A partial match should be tried in the event the argument is not an exact match.

Reviewed By: quark-zju

Differential Revision: D15749936

fbshipit-source-id: 26e699616a1b3fa6871fb50cc6914f916701004c
2019-07-20 01:06:32 -07:00
Jared Bosco
ef61b6fae9 cliparser: add skeleton code for command and command builder
Summary: Initial design / skeleton code for command::Command and command::CommandBuilder which is unimplemented

Reviewed By: quark-zju

Differential Revision: D15588927

fbshipit-source-id: 193d3d2aaae98a252e13d5b1e655cf93d7ce801e
2019-07-20 01:06:31 -07:00
Xavier Deguillard
8f47102275 fixcorrupt: fix debugfixcorrupt on treeonly repos
Summary:
Treeonly repos doesn't use revlogs, and thus debugfixcorrupt shouldn't try to
fix them.

Reviewed By: quark-zju

Differential Revision: D16373142

fbshipit-source-id: 6517b9516358223bfb6c646fd22aaa99c26b0372
2019-07-19 20:15:36 -07:00
Jun Wu
32b2b5a44e bindings: replace PyResult<String> with PyResult<Bytes>
Summary: This makes sure bytes (Python 2 `str`) is returned as expected.

Reviewed By: xavierd

Differential Revision: D16399693

fbshipit-source-id: c299933cfb5ec57bb46fed1f30a9ad07aa043703
2019-07-19 19:57:18 -07:00
Jun Wu
56134dd739 cpython-ext: add a Bytes type
Summary:
The `rust-cpython` library tries to be smart about `String` -> `PyObject` convertion.
It creates a unicode object if string is non-ascii:

  impl PyString {
      ...
      pub fn new(py: Python, s: &str) -> PyString {
          #[cfg(feature="python27-sys")]
          fn new_impl(py: Python, s: &str) -> PyString {
              if s.is_ascii() {
                  PyBytes::new(py, s.as_bytes()).into_basestring()
              } else {
                  PyUnicode::new(py, s).into_basestring()
              }
          }
          ...
      }
      ...
  }

In hg's case, we almost always want Python 2 bytes and never unicode objects.
Provide a new type for that.

Reviewed By: xavierd

Differential Revision: D16399345

fbshipit-source-id: cf47906ea3c871bcd1289239167241dcc3fedd8d
2019-07-19 19:57:18 -07:00
Jun Wu
c2027cc740 test-revset-age: migrate to Python and stablize it
Summary:
The test was flaky:

  --- test-revset-age.t
  +++ test-revset-age.t.err
  @@ -13,7 +13,6 @@

   Check age ranges
     $ hg log -T '{rev} {desc}\n' -r 'age("<30")'
  -  5 Changeset 5 seconds ago
     $ hg log -T '{rev} {desc}\n' -r 'age("<7m30s")'
     4 Changeset 420 seconds ago
     5 Changeset 5 seconds ago
  @@ -22,7 +21,6 @@
     4 Changeset 420 seconds ago
     5 Changeset 5 seconds ago
     $ hg log -T '{rev} {desc}\n' -r 'age("<1d")'
  -  2 Changeset 86369 seconds ago
     3 Changeset 3800 seconds ago
     4 Changeset 420 seconds ago
     5 Changeset 5 seconds ago
  @@ -53,10 +51,10 @@
     $ hg log -T '{rev} {desc}\n' -r 'age(">1d")'
     0 Changeset 31536000 seconds ago
     1 Changeset 86401 seconds ago
  +  2 Changeset 86369 seconds ago
     $ hg log -T '{rev} {desc}\n' -r 'age(">365d")'
     0 Changeset 31536000 seconds ago
     $ hg log -T '{rev} {desc}\n' -r 'age("<64m")'
  -  3 Changeset 3800 seconds ago
     4 Changeset 420 seconds ago
     5 Changeset 5 seconds ago
     $ hg log -T '{rev} {desc}\n' -r 'age("<60m500s")'
  @@ -87,16 +85,16 @@
     hg: parse error: invalid age in age range: 5h-10d
     [255]
     $ hg log -T '{rev} {desc}\n' -r 'ancestorsaged(., "<1d")'
  -  2 Changeset 86369 seconds ago
     3 Changeset 3800 seconds ago
     4 Changeset 420 seconds ago
     5 Changeset 5 seconds ago
     $ hg log -T '{rev} {desc}\n' -r 'ancestorsaged(.^, "<1d")'
  -  2 Changeset 86369 seconds ago
     3 Changeset 3800 seconds ago
     4 Changeset 420 seconds ago
     $ hg log -T '{rev} {desc}\n' -r 'ancestorsaged(., "1d-20d")'
     1 Changeset 86401 seconds ago
  +  2 Changeset 86369 seconds ago
     $ hg log -T '{rev} {desc}\n' -r 'ancestorsaged(., ">1d")'
     0 Changeset 31536000 seconds ago
     1 Changeset 86401 seconds ago
  +  2 Changeset 86369 seconds ago

Translate it to Python and patch `time.time` to stablize it.

Reviewed By: xavierd

Differential Revision: D16396479

fbshipit-source-id: 553bfe36094b2a2cbe939319606a627323cfc9eb
2019-07-19 19:36:33 -07:00
Jun Wu
3f21de52f4 test-fb-hgext-remotefilelog-local: try to make it less flaky
Summary:
The test was flaky:

  --- test-fb-hgext-remotefilelog-local.t
  +++ test-fb-hgext-remotefilelog-local.t.err
  @@ -31,7 +31,6 @@
     M x
     M y
     ? a
  -  1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over 0.00s
     $ hg add a
     $ hg status
     M x

Reviewed By: xavierd

Differential Revision: D16393051

fbshipit-source-id: 3dad1970200388b8339bc2e73b7a092336edc70d
2019-07-19 19:36:33 -07:00
Jun Wu
a77e9a4d5a test-fb-hgext-remotefilelog-bgprefetch: try to make it less flaky
Summary:
The test was flaky:

  --- test-fb-hgext-remotefilelog-bgprefetch.t
  +++ test-fb-hgext-remotefilelog-bgprefetch.t.err
  @@ -211,7 +211,6 @@
     $ find $CACHEDIR -type f | sort
     $ echo b > b
     $ hg commit -qAm b
  -  * files fetched over 1 fetches - (* misses, 0.00% hit ratio) over *s (glob)
     $ hg bookmark temporary
     $ sleep 1
     $ hg debugwaitonprefetch >/dev/null 2>%1
  @@ -266,7 +265,7 @@
     $ hg rebase -s temporary -d foo
     rebasing 3:58147a5b5242 "b" (temporary tip)
     saved backup bundle to $TESTTMP/shallow/.hg/strip-backup/58147a5b5242-c3678817-rebase.hg (glob)
  -  3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over *s (glob)
  +  2 files fetched over 2 fetches - (2 misses, 0.00% hit ratio) over 0.00s
     $ sleep 1
     $ hg debugwaitonprefetch >/dev/null 2>%1
     $ sleep 1

Reviewed By: xavierd

Differential Revision: D16393049

fbshipit-source-id: fb558e9c7f9cc51b1b133471220ac4862b985098
2019-07-19 19:36:32 -07:00
Jun Wu
b785df33a4 test-shelve: try to make it less flaky
Summary:
`...s ago` is flaky.

    --- test-shelve.t
    +++ test-shelve.t.err
    @@ -885,7 +885,7 @@
       +patch a
     No-argument --patch should also work
       $ hg shelve --patch
    -  default-01      (*s ago)    shelve changes to: create conflict (glob)
    +  default-01      (15s ago)   shelve changes to: create conflict

       diff --git a/shelf-patch-b b/shelf-patch-b
       new file mode 100644

Reviewed By: xavierd

Differential Revision: D16393050

fbshipit-source-id: 3906eabfd7ba9e4b11e7c4c8f236324afc607fff
2019-07-19 19:36:32 -07:00
Jun Wu
fa23fa1a77 test-fb-hgext-treemanifest-prefetch: try to make it less flaky
Summary:
`sleep ...` makes test flaky.

   --- test-fb-hgext-treemanifest-prefetch.t
   +++ test-fb-hgext-treemanifest-prefetch.t.remotefilelog.true.shallowrepo.false.err
   @@ -554,7 +554,7 @@
      $ sleep 1
      $ hg debugwaitonrepack
      $ ls_l $CACHEDIR/master/packs/manifests | grep datapack | wc -l
   -  \s*1 (re)
   +  3
    #endif

Reviewed By: xavierd

Differential Revision: D16391376

fbshipit-source-id: 3dc1ee3d1c8b85bc6b0a58570443b89aef86f55a
2019-07-19 19:36:32 -07:00
Adam Simpkins
40d7b50dfb rename the eden thrift wrapper library to match the python namespace
Summary:
We install the python files under `eden/fs/service` in a package named
`eden/thrift` in the built python binaries that use these modules.  This
moves the source files into an `eden/thrift` subdirectory so that the source
directory layout more closely matches the final binary layout.

This will make it easier to run several of Eden's Python-based tools directly
from the source tree, without having to do as much directory layout
transformation.  This is particularly helpful on platforms like Windows, which
don't currently have an equivalent of "live PARs" which can be run from the
source tree without requiring a rebuild after each file edit.

Reviewed By: chadaustin

Differential Revision: D16354622

fbshipit-source-id: 4b58cc96451b1ee5441714aaf74f5e3b6ada9eaa
2019-07-19 15:29:25 -07:00
Adam Simpkins
3fc6ecfa81 rename the eden/dirstate.py module to match the python namespace
Summary:
We install `eden/py/dirstate.py` as `eden/dirstate.py` in built python
binaries that use this module.  This  moves the source file into an `eden/`
subdirectory so that the source directory layout more closely matches the
final binary layout.

This will make it easier to run several of Eden's Python-based tools directly
from the source tree, without having to do as much directory layout
transformation.  This is particularly helpful on platforms like Windows, which
don't currently have an equivalent of "live PARs" which can be run from the
source tree without requiring a rebuild after each file edit.

Reviewed By: chadaustin

Differential Revision: D16354627

fbshipit-source-id: 578748e76b730db33cf3ea555df48aa94d15019f
2019-07-19 15:29:25 -07:00
Jun Wu
237846d4ca tests: try to make build_nupkg.py test work
Summary:
build_nupkg.py test will copy tests/ to build/embedded/tests/ before running
them. That breaks testutil.dott "edenscm" module discovery. Try to fix it by
making "edenscm" module discovery consider "build/embedded/python27.zip".

Reviewed By: xavierd

Differential Revision: D16383017

fbshipit-source-id: 52e19182d3e5e7267221244bd39d9a146928d8df
2019-07-19 15:08:17 -07:00
Jun Wu
bc191c2aa5 test-dirstate-completion: fix the test
Summary: Avoid creating the same repo.

Reviewed By: xavierd

Differential Revision: D16381413

fbshipit-source-id: 9f1d6bee685af5cec26e40e7669ef794ce6b23ce
2019-07-19 13:27:08 -07:00
Xavier Deguillard
f0a2127ace tests: remove newly added flaky test in test-hgsubversion-push-command.py
Summary: This newly added test keeps failing. Let's remove it from now.

Reviewed By: DurhamG

Differential Revision: D16381346

fbshipit-source-id: 11146d44fbbcd1e1c960fe4a0b6e3c28854f456d
2019-07-19 13:09:23 -07:00
Matt Glazar
9b88f1e59b Fix slow rebase for commits which move files
Summary:
When rebasing or showing a diff for a commit which moved files, remotefilectx.ancestors (called by _tracefile) calculates the linkrev for each ancestor. Sometimes [1], this is a disaster:

* remotefilectx._linkrev executes its slow path and scans the change log.
* For each entry in the change log, remotefilectx._linkrev downloads trees if needed.
* Hg downloads trees one-by-one (as of D15964145).

remotefilectx.ancestors is only calculating linkrevs so it can sort the ancestors topologically. _tracefile only needs the ancestors to be ordered topologically, not by linkrev. remotefilectx.ancestors's calls to remotefilectx._linkrev are redundant.

Optimize _tracefile's use of remotefilectx.ancestors: order remotefilectx objects topologically (breadth-first) without sorting by linkrev. Create a new function for this purpose (topological_ancestors) to avoid possibly breaking other callers of remotefilectx.ancestors. As a side effect, make this new function return remotefilectx objects lazily, similar to the filectx.ancestors function.

On my machine, with warm caches, this speeds up 'hg diff -c' and 'hg rebase' for a modestly-sized commit. 'hg diff -c' takes 0.64 seconds, down from 65.6 seconds.

[1] Hypothesis: After 'hg amend', 'hg bundle' packages linkrevs which refer to the pre-amend commit (which is not serialized into the bundle) rather than the post-amend commit. 'hg unbundle' thus creates linkrevs referring to a missing commit.

Reviewed By: DurhamG

Differential Revision: D16297426

fbshipit-source-id: 407597d5e36fc06b33719c28f5ea5052e01dc7a3
2019-07-19 12:35:22 -07:00
Xavier Deguillard
ec9ec06360 run-tests: add testpilot test runner
Summary:
Testpilot can give us a lot of things for free, including the automatic
detection of flaky tests, disabling of them, re-enabling too, easy retries on
failure, timeouts, better tracking, and the list goes on.

At a first step, I'd like to make the testpilot runner the default in hgbuild
to get all the benefits listed above.

Reviewed By: quark-zju

Differential Revision: D16294182

fbshipit-source-id: aadfbac9eb05e9d64336daba7a50a6263e38c162
2019-07-19 11:47:04 -07:00
Xavier Deguillard
9151a3cc24 tests: fix test-run-tests.t
Summary: When all tests are skipped, run-tests.py no longer return a 80 error code.

Reviewed By: singhsrb

Differential Revision: D16380129

fbshipit-source-id: e84a3558df8c2c4ebef9a382a1172d859a47e220
2019-07-19 11:39:56 -07:00
Aida Getoeva
1fb44ce297 remotenames: disable selectivepull on clone
Summary:
Streaming clone works only if we fetch all data from the server, however with selective pull feature hg specifies the particular heads it needs to pull. It causes downgrade in clone performance.
I decided to disable selective pull just before the clone operation, so the feature will be working everywhere else. Also I still store, even after clone, only "subscribed" remote bookmarks.

There are, however, artifacts of such behaviour, they are shown by changes in `test-commitcloud-sync-remote-bookmarks.t`: the whole tree of commits now is available locally, except of the remote bookmarks.

Reviewed By: simpkins

Differential Revision: D16223458

fbshipit-source-id: 0564ac23a16fe54d245e0a6ce9db5be4b6e3532f
2019-07-19 10:04:26 -07:00
Aida Getoeva
3c81066860 commitcloud: fix sync when remotebooks sync disabled on one of the copies
Summary:
If one of the repo checkouts doesn't have remote bookmarks synchronization enabled, it must not affect the Cloud's remote bookmarks state.

I also changed `localserver` (is used for our tests) because Commit Cloud server deletes the "old" bookmark names from the db and inserts "new". However, the `localserver` just set the "new" books dictionary as a new state, which is not quite correct.

Reviewed By: simpkins

Differential Revision: D16338257

fbshipit-source-id: d77d9218b1c35ea1a097bbe7393d0910ce7b4d38
2019-07-19 10:04:25 -07:00
Aida Getoeva
6ab4fcf8f8 commitcloud: fix remote bookmarks' merge on sync
Summary: While checking if one public commit is an ancestor of another public commit, I used string hashes instead of binary nodes. Fixing.

Reviewed By: farnz

Differential Revision: D16338256

fbshipit-source-id: e27ed8d79ec9ed3a188cdee93366ab2f96526152
2019-07-19 10:04:25 -07:00
Zeyi (Rice) Fan
e2655fac28 RFC: hg: make zsh completion to return list of draft commits
Summary:
By default the zsh completion will give me a list of bookmark names which personally I don't think it is useful at all.

I think making it giving me the list of draft commits is much better.

Reviewed By: quark-zju

Differential Revision: D16094724

fbshipit-source-id: 3493895a12ae02df011560b53dd5e55c8d183c79
2019-07-18 22:26:01 -07:00
Xavier Deguillard
3ce0ed8fa2 tests: fix test-hgsubversion-externals.py
Summary:
This was failing in our contbuild on centos. For some reason the memoization of
repo and ui was what made it fail.

Reviewed By: DurhamG

Differential Revision: D16368137

fbshipit-source-id: c3bec702bfa311f4be438f5aaf4939e6e725c63b
2019-07-18 22:20:35 -07:00
Xavier Deguillard
f9b4c4917a run-tests: return a success error code when tests are skipped
Summary:
As run-tests.py will be used with testpilot and at diff time, we do not
want to fail a run when all the tests were simply skipped. Let's make
that a success instead.

Reviewed By: quark-zju

Differential Revision: D16364297

fbshipit-source-id: ef8e912ddde91bd5be52784fceaf012857841eea
2019-07-18 15:54:21 -07:00
Jun Wu
0720c26f71 dispatch: do not override 'msg' in case of interruption
Summary:
The `msg` variable was unintentionally changed in the "killed" case. Use a
different variable name to solve it.

This diff changes:

  [legacy][command_finish] killed!
   exited -1 after 1.60 seconds

to:

  [legacy][command_finish] <command> exited -1 after 1.60 seconds

Reviewed By: singhsrb

Differential Revision: D16360967

fbshipit-source-id: fb52025cd743a49c18116275c2eeac7b5c436e3b
2019-07-18 15:11:57 -07:00
Jun Wu
56cf4cef7d blackbox: buffer logs before initialization
Summary:
This allows us to preserve logs before the blackbox initialization.

In the edenscm usecase, we might want to log a "process start" event before
knowing the location of the blackbox.

Reviewed By: xavierd

Differential Revision: D16044038

fbshipit-source-id: 7f41994989bb3a83e9ded3014e5afeae00f3350c
2019-07-18 15:11:57 -07:00
Jun Wu
17ee0df47c blackbox: remove Option for the blackbox singleton
Summary:
Use the new in-memory features from indexedlog and always create a blackbox
instance. This will allows us to buffer blackbox logs before `init` gets
called.

Reviewed By: xavierd

Differential Revision: D16044034

fbshipit-source-id: d137fdc3af8876c0c3dc3149c7478eb46025f457
2019-07-18 15:11:57 -07:00
Jun Wu
6b52d9c55c indexedlog: support in-memory-only RotateLog
Summary: This makes it possible to create RotateLog without writing to filesystem.

Reviewed By: xavierd

Differential Revision: D16044037

fbshipit-source-id: 451adaf8c2f97f0bd46bb2e5f42a33047d2ddfb0
2019-07-18 15:11:56 -07:00
Jun Wu
322d6990fd indexedlog: support in-memory-only Log
Summary: This allows using the Log without side effects on the filesystem.

Reviewed By: xavierd

Differential Revision: D16044036

fbshipit-source-id: 20182a58a51e61deea87c98b87f5598b98dadbb2
2019-07-18 15:11:56 -07:00
Jun Wu
21100e9dc5 indexedlog: make dir in some Log methods optional
Summary:
Change some functions to support emtpy dir, and create in-memory-only indexes.
This would allow creating in-memory-only Log.

Reviewed By: xavierd

Differential Revision: D16044039

fbshipit-source-id: 278662d3ab0093e4072e9321f3e8d4336b80ddfe
2019-07-18 15:11:56 -07:00
Jun Wu
9768b58340 indexedlog: make Log.dir optional
Summary: This allows Log to be constructed without a "dir".

Reviewed By: xavierd

Differential Revision: D16044040

fbshipit-source-id: 035416603f37af09be1ec75d1865e552ced89229
2019-07-18 15:11:55 -07:00
Jun Wu
880f04de84 indexedlog: support in-memory-only Index
Summary: This allows using the Index without side effects on disk.

Reviewed By: xavierd

Differential Revision: D16044041

fbshipit-source-id: dba6edd76e7e7a09628d836d3aa50b2defcd2555
2019-07-18 15:11:55 -07:00
Jun Wu
ec4ff4a2d2 indexedlog: make Index.file optional
Summary:
This makes it possible to create an Index instance without providing a
file. It's used in later changes.

Reviewed By: xavierd

Differential Revision: D16044035

fbshipit-source-id: e7b52b9cb342cc82567c6583902eecd003ac0949
2019-07-18 15:11:55 -07:00
Jun Wu
82b6c96907 indexedlog: extract empty mmap logic to a function
Summary:
This starts a series of changes to make indexedlog work in "in-memory-only"
mode. It is useful in 2 cases:

- buffering blackbox writes (short term)
- reused in Mononoke which does not want side-effect on disk (longer term)

Reviewed By: sfilipco

Differential Revision: D16044042

fbshipit-source-id: bdf35a9565e39e65c9ba4ddb949aa86412b4d496
2019-07-18 15:11:55 -07:00
Jun Wu
2ec82860a2 test-dirstate: fix testcase handling in new tests
Summary:
`#testcases` was translated to `for testcase in ...`, which is subtly
different since the for loop does not clean up states. Insert `cd $TESTTMP`
to make sure `setconfig` sets the global config, instead of the repo one.

Reviewed By: singhsrb

Differential Revision: D16363261

fbshipit-source-id: ea20c758e9131268f9329b98759e7423d9f1aa87
2019-07-18 15:06:45 -07:00
Saurabh Singh
c137206645 globalrevs: return globalrevs while resolving svnrev template keyword
Reviewed By: quark-zju

Differential Revision: D16361887

fbshipit-source-id: 547b03af9c17aa7ab033f9d1bd733f4a63830d07
2019-07-18 12:23:00 -07:00
Saurabh Singh
0766f36b29 hgsubversion: refactor method for svnrev template keyword to easy wrapping
Summary:
This commit is just a simple refactor of the method for the resolving
the `svnrev` template keyword. In particular, we split the method so that it
can be easily wrapped by other extensions like globalrevs in D16361887.

Reviewed By: quark-zju

Differential Revision: D16361888

fbshipit-source-id: 9f20fb33afd2b286c4f30571fa257b8284f2bb54
2019-07-18 12:23:00 -07:00
Jun Wu
53cc0f0766 test-contrib-check-code: update the test
Summary:
D16344714 made some rules only apply to edenscm/. Update the test to reflect
the changes.

Some formatting rules (ex. "string join across lines") are less important since
all files are formatted by black.

Reviewed By: xavierd

Differential Revision: D16360508

fbshipit-source-id: 9d38d710501eaf71c033ca49328774b8688fb5e0
2019-07-18 11:38:02 -07:00
Shu-Ting Tseng
fd5abc16e3 rewrite svn commit message with hg hash
Summary:
When we are migrating www to hg as source of truth, we would like to maintain the
reverse sync for some time in case we need to rollback.

In order to achieve that, we need to know the latest svn and hg commit to operate on. We
would like to record this information in the svn commit itself so it doesn't require
extra syncing and transaction.

In ordre to get this info, we can run `svn log -l 1` and parse the commit message from
there.

Reviewed By: quark-zju

Differential Revision: D16337012

fbshipit-source-id: acf66babdb48c07f95e9eb49daac0d3d3e6a96a0
2019-07-18 10:06:05 -07:00
Jun Wu
0c36fd8b5e tests: translate some .t tests to Python
Summary:
Those tests were converted using:

  echo *.t | xargs -P20 -n1 python -m testutil.dott.translate --black --verify

They run 5x faster (via run-tests.py), and 10x faster (via python directly).

run-tests.py on old .t files, 652 CPU seconds:

  % time ./run-tests.py `cat list-t.txt`  --noprogress
  .................................................................................................................................
  # Ran 129 tests, 0 skipped, 0 failed.
  ./run-tests.py `cat list-t.txt` --noprogress  505.30s user 146.37s system 1451% cpu 44.899 total

run-tests.py on new py tests, 135 CPU seconds:

  % time ./run-tests.py `cat list-py.txt` --noprogress
  .............................................................................................................................
  # Ran 125 tests, 0 skipped, 0 failed.
  ./run-tests.py `cat list-py.txt` --noprogress  55.73s user 78.80s system 744% cpu 18.061 total

vanilla python on new tests, 59 CPU seconds:

  % time (for i in `cat list-py.txt`; do python $i; done;)
  ( for i in `cat list-py.txt`; do; python $i; done; )  41.61s user 17.47s system 90% cpu 1:05.31 total

The new tests also have auto fix ability. `python test-foo-t.py --fix` will
autofix the code.

Reviewed By: xavierd

Differential Revision: D16172902

fbshipit-source-id: dda53990a7dfff5ac214c1237e4206a4d67e8e48
2019-07-17 21:11:32 -07:00
Jun Wu
59c9cee23a testutil/dott: append '(trailing spaces)' to lines with trailing spaces
Summary:
Some linters or editers are unhappy with trailing spaces in heredoc.
Workaround it.

Reviewed By: xavierd

Differential Revision: D16344717

fbshipit-source-id: 63be8b992e2e4718faea1a55655c592f0e87b206
2019-07-17 21:11:32 -07:00
Jun Wu
77dbcbbf24 testutil/dott: add a script to translate .t files
Summary:
Add a script to automatically translate .t tests to .py tests using
testutil.dott.

Reviewed By: xavierd

Differential Revision: D16172903

fbshipit-source-id: a1d736ae3e8035ac254af59c6dff5eb9f204f1fb
2019-07-17 21:11:31 -07:00
Jun Wu
4853d63b69 testutil/dott: implement per-command environment variables
Summary: This allows FOO=bar to work in some tests.

Reviewed By: xavierd

Differential Revision: D16344718

fbshipit-source-id: b600d928a42e9e8e36a2ab9f5db97fd489878d02
2019-07-17 21:11:31 -07:00
Jun Wu
b8f57dbe27 testutil/dott: implement feature test
Summary:
`.t` tests use `hghave` to test features, and can have `#testcases` for
multiple test cases. Implement them.

Reviewed By: xavierd

Differential Revision: D16209201

fbshipit-source-id: 1e8ea32d966f922efcf94e555cc9ab946cc85b27
2019-07-17 21:11:31 -07:00