Commit Graph

191 Commits

Author SHA1 Message Date
Arun Kulshreshtha
6b191cfb3e rage: fix and update 'hg rage' output
Differential Revision: https://phabricator.intern.facebook.com/D4664999
2017-03-07 01:27:12 -08:00
Simon Farnsworth
21802b82da histedit: set blockedtag when invoking user process
Summary: Improve dev_command_timers by removing some unknown_system sources

Test Plan:
testinprod

But also run-tests.py -j40

Reviewers: #sourcecontrol, mitrandir

Reviewed By: mitrandir

Subscribers: mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4658516

Signature: t1:4658516:1488812254:474cf4033fc8e59c3eadf41bf9b3218a6ff4c236
2017-03-06 06:58:53 -08:00
Stanislau Hlebik
ba7fe90440 hgext3rd: newhiddencachekey extension
Summary:
Computing cache key can be quite slow (100ms and even more). Instead let's use
a simpler cache key: size + mtime of phaseroots, obsstore and changelod and
whether changelog write was delayed.

Test Plan:
1) arc unit

2) Run test-newhiddencache.t

3) Run upstream unittest with extension enabled.
python run-tests.py --extra-config-opt extensions.newhiddencachekey=/home/stash/facebook-hg-rpms/fb-hgext/hgext3rd/newhiddencachekey.py -j20

Verify that there are no failures except for those that show that new extension were added.
Note: also need to comment out debug output in the extension

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, quark, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4604811

Signature: t1:4604811:1487958882:702ea8fdee16def674db97344832936d53f0cd9d
2017-03-06 01:18:58 -08:00
Stanislau Hlebik
68889ae8f4 fastpartialmatch: add amended commits to the index
Summary:
Upstream mercurial doesn't run hooks for temporary amended commits
(see https://bz.mercurial-scm.org/show_bug.cgi?id=3501 and
c2ca20984e3c9f30d73f0f35c35904b64edbd692). No other hook contains info about
temporary amended commits.

Let's wrap localrepository.commit() function and add missing commits inside
this wrapper.

Test Plan: arc unit

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4634950

Tasks: 16387175

Signature: t1:4634950:1488399457:1d299c6ad3cfd418dda32a7ec20c60290f8d7778
2017-03-02 01:14:09 -08:00
Stanislau Hlebik
0e16b9b84d checkmessagehook: use reposetup to setup a hook
Summary:
It makes it easier to set up a hook - just enabling the extension will enable
the hook.

Test Plan:
Run perl script



  system("echo 1 >> 1");
  system("hg add 1");
  system("hg ci -m"."\x80");
  system("hg ci -m"."\x01");
  system("hg ci -m ok");

make sure only one commit was created

Reviewers: #sourcecontrol, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4604980

Tasks: 16212973

Signature: t1:4604980:1487944300:8e4e7f340c746237b47773fc81759025e97b919e
2017-03-02 01:05:19 -08:00
Stanislau Hlebik
f008b056b4 fastpartialmatch: do not use fastpartialmatch in bundlerepos
Summary:
bundlerepo adds new commits that are not present in fastpartialmatch index.
Without this diff any access to the commit from bundle fails if
fastpartialmatch.raiseifinconsistent config option is set.

Let's not use fastpartialmatch in bundlerepos

Test Plan: arc unit

Reviewers: #mercurial, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4635368

Tasks: 16394593

Signature: t1:4635368:1488393506:15b8f6a9fddabe681de7fd1296bbfafb9512f558
2017-03-02 00:53:09 -08:00
Stanislau Hlebik
098f1ee4b6 fastpartialmatch: remove changectx.__init__() wrapper
Summary:
Turned out that wrapping `changectx.__init__()` doesn't give any performance
benefits but instead it breaks initializing of changectx. For example, if
there is a commit which revision number N is a prefix of another commit A then
`hg log -r N` outputs commit A instead of commit N. Let's get rid of this
wrapping.

Test Plan: arc unit

Reviewers: #mercurial, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4635311

Tasks: 16394593

Signature: t1:4635311:1488393427:eae091a0d155df336adbb122f2881a28e95ba6b6
2017-03-02 00:37:17 -08:00
Scott Ragan
598c76eb7b creates hg sparse --clear-rules option
Summary:
The sparse profile in .hg/sparse currently only can grow, removing rules from this must either be done manually (by editing the file), or one by one using the the -d/--delete command line switch.

To mirror the hg sparse --import-rules command line, hg sparse --clear-rules removes local includes/excludes rules.

Test Plan: fb-hgext/tests/test-sparse-clear.t

Reviewers: marianomartin, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4609102

Tasks: 16073155

Signature: t1:4609102:1488028035:f5f7b7420d911667fb4a07ac770b7e0480a76977
2017-02-27 10:53:50 -08:00
Durham Goode
f1d376b16f debuginhibit: remove warning if inhibit is not enabled
Summary:
We have users who don't use inhibit, so printing this message clutters their UI.
Let's just move this debug.

Test Plan: yolo

Reviewers: kulshrax, #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4614036

Signature: t1:4614036:1487986024:6945b057aae62fc7a9fded9474d47ba134496e5a
2017-02-25 15:28:15 -08:00
Durham Goode
2bc65bd9db hiddenerror: fix out of bounds error
Summary:
The current code checks if the filter error reports a rev number, and if it does
tries to convert it to a node. If the 'number' is actually just a short form of
a hash that happens to be all digits, then it may be a number greater than the
size of the changelog, so we need to not attempt to access it in the changelog,
otherwise we get an IndexError.

Test Plan: Added a test, it failed before with a weird error

Reviewers: #mercurial, kulshrax

Reviewed By: kulshrax

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4613988

Signature: t1:4613988:1488027938:4f5ffcb07aeecbaf59cad20fb3a592dd92ed2beb
2017-02-25 15:26:19 -08:00
Stanislau Hlebik
fa422ea77d fastpartialmatch: remove useless code
Summary:
`changectx.__init__()` always returns None since it's an `__init__()` func.
Next comparison is useless

Test Plan: arc unit

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters, #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4608204

Signature: t1:4608204:1487928626:7205b9e7d9c931692337c3a1aa33451104b05fcd
2017-02-24 05:34:22 -08:00
Jun Wu
635683876d codemod: fix compatibility with the upstream revset refactoring
Summary:
`mercurial.revset` was recently split into `revset + revsetlang + smartset`.
Update our code accordingly.

D4604848 has fixed the `revsetlang` part. This patch fixes the remaining
`smartset` part.

Also fixes some test failures introduced by D4547080.

Test Plan: `arc unit`

Reviewers: #mercurial

Subscribers: jeroenv, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4595417
2017-02-23 13:09:59 -08:00
TJ
01fdb5bf0d edrecord: introduce interactive commits with an editor interface
Summary: creating a mercurial extension so that `hg record` functionality can be used via a text editor (instead of interactive command prompt or curses menu)

Test Plan: `$ run-tests.py test-edrecord.t`

Reviewers: durham, skreyen, most, #sourcecontrol, asriram, simonfar

Reviewed By: simonfar

Subscribers: quark, rmcelroy, simonfar, mjpieters, #nuclide

Differential Revision: https://phabricator.intern.facebook.com/D4547080

Tasks: 15728734

Signature: t1:4547080:1487842609:8855e35010cac3b6d2b136a80d7effa369eb1da8
2017-02-23 11:27:52 -08:00
Stanislau Hlebik
31e3ca4aa3 fb-hgext: make compatible to upstream changes
Summary:
c6cf3ac8c9bb811afa5b6eb5b69b29d128a7476a made revset API change.
This diff fixes our extensions

Test Plan: arc unit

Reviewers: #sourcecontrol, mjpieters, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4604848

Signature: t1:4604848:1487851636:1c7618e9050f607e2d8b47ed495a349b877ed48a
2017-02-23 04:08:18 -08:00
Martijn Pieters
1752a2ba84 Send a single string (normal) to scuba
Summary: The data was being sent to scuba, but then ignored altogether. Turn this into a single string instead.

Test Plan: arc unit

Reviewers: #sourcecontrol, andrasbelo

Reviewed By: andrasbelo

Subscribers: mjpieters, andrasbelo

Differential Revision: https://phabricator.intern.facebook.com/D4598196

Signature: t1:4598196:1487784582:8952e0e386325d1635029aab2b9d97e9284376ea
2017-02-22 14:36:28 -08:00
Stanislau Hlebik
47e9e5588c hgext3rd: add checkcommitmessage
Summary:
Let's add a script that can be used as a commit hook to prevent bad commit
messages from happenning.

Test Plan:
Run the following perl script:
  system("echo 1 >> 1");
  system("hg add 1");
  system("hg ci -m"."\x80");
  system("hg ci -m"."\x01");
  system("hg ci -m ok");

Output:
  fbcode/1 already tracked!
  transaction abort!
  rollback completed
  abort: decoding near '': 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte!
  non-printable characters in commit message
  transaction abort!
  rollback completed
  abort: pretxncommit hook failed

Make sure that commit is made with "ok" message, but there are no commits with
bad commit messages

Reviewers: #sourcecontrol, tja

Reviewed By: tja

Subscribers: tja, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4597432

Tasks: 16212973

Signature: t1:4597432:1487761552:cf38eabf93374b0ec2feb653dd70033de25e6e0e
2017-02-22 04:50:24 -08:00
Jun Wu
8a407d22ea hiddenerror: fix Python 2.6 compatibility
Python 2.6 does not support `'{}' % x`, so change it to `'{0}' % x`.
2017-02-17 16:34:59 -08:00
Jun Wu
78b2c91c65 profiling: remove the extension
Summary:
The profiling extension is to log interactive time.

The upstream change 459366b580cf breaks the profiling extension as it could
no longer wrap `maybeprofile` in time. And @simonfar's
`ui.timeblockedsection` is going to be a superior solution. So just remove
the profiling extension and its tests.

Test Plan: Checked that the extension is not enabled in our config files.

Reviewers: simonfar, #mercurial

Subscribers: mjpieters, simonfar

Differential Revision: https://phabricator.intern.facebook.com/D4583087
2017-02-17 16:27:19 -08:00
Jeroen Vaelen
0ecf1322c6 fastlog-hg: use smartset to merge multi-path results
Summary:
97d0be4019ac in core broke the fastlog extension for multi-path
queries. We did not have a test to catch it. It was reported as broken by a
user.

Test Plan:
```
$ ../../hg/tests/run-tests.py test-fastlog.t
```

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4579133

Tasks: 16154586
2017-02-17 09:01:50 -08:00
Mateusz Kwapich
7b859c681d whereami: add extension
Summary:
This command will allow us to expose simple api to all automation checking
working copy parent.  It's meant to be overridden by our wrapper to read the
dirsate directly without shelling out to hg (see D4454504 )

Test Plan: see tests

Reviewers: #mercurial, durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4454502

Signature: t1:4454502:1485441135:09902c6437a7af55dfa5c97e3165681de687231f
2017-02-17 16:01:02 +00:00
Stanislau Hlebik
3ba3866802 fastpartialmatch: add generation number
Summary:
fastpartialmatch index may be incorrect if fastpartialmatch extension was
disabled, then new commits were added and then fastpartialmatch was
enabled back. We need to detect this situation and rebuild the index in
this case.

One approach would be to use _handleinconsistentindex() function to mark index
as invalid. There are a couple of drawbacks to this approach:
1) It requires more significant code changes
2) The output may still be incorrect if hash with the same prefix was added while fastpartialmatch was disabled.

Another approach would be to use header version from index files
(see class _header). That's even worse because we'll need to bump index
version in the code whenever we disable fastpartialmatch.

Third approach would be to use changelog mtime + size as a validation key but
then we need to ensure partialmatch index is written after changelog.

Instead I suggest to use generation numbers. It's just a number in the config
and in the special file inside partialmatch index directory. If the
two doesn't match then index is incorrect and needs to be deleted. The biggest
drawback to this approach is that we need to bump generation number each time
the extension is enabled. I think it should be fine because the one who enables
extensions usually understands it and he or she will bump the generation number.

Test Plan: arc unit

Reviewers: #sourcecontrol, durham, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4571926

Signature: t1:4571926:1487263035:53419c9ca4e344127f391ac19c1071a826fea3f1
2017-02-16 10:18:22 -08:00
Stanislau Hlebik
bc7415f5e7 fastpartialmatch: use _realopener
Summary:
User reported failures because revlog.opener doesn't have `exists` function.
The reason is that sometimes opener is wrapped inside the function.
Let's use _realopener instead

Test Plan: arc unit

Reviewers: #sourcecontrol, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4571659

Signature: t1:4571659:1487267797:a950ab7c88d75573df64ec1964755c054307c7ea
2017-02-16 10:17:54 -08:00
Adam Simpkins
33b2fbc0bc fbconduit: fix error handling in gitnode() revset
Summary:
Don't let errors propagate out of the gitnode() revset.  Always report errors
in gitnode() as a translation failure, rather than letting exceptions propagate
up and crash mercurial.  The code was previously only catching internally
generated ConduitError exceptions, but it can also throw HttpError exceptions,
and the underlying httplib code can throw its own exceptions as well as
socket.error exceptions.

This also fixes the test code to use an ephemeral TCP port rather than assuming
port 8543 will always be available.  Using a fixed TCP port in test code is a
very common way to cause bogus failures if the tests are run in parallel.
(For instance, testing multiple repositories in parallel on the same build
host.)

Test Plan:
Added unit tests that check the behavior when the server returns a 500 error,
and when the server refuses the connection entirely.

Reviewers: quark, durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: net-systems-diffs@fb.com, yogeshwer, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4556871

Signature: t1:4556871:1487062142:b58d770d46c975d44933bec08cfce8acb25ff16b
2017-02-15 12:35:06 -08:00
Jun Wu
763e41cee8 smartlog: work better with repos where there is no master
Summary:
Previously, smartlog use `tip` as the fallback master, and prompts:

  warning: there is no master changeset locally, try pulling from server

if master is `tip`.

That makes smartlog less friendly for external users. This patch removes the
prompt and changes the fallback master to the last public revision so it
works out-of-box.

Test Plan: `arc unit`

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4555346

Signature: t1:4555346:1487036530:35a5fa65d5419e7324d3203fa52de9a82b8132e3
2017-02-14 17:25:12 -08:00
Arun Kulshreshtha
e71276b303 hiddenerror: make error message configurable
Summary:
This diff makes the following modifications to the (former) `hiddenhash` extension:

- Makes the error messages configurable, allowing us to easily change the error messages in `facebook.rc`.
- Renames the extension to `hiddenerror`, since the primary feature is now the configurable error messages rather than using a hash in the message.
- Changes the method by which the extension wraps the `changectx` constructor. The old method of wrapping would result in errors in code paths that in `context.py` that performed `isinstance()` checks on contexts.

Test Plan: To test arc patch this extension into your `facebook-hg-rpms` and enable it for a test repo. Then, attempt to access a hidden node. You should see the default error message defined in the extension. Setting `hiddenerror.message` and `hiddenerror.hint` should allow you to customize the messages. See test file for examples.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, durham, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4548140

Tasks: 15896355

Signature: t1:4548140:1487063552:06395c1eaaa83b00ead8e80e2cd8f9d13f7d08e2
2017-02-14 11:15:19 -08:00
Kyle Lippincott
13f723e8dd fbconduit: add conduit_protocol global: makes test-check-pyflakes.t happy 2017-02-14 02:11:09 -08:00
Martijn Pieters
3455bf3ae6 Allow sparse profiles to contain comments
Summary: Sometimes you want to be able to justify why a line is in a sparse profile. Support empty lines and comments (starting with a hash).

Test Plan: Run the test runner

Reviewers: #mercurial, rmcelroy, durham

Reviewed By: durham

Differential Revision: https://phabricator.intern.facebook.com/D4537617

Tasks: 15993301

Signature: t1:4537617:1486687441:18a00b65df244b573bab095809fb1fbb57e21d71
2017-02-13 04:17:51 -08:00
Arun Kulshreshtha
f46e6eb4da debuginhibit: print out inhibited nodes by default
Summary: If `hg debuginhibit` is run with no arguments, print out a list of inhibited nodes. This is similar to how `hg debugobsolete` works and will assist with debugging.

Test Plan: Run `hg debuginhibit` in a repo with inhibited nodes. (This can be tested by either stripping some test commits and then updating back to them, or by manually inhibiting the commits with `hg debuginhibit`.) A list of inhibited nodes should be printed. See test file for an example.

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D4541514

Tasks: 16004717

Signature: t1:4541514:1486722366:10b4232830ed88931bd6ac610972114743797192

Revert Plan:
2017-02-10 11:28:33 -08:00
Stanislau Hlebik
e553fcf9af hiddenhash: fix centos6 build
Summary:
To get rid of this DeprecationWarning:

    --- /data/hgbuild/facebook-hg-rpms/fb-hgext/tests/test-hiddenhash.t
    +++ /data/hgbuild/facebook-hg-rpms/fb-hgext/tests/test-hiddenhash.t.err
    @@ -10,5 +10,7 @@
       $ hg debugbuilddag +1
       $ hg debugobsolete 1ea73414a91b0920940797d8fc6a11e447f8ea1e
       $ hg log -r 0
    +  $TESTTMP/hiddenhash.py:33: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
    +    match = re.match(r"hidden revision '(\d+)'", e.message)
       abort: hidden changeset 1ea73414a91b!
       [255]


let's not access `.message` and use str(e) instead

Test Plan:
arc unit,
Will test on centos6 soon

Reviewers: #sourcecontrol, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4521398

Signature: t1:4521398:1486470861:e39e4639346d0f1f2e4a69fc38ccf34fbc432df6
2017-02-07 04:51:20 -08:00
Stanislau Hlebik
c4a1147f39 sampling: fix comment
Summary:
HG_SAMPLING_FILEPATH was renamed to SCM_SAMPLING_FILEPATH long time ago.
Let's update the comment

Test Plan: Not tested

Reviewers: #sourcecontrol, quark

Reviewed By: quark

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4507708

Signature: t1:4507708:1486141731:8a96ac74006cf9d240ad4cbbff928fe49fe71cb3
2017-02-07 00:39:26 -08:00
Arun Kulshreshtha
da74a12dac hiddenhash: make hidden commit errors more user friendly
Summary:
Previously, when a command tried to access a hidden revision without the `--hidden` flag, the user would get the following error:

```
abort: hidden revision '0'!
(use --hidden to access hidden revisions)
```

With this extension, the error is now:

```
abort: hidden commit b8144197c244!
```

This way, novice users aren't tempted to immediately re-run the command with `--hidden`, which may have undesired results. It also makes it much easier to find the commit in question in `hg sl --hidden` since by default smartlog does not show rev numbers.


Test Plan: Attempt to access a hidden commit, observe new error message as seen above. Note that in the test file the word "changeset" is present instead of "commit" due to the lack of the `dialect` extension in the test.

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4506065

Tasks: 15747879

Signature: t1:4506065:1486122372:d82ebd488a00d1958c235f733a9455111954c116
2017-02-03 12:26:22 -08:00
Stanislau Hlebik
fa28a07404 perftweaks: fix failure
Summary:
turned out that transaction can be None in some cases.
Let's just write to the cache in this case.

Test Plan: arc unit

Reviewers: #sourcecontrol, durham, andrasbelo

Reviewed By: andrasbelo

Subscribers: andrasbelo, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4507653

Tasks: 15862906

Signature: t1:4507653:1486133933:de0997ef1724ba1082c3597ea64aab760f670b47
2017-02-03 07:22:07 -08:00
Arun Kulshreshtha
3c80b1176b fbamend: make inhibit hook fire after rebase
Summary:
Recently @rmcelroy discovered that attempting to rebase a single commit in the middle of a stack results in the rest of the stack being marked as unstable. See https://fb.facebook.com/groups/sourcecontrol/permalink/1207767375939547/ for full example.

It turns out that the inhibit extension's post-transaction hook that would ordinarily inhibit the rebased (and thus obsolete) commit, and thereby hide the instability, was not firing in this case. This was similar to a previous problem with `hg next --rebase` wherein `--continue`'ing a rebase with conflicts would result in visible instability for the same reason. In both cases, the problem appears to be that `rebase` doesn't actually create a transaction, so of course the post-transaction hook doesn't fire.

The solution for `hg next --rebase` was to add a (nearly) empty transaction after the rebase call to trigger the hook. This diff just makes this the default behavior for `hg rebase` so that the hook is always called.

Test Plan:
See new test file. Basically, create a situation like:

```
o  e5d56d  debugbuilddag
|  r3
|
| o  c175ba  debugbuilddag
| |  r2
| |
| o  220949  debugbuilddag
|/   r1
|
o  1ad88b  debugbuilddag
   r0
```

Perform `hg rebase -r 1 -d 3`, which rebases commit "r1" onto "r3", which would ordinarily make "r2" unstable. Instead, the result should be as below, with no visible instability because "r1" is inhibited.

```
o  738e8e  debugbuilddag
|  r1
|
o  e5d56d  debugbuilddag
|  r3
|
| o  c175ba  debugbuilddag
| |  r2
| |
| x  220949 (Rebased as 738e8e)  debugbuilddag
|/   r1
|
o  1ad88b  debugbuilddag
   r0
```

Reviewers: rmcelroy, #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters, rmcelroy

Differential Revision: https://phabricator.intern.facebook.com/D4491870

Tasks: 15697758

Signature: t1:4491870:1486033128:45b8e9a72af1e88ab78484ddef47a788d1aca7b5
2017-02-02 11:49:44 -08:00
Stanislau Hlebik
1632aa627b fastpartialmatch: fix the build
Summary: Sort the output to fix tests on different platforms

Test Plan: arc unit on mac

Reviewers: #sourcecontrol, simonfar, ikostia

Reviewed By: simonfar, ikostia

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4501449

Signature: t1:4501449:1486050577:3041dc3c3691f48e39a0e9e05b1f97954a6d88e2
2017-02-02 08:00:55 -08:00
Stanislau Hlebik
47060cb7d0 fastpartialmatch: trigger rebuilds if there were too many unsorted entries
Summary:
If we have too many unsorted entries then finding matching revisions is
slower. To fix it we will rebuild partial index from time to time.
_findcandidates function marks index as need-to-be-rebuilt if it notices
index file with too many unsorted entries. Then _changegrouphook rebuilds
the index.

Test Plan: arc unit

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4494617
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
470276319f fastpartialmatch: use bisect to quickly find matching revisions
Summary:
Since we have some of the nodes sorted we can now use bisect to quickly find
matching nodes.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4494419
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
01b8e8e509 fastpartialmatch: add header
Summary:
Append header to each fast partial match index file. For now it contains
version number and number of sorted entries in the file.
File is ignored if version number from file is different.

Test Plan: arc unit

Reviewers: #sourcecontrol

Differential Revision: https://phabricator.intern.facebook.com/D4488417
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
c28363dc2e fastpartialmatch: sort the nodes during rebuilding
Summary:
We'll add bisect algorithm soon.
Let's sort the nodes first during index rebuilding

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4488263
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
79d4a8903d fastpartialmatch: handle strips correctly
Summary:
strip may change revision numbers of many nodes at once.
It's better to rebuild index in case of strip.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474710
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
591b66079d fastpartialmatch: pretxnchangegroup hook
Summary:
This hook builds index if it's not present and it appends new entries
from the changegroup.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474704
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
3c58c2dbc4 fastpartialmatch: wrap revlog._partialmatch and changectx.__init__
Summary: These two functions actually use fastpartial index to resolve revision for a node.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474658
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
e76fcd369f fastpartialmatch: add commit hook
Summary:
Add commit hook to append new entries to the index.
It uses the same transactions as revlogs.
Do not append entries if index is not built (i.e.
if _partialindex does not exist). This is to ensure that we either
have complete index or none at all. Besides next diff will add
hooks to build index after pull if it doesn't exist.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474654
2017-02-02 05:12:10 -08:00
Stanislau Hlebik
144ba285fb fastpartialmatch: initial commit
Summary:
Index to make node partial match fast i. e. speed up matching of partial hashes like f9bbd5.

This is an initial diff and it doesn't add any useful functionality, just debug commands.

Storage format is simple. There are a few files (at most 256).
Each file contains entries:



  <20-byte node hash><4 byte encoded rev>


Each entry represents a commit (node).
Name of the file is the first two letters of the hex node hash. Nodes with the
same first two letters go to the same file. Nodes are NOT sorted inside the file
to make appends of new nodes easier.
Partial index should always be correct i.e. it should contain only nodes that
are present in the repo (regardless of whether they are visible or not) and
rev numbers for nodes should be correct too.

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4474642
2017-02-02 05:12:10 -08:00
Arun Kulshreshtha
d7c143274c debuginhibit: add debuginhibit extension
Summary: Add a new extension to assist with debugging issues with the inhibit extension. Adds the `hg debuginhibit` and `hg debugdeinhibit` commands to manually inhibit/deinhibit commits as well as config options to print out the nodes being inhibited and truncated stack traces of each call site. I mostly made this into an extension so that it would be easy to debug inhibit issues from any user by just asking them to run their command with the appropriate `--config` flag.

Test Plan: See test file. Enabling the `debuginhibit.printnodes` and `debuginhibit.printstack` functions should result in the relevant nodes and stack traces to be printed whenever nodes are inhibited and deinhibited.

Reviewers: durham, rmcelroy, #mercurial, mitrandir, simonfar

Reviewed By: simonfar

Subscribers: mitrandir, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4485659

Signature: t1:4485659:1485985964:e6920b67450942c706c9523e9df48b4093b26d69
2017-02-01 15:17:04 -08:00
Arun Kulshreshtha
4a81b50bc3 fbamend: return early on split/fold error
Summary: Although the split and fold commands usually abort on error, in some cases they simply write to stderr and return a nonzero exit status. Previously, the wrappers in fbamend would expect failures to result in an abort, and therefore didn't return early. This resulted in restack errors when this was not the case -- notably in the case of folding a commit with itself. This diff fixes the problem by returning early on error.

Test Plan: Attempting to fold a commit with itself (i.e., `hg fold --exact . .`) fails with an error message instead of crashing.

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4493029

Tasks: 15704338

Signature: t1:4493029:1485986404:17186b47786cf79c735b33adbb19de79ac75a5be
2017-02-01 15:14:17 -08:00
Arun Kulshreshtha
37e275d052 fbamend: move bookmarks after split/fold
Summary: Previously, if a user ran split or fold on commits with bookmarks on them, those bookmarks would remain on the original commit instead of the new split or folded commits. This behavior was unexpected and confusing because it meant the obsolete commit would remain visible and the user would be forced to manually move the bookmark. This change makes split and fold automatically move any bookmarks on the old commits onto the newly created commits.

Test Plan: Run `hg split` or `hg fold` on a commit or set of commits with one or more bookmarks, and observe that the bookmarks are updated to point to the newly created commits. See tests for examples.

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4490655

Tasks: 15595449

Signature: t1:4490655:1485986009:858f099d3f95c6a45fe8b119d4f8d376b87652b7
2017-02-01 15:14:17 -08:00
Durham Goode
6b981a083a perftweaks: fix noderev cache for non existent nodes
Summary:
In certain situations, like infinitepush, the noderev cache builders would try
to save a node that didn't exist in the repo. This caused an exception. Now we
check each node before we attempt to resolve it to a rev.

Test Plan: Added a test. It failed before, and passes now.

Reviewers: #mercurial, andrasbelo

Reviewed By: andrasbelo

Subscribers: andrasbelo, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4494848

Signature: t1:4494848:1485964835:986d4fe3e29404cac22e4acf7d88c3715fcb51b9
2017-02-01 08:03:49 -08:00
Durham Goode
5d9152387e uncommit: don't lose copy information of remaining files (issue5403)
This is an import of a bugfix in upstream evolve by Martin.

As reported in the issue, "hg uncommit" would lose copy information of
the files that remained in the commit. The problem was simply that the
a dict of copies was iterated as "src, dst in copies.items()" where it
should have been "dst, src ...".
2017-02-01 02:17:40 -08:00
Durham Goode
5da804759f perftweaks: increase noderev cache coverage
Summary:
Previously the noderev cache only covered the branchmap. These days remotenames
and phases are also doing a lot of node->rev look ups, so let's add them to the
noderev cache as well.

Test Plan:
Compared hg book before and after the change. Noticed a significant
perf increase.

Reviewers: #mercurial, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4487962

Signature: t1:4487962:1485871615:634d95f61e916d81440a0f440010912af5ae6a13
2017-01-31 06:11:25 -08:00
Arun Kulshreshtha
d9d96358f5 allowunstable: allow hg record in the middle of a stack
Summary: This is basically the same as `hg amend -i` but since allowunstable operates at the command function level we need to explicitly whitelist this command. Note that I've set the obsmarker metadata to "amend" so that commits affected will be marked as "Amended as XXX" in smartlog. I don't think any other `hg record` flags other than --amend create obsmarkers so this should be OK.

Test Plan: Run `hg record --amend` in the middle of a stack and observe that it works now.

Reviewers: durham, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, reedriley

Differential Revision: https://phabricator.intern.facebook.com/D4466338

Tasks: 15705764

Signature: t1:4466338:1485424744:442604ce2089298f0724c27025502a3602113401
2017-01-26 10:24:16 -08:00