Commit Graph

721 Commits

Author SHA1 Message Date
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
Arun Kulshreshtha
63ffce24fb fbamend: abort on hg restack --hidden
Summary: There is no valid reason to run `hg restack --hidden` (and this will cause unexpected behavior) so disable it.

Test Plan: `hg restack --hidden` now aborts. Added check to unit test.

Reviewers: rmcelroy, #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 15615216

Signature: t1:4463934:1485386049:9836ec970d7c3e11c7dfaed21aa0ce8b58013294
2017-01-25 15:48:12 -08:00
Arun Kulshreshtha
d1693cf7c4 rage: annotate hidden nodes in hg sl
Summary: Use `{hsl}` smartlog template to show label hidden nodes in `hg pasterage` output.

Test Plan: Example pasterage output: P56992404

Reviewers: #sourcecontrol, durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4452488:1485222832:5adabafd7d0d55bf76b11684c7d1f03d6681f225
2017-01-23 17:56:38 -08:00
Mateusz Kwapich
2d3a634a86 py3: replace pycompat.getenv with encoding.environ.get
Summary: Following the replacement in core.

Test Plan: test-rage.t passes now

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4441823:1484921100:b1c8e1c0aef1196b7a8009a919e6d1fa3e2eb06c
2017-01-20 06:23:56 -08:00
Arun Kulshreshtha
19887fc8fa arcdiff: use absolute paths
Differential Revision: https://phabricator.intern.facebook.com/D4440103
2017-01-20 00:24:45 -08:00
Arun Kulshreshtha
b703374248 smartlog: make split successor labels work correctly
Summary: The template keyword for split was not producing output because obsmarkers with multiple successors were being filtered out.

Test Plan: Correct "Split into XXX, YYY" labels appear in smartlog. Tests have been added for all of the obsolescence-related smartlog template keywords.

Reviewers: #sourcecontrol, rmcelroy, durham

Reviewed By: durham

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4396453:1484880307:bfdc60385e42fee169ff2f0ec4f85dd0747b55c9
2017-01-20 00:24:45 -08:00
Arun Kulshreshtha
50c7f6c256 fbamend: add automatic restacking to split and fold
Summary: Automatically rebase unstable commits left behind after a split or fold in the middle of a stack. Previously, users had to run `hg restack` to fix their stacks after the fact. This change also fixes the issue identified in t14560234 whereby the old stack (entirely obsolete) stack would be left visible after splitting or folding a head commit due to the inhibit extension not correctly deinhibiting the old stack.

Test Plan: Create a stack of commits and perform `hg split` or `hg fold` on a commit (or set of commits) that have descendants. After the operation these commits should be rebased, preserving the linearity of the stack. See unit tests for specific test cases.

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 14560234, 15266009

Signature: t1:4432833:1484880689:1e07e421c8871dfef8bd016454aaed5a88a4a7d1
2017-01-20 00:24:45 -08:00
Adam Simpkins
63b7bb19c5 templates: fix help messages for template keywords
Summary:
Many of the template keywords in our extensions were being registered
incorrectly, causing their help output to be rendered incorrectly in the
"hg help templates" output.  The ones in smartlog.py were particularly bad, as
most of them showed only their description, without displaying the name of the
template.  In smartlog.py only singlepublicsuccessor was being displayed
correctly, because it's docstring explicitly included it's own name at the
start.

This fixes all of our extensions to consistently use the
registrar.templatekeyword() decorator to register the keywords.  This decorator
automatically prefixes the help message with the keyword name.  The
mercurial/extensions.py code will explicitly check to see if an extension
contains an "templatekeyword" attribute, and if so it will register any
keywords contained in this registry after calling extsetup().

Test Plan:
Added new unit tests to check the output of "hg help templates" for the
affected keywords.

Reviewers: #sourcecontrol, kulshrax, ikostia, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, net-systems-diffs@, yogeshwer, mjpieters

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

Signature: t1:4427729:1484831476:17b478a5e867dfc3f85402588c381bf8b1831107
2017-01-19 12:52:54 -08:00
Ryan McElroy
a702adbf6b phabdiff: make tasks regex more lenient
Summary: Let people put #, t, commas or no, etc!

Test Plan: existing and new tests

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: durham, mjpieters, ullrich

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

Tasks: 15467918

Signature: t1:4411027:1484264937:cdc2452ac3ba920c153d3e0317972433da188a8e
2017-01-13 14:15:41 +00:00
Arun Kulshreshtha
db1e6df35f fbamend: silently drop --dest in restack instead of aborting
Summary:
The remotenames extension automatically adds a --dest option to `hg rebase`, which causes
restack to abort. Instead, we should just drop the 'dest' key and proceed.

Test Plan: Attempt to use `hg rebase --restack` in fbsource when the current bookmark is tracking a remote bookmark.

Reviewers: #mercurial, durham, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Tasks: 15422257

Signature: t1:4399846:1484084585:4a6ec907032e7d8b1388980870b6d72cb560829f
2017-01-10 13:53:43 -08:00
Simon Farnsworth
a8da24f626 statprofext: remove dead file
Summary: Upstream Mercurial now has native support for statprof, rendering this file useless.

Test Plan: Remove statprofext.py* from my installed hg, confirm it still works. Build fb-hgext and run tests, confirm no new failures

Reviewers: #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, #sourcecontrol

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

Signature: t1:4397926:1484066120:0c1469d838a91a65fb57ecc858675256087e2c48
2017-01-10 10:10:58 -08:00
Thomas Jacob
dc2e79ae3f tweakdefaults: make --phabdiff use shortdate on --quiet as in default blame
Summary: Added some tests for this also

Test Plan: arc unit in fb-hgext

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 15360841

Signature: t1:4397881:1484066348:1b9fb24a30a9962de0dad858f4d57956a2c91dc4
2017-01-10 08:48:02 -08:00
Arun Kulshreshtha
041eae0180 fbamend: edit hint to mention hg restack instead of hg amend --fixup
Summary: To encourage people to learn about and use `hg restack` (which is a more general fixup tool), tell users about it instead of `hg amend --fixup`. I wasn't sure whether to advertise it as `hg rebase --restack` or just `hg restack`, so I've included both.

Test Plan: Do an amend in the middle of a stack and observe the new wording. Unit tests reflect changed wording.

Reviewers: durham, #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4390111:1483962208:46951c8f5e4c499840b0b4b0ee8ac1e1b6c14ca9
2017-01-09 11:09:02 -08:00
Stanislau Hlebik
dd1bfa42b8 phabdiff: precompile regexes
Summary:
I got the following profile results when profiling smartlog:

{P56936293}

It suggests that regex compiling takes too much time. I tend to think that
profiling is inaccurate in this case because with this diff I didn't get any
noticable speed up. But this diff won't do any harm.

Test Plan: arc unit

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4387265:1483724595:43de3c694109be2d4343d8ebdbc7ab79aa9edb04
2017-01-09 01:37:48 -08:00
Jun Wu
d185b8e43b sshaskpass: do not import mercurial
The sshaskpass is not only a mercurial extension, but also a script that
runs separately, in which case it cannot import mercurial modules. So let's
fallback to os.environ.
2017-01-05 17:04:34 +00:00
Jun Wu
79a8df7ff6 morestatus: suggest --clean for unfinished update state
Summary:
Without `--clean`, the user may not be able to abort cleanly.

Also, change "erase" to "discard" to be more consistent with the official
language. "changed" is replaced by "changes" as it looks like a grammar
mistake.

Test Plan: Updated existing tests

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4377376:1483464655:f695fd643509d7fabb88298bd1004727ee64ef76
2017-01-03 16:25:52 +00:00
Stanislau Hlebik
b3cc0d5817 pushrebase: close bundle file
Summary: bundle file should be closed to ensure that all the temporary files were deleted

Test Plan: arc unit

Reviewers: #sourcecontrol, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

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

Signature: t1:4377148:1483451990:2a1362d9e524a54ffedad8f2bc09fc622efe8ad4
2017-01-03 06:01:57 -08:00
Stanislau Hlebik
5f58694748 unit-tests: fixes
Summary:
test-check-code.t was updated in core mercurial so we have to fix it in
fb-hgext

Test Plan: arc unit

Reviewers: #sourcecontrol, quark

Reviewed By: quark

Subscribers: quark, mjpieters

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

Signature: t1:4377208:1483451688:bc382cdab07c6d6127d67c902458a2ccfa1373d1
2017-01-03 05:59:55 -08:00
Arun Kulshreshtha
bcc5f95132 smartlog: remove --limit option
Summary: The --limit option was carried over from the option list for `hg log`. However, it doesn't do anything in smartlog, so this diff removes it from the option list.

Test Plan: `hg smartlog --help` no longer shows `--limit`.

Reviewers: #mercurial

Subscribers: mjpieters

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

Tasks: 15186221
2016-12-22 12:07:45 -08:00
Martijn Pieters
5561f26b7b sparse: add rule import feature
Summary:
Make adding a set of rules efficient.

Currently buck autosparse writes directly to .hg/sparse, clobbering any
existing manual rules or profile settings. This is not optimal.

The command-line of hg sparse is too limited at the moment to add rules in any
other way (only one new rule per call!). The --import-rules option lets us
bulk-import and efficiently decide wether or not a refresh is needed.

Test Plan: arc unit

Reviewers: #sourcecontrol, andrasbelo

Reviewed By: andrasbelo

Subscribers: andrasbelo, mjpieters

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

Signature: t1:4358087:1482409901:42b2d32dc624579a3d35875ba1bb126d9539cc69
2016-12-22 12:50:08 +00:00
Martijn Pieters
1c54b7f189 perftweaks: start logging active sparse profiles
Summary: Log active profiles for any command that uses the repository.

Test Plan: arc unit

Reviewers: #sourcecontrol, mitrandir

Reviewed By: mitrandir

Subscribers: andrasbelo, mitrandir, mjpieters

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

Signature: t1:4346795:1482251224:a9b3568eeb7e57c61273ce0dc9f4d41abcd2888e
2016-12-20 16:34:33 +00:00
Kyle Lippincott
5c73644ae8 debian: Do not package hgext3rd/__init__.py
When installed into a path like /usr/lib/python2.7/dist-packages, this file
conflicts with the hgext3rd/__init__.py from mercurial itself.  Let's keep the
mercurial version the canonical one, and just skip packaging this one.

I added a warning to this repo's __init__.py about behavior divergences between
this __init__.py and mercurial's version.
2016-12-19 16:34:49 -08:00
Martijn Pieters
a678247319 perftweaks: start logging the dirstate size
Summary:
Logging dirstate sizes gives us a way to track sparse profile use; how big a
working copy do people actually have?

The logged info can be directed to Scuba via the sampling extension.

Test Plan: Run on a local test repo with the debugger attached. Goal

Reviewers: #sourcecontrol, quark

Reviewed By: quark

Subscribers: mitrandir, quark, mjpieters

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

Signature: t1:4340367:1481920819:d7358e0bdc2cc1422b36266374344e7d2b644ae5
2016-12-16 22:46:36 +00:00
Durham Goode
2e89e5591d pushrebase: fix handling merge commits where master is p2
Summary:
Previously, if during a pushrebaes a merge commit was rebased and the
parent commit that contained the original rebase destinations content (i.e.
master's content) was on the p2 side, it would all be thrown away.

This is because the pushrebase commit works by copying the destination-repo-p1, then
applying changes from the diff of the original-repo-p1 vs original-repo-commit.
Since all the rebase destination contents was in destination-repo-p2, it is all
lost here.

The solution is to track which commit is the latest one to contain the
destination bookmark contents, and make sure it is always p1 when rebasing merge
commits. This will ensure that the destination bookmark contents are preserved
all the way up to the new commit for that bookmark.

Test Plan:
Added a test. It fails before the change and passes after. Another
test was also affected, since the p1/p2 ordering is different.

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Tasks: 15092414

Signature: t1:4336427:1481881555:a22b8c363f2f7a197cef192abf34bfca926ecdc2
2016-12-16 10:24:12 -08:00
Arun Kulshreshtha
bfa9bd7a91 fbamend: remove allowunstable hack
Summary: Move the enabling of unstable changesets from fbamend to allowunstable, keeping all of the wrapping in one place.

Test Plan: Unit test still passes. No change in functionality.

Reviewers: #sourcecontrol, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4288233:1481073858:a7432a9941e93fcadf5ad6502630a49c4e1207f7
2016-12-06 17:56:19 -08:00
Arun Kulshreshtha
e7a2ea79bc allowunstable: allow rebasing in the middle of a stack without --keep
Summary: This change enables "allowunstable" for the `hg rebase` command, which lets it create unstable changesets without full evolution enabled.

Test Plan: Create a stack of commits and attempt to rebase a commit in the middle of the stack, using a command like `hg rebase -r REV1 -d REV2` without the `--keep` flag. This will now work, and the old version of the rebased commit (with descendants) will render as an X in smartlog.

Reviewers: #sourcecontrol, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4287989:1481074215:80103f6bfd150e51cc152bc257146d3f9369b175
2016-12-06 17:56:17 -08:00
Alexander Mols
8391d808d0 myparent: commit template keywords based on your previous commit
Summary:
An extension to pre-fill your commit template based on your own
previous commit. Useful for stacked diffs where the commits are mostly related
and will have mostly the same reviewers, tasks, etc.

Test Plan: dogfooding + tests

Reviewers: #sourcecontrol, mjpieters, quark

Reviewed By: quark

Subscribers: quark, mjpieters

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

Tasks: 12218809

Signature: t1:4265616:1480946835:ed18fadbd9068f2d2ec4799fa1ac176132b41e4b
2016-12-05 06:27:29 -08:00
Jun Wu
1a05e790ca linkrevcache: update documentation
Summary:
This patch changes docstring to make it clearer about how to use the
extensions. It provides some possibly useful details.

Besides, update `testedwith` to be consistent with other extensions.

Test Plan: My vim spellchecker seems happy.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: stash, mjpieters

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

Signature: t1:4263123:1480668147:d042e9b52d0a2759ac360c87a2c87d2d3b0aa0f9
2016-12-02 00:59:48 +00:00
Pascal Hartig
a7cffaf493 hgext: githelp support for commit -C
Summary:
Add support for `git commit -C <commit>`/`git commit --reuse-message <commit>`.

E.g.

```
hg githelp -- git commit -C deadbeef
hg commit -M deadbeef
```

Test Plan: Added test case for the new feature

Reviewers: rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:4258167:1480674937:4f21fd43272462c8c5eee40a02d0db7014c834d4
2016-12-02 10:41:54 +00:00
Jun Wu
5d5fedd10c tweakdefaults: fix check config test
Summary:
This fixes test-check-config-hg.t for tweakdefaults. And did some clean-up
for other minor issues.

I was trying to implement another feature (along with the clean-up) in
tweakdefaults and finally realized it's infeasible and drop the feature. But
the clean-up seems useful thus sent here.

Also change `cp -r` to `cp -R` to pass the usptream check-code test.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, mitrandir

Reviewed By: mitrandir

Subscribers: mjpieters

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

Signature: t1:4253852:1480613350:398e9b234fcc2360dcb8a3e3ad4e5bc5c4377857
2016-11-30 20:58:08 +00:00
Michael Bolin
9b730c722c Perform stricter check to test whether a repo is sparse.
Test Plan:
Without this change, running `hg commit` in Eden was failing with the following:

```
AttributeError: 'shallowrepository' object has no attribute 'getsparsepatterns'
```

This is because our Eden mount is *shallow*, but not *sparse*, and
`shallowrepository` has a `sparsematch` method, so it yielded a false positive
for this check in `sparse.py`:

```
        if util.safehasattr(repo, 'sparsematch'):
```

Because the first thing that is called after this check is:

```
            _, _, profiles = repo.getsparsepatterns(ctx.rev())
```

it seems more appropriate to test for the `getsparsepatterns` attribute, anyway.

Reviewers: simpkins, durham

Differential Revision: https://phabricator.intern.facebook.com/D4248940
2016-11-29 18:28:48 -08:00
Arun Kulshreshtha
374b37caf5 allowunstable: update comment
Summary: In my rush to get the allowunstable extension landed before the holidays, I made several embarrassing typos in the doc comment at the top of the extension. This diff fixes the typos and makes the comment more clear.

Test Plan: The only change was in a comment, so this is a no-op. Unit tests still pass for good measure.

Reviewers: durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4242510:1480399263:a9822b5e762f1a94c322b15c2ddec9c1acb7df78
2016-11-29 10:18:59 -08:00
Jun Wu
f08e17d3ed testedwith: change testedwith to "ships-with-fb-hgext"
Summary:
Using `testedwith = 'internal'` is not a good habit [1]. Having it
auto-updated in batch would also introduce a lot of churn. This diff makes
them "ships-with-fb-hgext". If we do want to fill the ideal "testedwith"
information, we could put it in a centric place, like a "fbtestedwith"
extension rewriting those "ships-with-fb-hgext" on the fly.

Maybe having in-repo tags for tested Mercurial releases is also a good idea.

[1]: www.mercurial-scm.org/repo/hg/rev/2af1014c2534

Test Plan: `arc lint`

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:4244689:1480440027:3dc18d017b48beba1176fbfd120351889259eb4b
2016-11-29 13:24:07 +00:00
Jun Wu
c030cc61cb tweakdefaults: do not use template for annotate if unnecessary (BC)
Summary:
Template lacks of the "padding" feature. There is a hard-coded 13-char wide
username, 5-char wide line number, which does not look well if the usernames
are too long or too short.

This patch restores the original annotate format which is different from
the current behavior. For example, given "-uc", it shows "user node" instead
of "node:user". It also tries to make the template version as close as the
non-template one, by adjusting the order, changing separators, and making
"-c" optional (could be hidden from the output).

Test Plan: Modified existing tests

Reviewers: #sourcecontrol, ikostia

Reviewed By: ikostia

Subscribers: mjpieters

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

Signature: t1:4243830:1480437984:1c679c9db516bab905d027061326a7a1524922c6
2016-11-29 11:18:00 +00:00
Jun Wu
38e3389cbb build: fix build errors caused by chgserver moved to core
Test Plan: `arc diff`

Reviewers: #sourcecontrol, mjpieters

Reviewed By: mjpieters

Subscribers: mjpieters

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

Signature: t1:4244233:1480432440:104d3b082b9affddf1d44bb3cfc5f997eb7e9afa
2016-11-29 15:14:51 +00:00
Arun Kulshreshtha
73155a224e allowunstable: add allowunstable extension
Summary: Currently, the reason we can't perform operations such as histedit, split, and fold in the middle of a stack is that we do not have the experimental.evolution=allowunstable option enabled. It turns out all of these commands will do the "right thing" if this option is enabled. However, since we are uncertain of the ramifications of enabling this option globally, this new extension turns the option on for the duration of split, fold, and histedit, allowing those commands to be used in the middle of a stack without config changes.

Test Plan: See unit tests. Basically, create a stack and then attempt to use split, fold, or histedit somewhere in the middle.

Reviewers: #mercurial, durham

Reviewed By: durham

Subscribers: mjpieters, #sourcecontrol

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

Tasks: 14598405

Signature: t1:4209315:1479744780:811e8bef02149a055376c0f105ac2d389dd60970
2016-11-28 10:43:34 -08:00
Arun Kulshreshtha
8408c71376 smartlog: add template keywords for split, fold, and histedit
Summary: Add template keywords for split, folded, and histedited successors. This will enable us to show "(Histedited as XXX)" annotations in smartlog.

Test Plan: By itself this should be a no-op. All unit tests still pass. The effects of this aren't visible unless a user uses a version of our facebook.rc config file that contains updated smartlog templates. See D4209113.

Reviewers: durham

Reviewed By: durham

Subscribers: mjpieters, #sourcecontrol

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

Signature: t1:4209314:1479744837:8eeeeb7a031abfabeb302abde9e4b1f3d789a479
2016-11-28 10:43:32 -08:00
Jun Wu
d203784d68 pyflakes: fix all pyflakes issues
Summary: As the title.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, stash, rmcelroy

Reviewed By: stash, rmcelroy

Subscribers: rmcelroy, stash, mjpieters

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

Signature: t1:4232321:1480067588:54e91ece8fa6b5ff13b3ebc9279217c76bf96a24
2016-11-25 00:23:21 +00:00
Stanislau Hlebik
2a0e8205d4 extutil: create new package and move runshellfast here
Summary:
I'm going to use runshellfast in infinitepush.
To avoid copy-paste let's move it to the separate package.
Note: fastmanifest also has runshellfast but it's implementation
is a bit different and seems that it doesn't work with remotefilelog.
So I'll leave it alone for now.

Test Plan: python run-tests.py -j20

Reviewers: #sourcecontrol

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4175836
2016-11-21 00:52:30 -08:00
Durham Goode
8e63595d58 catnotate: fix to work with manifestlog
Summary:
Upstream has refactored the manifest to be a manifestlog, so we need to update
our usage of it accordingly.

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4180889:1479228547:378f91b556493e05ff0222449b43cf498c301467
2016-11-16 12:11:13 -08:00
Durham Goode
7a97fe8dca pushrebase: fix to work with new manifestlog
Summary:
Upstream has refactored the manifest class, so we need to update pushrebase to
work with the new structure. In particular, pushrebase takes advantage of the
manifest cache, so we need to carefully reconstruct the appropriate cache on the
bundle repo. We can't just .copy() it now because the cache contains manifestctx
instead of manifestdict, and the manifestctx contains a reference to the source
repo.

Test Plan: Ran the tests

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4180885:1479228506:a0ff114e158caab25da22f6116e5a4090f5515c0
2016-11-16 12:11:11 -08:00
Jun Wu
ca10807a38 fbamend: fix Python 2.6 syntax 2016-11-16 14:23:57 +00:00
Arun Kulshreshtha
9e77a16c75 fbamend: remove old implementation of hg next --rebase
Summary: Remove the old _nextrebase() function. This function is no longer used after the updates to `hg previous` and `hg next`.

Test Plan: All unit tests pass. This code is not called anywhere so removing it should be a no-op.

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 14119420

Signature: t1:4121784:1478305767:15a737545d0e85c175018e190cb92f722ebad7d8
2016-11-15 18:46:59 -08:00
Arun Kulshreshtha
97ed6a8afa fbamend: add new implementations of hg previous and hg next
Summary:
This diff replaces the `hg previous` and `hg next` commands from the evolve extension with new implementations. The new commands have several features not found in evolve:

  - Users can now move by multiple commits at a time. Example: `hg next 3`
  - Users can move all the way to the top or bottom of the current stack with the following new flags: `hg next --top` and `hg prev --bottom`
  - Users can rebase child commits on demand with `hg next --rebase`. This flag can be combined with the others to specify exactly how many commits to rebase. Example: `hg next --rebase 4` (move 4 commits up the stack, rebasing as needed) `hg next --rebase --top` (rebase all the way to the top of the stack)
  - When a user lands on a particular commit, if there is a bookmark it will be automatically activated. The user can also move to the previous or next commit with a bookmark with the `--bookmark` flag.
  - The user can pass the `--newest` flag to resolve ambiguity in situations where history is nonlinear. With the flag the command will always choose the commit with the higher rev number at each step.
  - The commands now show commit hashes instead of rev numbers when showing the user what commit they landed on.

Apologies in advance for the large diff. I've tried splitting it up as best as I could, but the unit tests introduced here significantly increase the size. I figured the unit tests should be part of this diff instead of being added in a separate one. This diff is almost entirely new code, so I hope that helps a little bit. Let me know if there's a better way to split this up.

Test Plan: See the new unit tests for an extensive look at the new commands in action. Essentially, all of the features mentioned above should work as expected.

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: stash, mjpieters

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

Tasks: 14119420

Signature: t1:4121778:1478774243:a7131593222bc329f541e77e1d3ebd8222e47e79
2016-11-15 18:46:56 -08:00
Arun Kulshreshtha
79ca27552d fbamend: make inhibit extension's post-transaction callback fire after rebase
Summary: The new `hg next` and `hg previous` implementations rely on the inhibit extension to inhibit visible obsolete changesets, thereby preventing unstable descendants from appearing as "unstable" in smartlog for end users. The inhibit extension does this by registering a callback that runs whenever a transaction closes. However, it turns out that this callback isn't being called at the end of a rebase, so we need to add a transaction to call it ourselves.

Test Plan: All unit tests for fbamend still pass. Currently, there isn't a way to demonstrate the issue that occurs if this code isn't here; the new `hg previous` and `hg next` functions introduced in the next diff in this stack do provide a unit test to check for this behavior.

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: rmcelroy, mjpieters

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

Tasks: 14119420

Signature: t1:4121768:1479264251:841bd6473df810e3d663550ef48ec6948476f3a2
2016-11-15 18:46:52 -08:00
Jun Wu
127bd207b5 linkrevcache: wrap _adjustlinkrev to take advantage of the linkrev database
Summary:
Wrap `_adjustlinkrev` so it first tries the possibly faster path (linkrev
database). Then fallback to the original linkrev algorithm.

Also fixes an issue that `{k : v ...}` syntax does not work in Python 2.6.

Test Plan: Added a very simple test

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: durham, stash, mjpieters

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

Signature: t1:4143315:1479234110:07e87c7584e0cfd627b3f9e2fae1a2a34beb390f
2016-11-14 18:04:29 +00:00
Wez Furlong
9b5499d572 phabdiff: don't require a space when parsing the Tasks field
Summary: Allow for any number of spaces after the colon

Test Plan: arc unit

Reviewers: #sourcecontrol

Subscribers: markisaa

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

Tasks: 14532985
2016-11-15 12:28:21 -08:00
Jun Wu
6860161db4 linkrevcache: add a command to verify the linkrev database
Summary:
Adds a `debugverifylinkrevcache` to verify the linkrevs in the database,
against the vanilla adjustlinkrev algorithm.

Test Plan: A simple test is added. The code is also manually tested on my hg repo.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:4143240:1479217639:bb9b5814b405b9e60a0722b01fc2c918c5a24b35
2016-11-14 18:04:29 +00:00
Jun Wu
6864d82976 linkrevcache: add a command to build the linkrev database
Summary:
This diff implements a `debugbuildlinkrevcache` command which builds the
linkrev database.

Test Plan: A simple test will be added when the cache can be verified.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: stash, jsgf, mjpieters

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

Signature: t1:4143200:1479131313:858042c86b5894898333900f63ea0cd50c47e934
2016-11-14 18:10:30 +00:00
Jun Wu
de07b8a110 linkrevcache: attach the linkrev database to the repo object
Summary: This diff makes the linkrev database accessible via `repo._linkrevcache`.

Test Plan: A test will be added when the feature is more complete.

Reviewers: #sourcecontrol, jeroenv

Reviewed By: jeroenv

Subscribers: jeroenv, mjpieters

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

Signature: t1:4143175:1478558825:2c0eb0fa0f77cf004aee7c40ffc2a6ea417f6212
2016-11-14 18:08:30 +00:00
Jun Wu
dd91b969e6 linkrevcache: implement the database
Summary:
This diff implements some simple linkrev database classes which uses dbm to
store linkrev candidates.

Why not sqlite? sqlite's insertion seems to be much slower with index being
present, so we have to do manual buffering and do insertion in batch, not to
say parsing SQL itself can introduce overhead. If we really want sqlite for
some reason (i.e. its support for concurrent writer and reader seems to be
better), we can still implement it as a dbm engine.

Test Plan: A test will be added when there is something usable.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: jsgf, stash, mjpieters

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

Signature: t1:4143119:1479131795:5f6e368ebd1798b874cec28ac05b137eb3bea86e
2016-11-14 18:03:15 +00:00
Arun Kulshreshtha
1c6b719130 fbamend: make restack start from bottom of the stack
Summary:
Previously, `hg rebase --restack` would find the closest stable base commit with unstable descendants on its precursors, and begin the restack operation from this commit. What this meant is that it would not resolve all instability in the current stack -- only instability above the first instance of instability detected by searching downward from the current changeset.

Given that we will soon be able to perform local fixup operations with something like `hg next --rebase --top`, it no longer makes sense to keep `hg rebase --restack` as a local operation. Instead, it should resolve all instability in the current stack. This diff changes the behavior to always begin restacking from the bottom of the stack.

One thing to note about this diff is that it completely removes divergence detection from restack. This is because in the process of making this change, I discovered a bug in the original version of restack whereby divergence would only be detected if it involved a precursor of the base changeset. This is because the check was only happening in _latest(), which after several rounds of changes to this code, was only being used in _findstablebase(). In all other cases, the implicit behavior was that unstable children are rebased onto the newest visible successor of their parent, as determined by rev number.

It turns out that altering this behavior to skip rebasing unstable descendants of divergent changesets is nontrivial, and furthermore, one could argue that the current behavior is actually desirable. (Furthermore, this change removes the O(n^2) behavior from _latest().) Regardless of whether it is desirable or not, this diff makes that implicit behavior explicit, and modifies the tests to explicitly check for the new behavior. If we do decide to skip divergent changesets, this will need to happen in another diff as it will require some restructuring of the restack target finding logic.

Test Plan:
See unit tests.

1. Create a stack of commits.
2. Pick several commits in the stack, and amend them without the `--rebase` flag, thereby leaving their respective descendants unrebased.
3. Update to the top of the stack.
4. Run `hg rebase --restack`. All instability will be resolved.

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 14041544

Signature: t1:4144899:1478781779:1a94dbc1c6b69d7116f1d40593a83684ed44942a
2016-11-10 11:25:19 -08:00
Arun Kulshreshtha
8afd0a8a75 fbamend: add helper functions for hg previous and hg next
Summary: Add some miscellaneous new helper functions that will be used in the new implementation of `hg previous` and `hg next`. These are just utility functions for things like setting bookmarks, printing out changeset lists, and hiding command line options. Also fixed a few typos in comments.

Test Plan: All tests still pass. This change should be a no-op as these functions are not called anywhere.

Reviewers: durham, quark, #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Tasks: 14119420

Signature: t1:4121764:1478162841:32362fef3727e67e46b5700d9242be5c0cd62a52
2016-11-03 11:11:41 -07:00
Arun Kulshreshtha
2e9aba5940 fbamend: rename/refactor wrapper functions
Summary: Do a minor refactor and rename of some of the wrapper functions in this file. There are no functional changes. These names were chosen to follow a consistent convention and be less confusing when taken together with the new `hg previous` and `hg next` functions that will be added in a later diff.

Test Plan: All tests still pass.

Reviewers: durham, quark, stash

Reviewed By: stash

Subscribers: mjpieters

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

Tasks: 14119420

Signature: t1:4121755:1478164041:d8c603c32554d1d7c1df9706386c015f90ad62c6
2016-11-03 11:11:39 -07:00
Jun Wu
93c918c92e absorb: fix an issue where changesets do not get deleted correctly
Summary:
The old code didn't test if the new commit will become empty correctly, if its
"memworkingcopy" contains changes inherited from its parent. This diff fixes
the problem.

Thanks @stash for discovering the issue!

Test Plan: Added a test case for this issue. Make sure the old code cannot pass.

Reviewers: #mercurial, stash

Reviewed By: stash

Subscribers: mjpieters, stash

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

Signature: t1:4113438:1478077373:194104b902bdfe6827858c2916a7f3f0cd83ee6c
2016-11-01 21:16:13 +00:00
Jun Wu
6318d6eb2a smartlog: do not change node char for fake nodes
Summary:
The fake node has an illegal revision number that cannot be used in the
`allsuccessors` revset.

Test Plan: It should work in theory. I couldn't construct a testcase relatively quickly.

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:4082186:1477503381:ac646071af5ad0e63a83ca7199e62a75ef736bce
2016-10-26 18:33:10 +01:00
Arun Kulshreshtha
5ae81e0470 smartlog: show inhibited obsolete nodes as x's
Summary: Make nodes with visible successors render as 'x' in hg smartlog output. Previously these nodes were rendered as 'o' because the inhibit extension made them appear to be non-obsolete.

Test Plan:
1. Create a stack of commits.
2. Amend a commit in the middle of the stack.
3. Run `hg sl`, observe that although the precursor of the amended commit renders as an 'x'.
4. Run `hg unamend`, then update to a different commit (so the precursor is not the current commit and thus not rendered as '@').
5. Observe that the precursor now appears as 'o' again because it has no visible successors.

Reviewers: #sourcecontrol, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 13652083

Signature: t1:4071058:1477434742:f57bf5a07b6b9497472deb8445f5fc01a5379f8c
2016-10-25 17:22:22 -07:00
Arun Kulshreshtha
0943b06da1 fbamend: add config option to use restack instead of preamend bookmark
Summary: Added a configuration option to make fbamend use the functionality from `hg rebase --restack` instead of the previous bookmark-based approach in `hg amend`.

Test Plan: Enable the `fbamend.userestack` config option and attempt to use `hg amend`, `hg amend --fixup`, and `hg amend --rebase`. These should all work just as before, except that `hg amend` will no longer create .preamend bookmarks.

Reviewers: #sourcecontrol, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 13839177

Signature: t1:4062925:1477359251:0ece10599987d6b8e39384e9530866ffb2e50e58
2016-10-25 11:10:47 -07:00
Arun Kulshreshtha
c7f2693ddb fbamend: add metadata to obsmarkers created by hg next --rebase
Summary: `hg next --rebase` was not adding metadata to the obsolescence markers it manually creates (manual creation is necessary because of the --keep flag), which meant that `hg sl` output did not show "Rebased as XXX" annotations for commits rebased using this command. This change adds the metadata.

Test Plan:
1. Create a stack of commits.
2. Amend a commit that is at least 2 commits from the top of the stack. (This way rebasing this commit's child will not result in the entire old stack getting deinhibited.)
3. Run `hg next --rebase`.
4. Run `hg sl`, observe that the rebased child is annotated as "Rebased as XXX".

Reviewers: quark, #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 14027474

Signature: t1:4060814:1477094781:5bf0b2b42eafcb2267ff6821e33d5e8fe7059eb0
2016-10-21 17:58:19 -07:00
Arun Kulshreshtha
1d80ea88ea fbamend: remove unused variables from unamend
Summary: These variables were unused, causing test-check-pyflakes.t to fail whenever fbamend.py is modified in a way that changes the line numbers of those assignments.

Test Plan: Unit tests still pass (except test-fbamend.t, which fails for reasons unrelated to this change)

Reviewers: durham, #sourcecontrol, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:4055599:1477049676:84ec9a1036bb6d6873d497caed9feff701a8169b
2016-10-21 12:32:03 -07:00
Mateusz Kwapich
d85d95b667 integration tests for sqldirstate/fbhistedit and "hg amend" test for latter
Summary:
This diff was created when I was investigating hgamend exec not working
with histedit which resulted with [1].
This also brings some very small fixes for sqldirstate and fbamend that
I was too lazy to diff separately.

[1] https://patchwork.mercurial-scm.org/patch/16451/

Test Plan: ran tests

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:3777784:1472227075:f2f8a9cad22bf0c45d4554709846b8aafb61d9a0
2016-10-21 06:01:59 -07:00
Jun Wu
e9776efcd7 patchpython: fix test-check tests
Summary: Resolve pyflakes issues caused by patchpython.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4051110:1476985498:3582ddf70780537a7902fece3ab847bc9effd744
2016-10-20 16:03:31 +01:00
Jun Wu
4816fb9b86 absorb: fix test-check issues
Summary: This diff fixes test-check issues related to `absorb`.

Test Plan: `arc unit`

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4050973:1476985180:1bcd81297933c1488372b6c4bb7e5ea46f8105b0
2016-10-20 14:59:20 +01:00
Jun Wu
c11cddecf5 test-check: backport test-check-execute from core hg
Test Plan: `arc unit`

Reviewers: #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:4037205:1476876512:e7659ce8add7fabacb50bb5fb3fe1f1d1744c304
2016-10-18 17:58:45 +01:00
Arun Kulshreshtha
6d9d6b699f Update revset in hg rebase --restack
Summary: Benchmarking `hg rebase --restack` against `hg evolve --all` showed that `hg rebase --restack` was spending a lot of time on a single revset to identify the current stack of commits. This diff changes the revset to an equivalent but more efficient one.

Test Plan:
All unit tests still pass.

For benchmarking, I created a stack of 4 commits on top of remote/master in fbsource/fbcode. I amended the second commit and then ran the command. Here is profiler output for both before and after the change:

Before (10.87 seconds): P56747821
After (7.58 seconds): P56747927

Based on the profiler output, this change results in a 30% performance improvement in this case.

Reviewers: durham, #sourcecontrol, quark

Reviewed By: quark

Subscribers: quark, mjpieters

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

Tasks: 13976698

Signature: t1:4038630:1476825563:02da1d4e459f780de41d852f88da789513aba7dc
2016-10-18 14:20:37 -07:00
Jun Wu
da4275caa9 sshaskpass: backup tty fds in case they get overrided later
Summary:
The current `sshaskpass` implementation relies on `stdin` and `stderr` being
TTYs. That can not be guaranteed if pager is used. With chg enabled, the chg
client will call `attachio` when starting the pager, and it which will override
both `stdin` and `stderr` to the pipes created by the chg pager logic. This
causes failures when a paged command (like `hg diff`) needs interactive ssh
authentication (happens when remotefilelog cache misses).

This patch fixes it by backing up TTY fds inside the `sshaskpass` module. With
chg enabled, the first `attachio` (before starting pager) can provide TTY fds,
where we just back them up. The second `attachio` (after pager started) will
override `ui.fin/fout`, `sys.stdin/stdout` to non-tty fds but it does not matter
since we have backups.

Test Plan:
Run the following command in a remotefilelog repo:

```
rm /tmp/chg$UID /tmp/r -rf; chg diff --config remotefilelog.cachepath=/tmp/r --debug --pager=on
```

And confirm password prompt works as expected.

Reviewers: rmcelroy, #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4032236:1476755400:80fc6007b6fb2f9fe83cf6570d80a2b431fc069f
2016-10-17 21:28:33 +01:00
Arun Kulshreshtha
37cf7bd354 Make hg rebase --restack smarter
Differential Revision: https://phabricator.intern.facebook.com/D4000348
2016-10-14 11:05:53 -07:00
Adam Simpkins
7f1c4eb449 [sparse] make sure "hg update --clean" correctly forgets about excluded files
Summary:
A user ran into a bug where a failed rebase left their repository in a state
where "hg status" reported many excluded files had been removed.

They weren't able to recover from this state, even using "hg update --clean ."
This was because the sparse extension was ignoring the actions to forget these
files from the dirstate.  The sparse extension should allow excluded files to
be forgotten.

Test Plan:
I tried writing a test case for this but wasn't able to figure out how to
trigger exactly the situation that the user's repository was in.  (It looks
like there were other bugs in "hg rebase --abort" that led to their repository
state.)

I was able to cause some other problems with files in the "g" type
("remote created") that "hg update --clean" wouldn't fix.  I haven't added
those test cases for now though, since that problem isnt' fixed by this diff.
It does seem like there are potentially other problems here that still need to
be addressed.

Reviewers: quark, rmcelroy, mjpieters, durham

Reviewed By: durham

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

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

Tasks: 13694820

Signature: t1:3966580:1475676328:48433e203ae702a50b40176e52f1ed90a5c45504
2016-10-13 11:49:58 -07:00
Jun Wu
82b158ed59 githelp: fix crash in mergebase
Summary: `_` does not take two arguments while `ui.status` does.

Test Plan: Added a test case

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:4010079:1476298648:81e678fbe433aa8cca8b03c9eba50d9b78bbc9bb

Blame Revision: D2811887
2016-10-12 19:47:42 +01:00
Arun Kulshreshtha
a154bbaeb0 Add hg rebase --restack
Summary:
This change adds a `--restack` option to `hg rebase`. When invoked, the command will rebase all descendants of precursors of the current changeset onto the current changeset. This is similar to the behavior of `hg evolve --all`, except it only handles unstable changesets, and not other issues that can arise from shared mutable history such as divergence or bumping.

I've been playing around with some of the more advanced features (such as allowing the command to be run from anywhere in the old stack or new stack, as well as allowing the user to specify the number of changesets to rebase), but I wanted to upload the most simple iteration of this command for feedback.

Test Plan:
See unit tests for complete commands.

1. Create a stack of commits.
2. Somewhere in the middle of the stack, amend a commit, potentially several times.
3. Run `hg rebase --restack`.
4. The top half of the stack should be rebased onto the amended commit, and the preamend bookmark should be gone.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: rmcelroy, quark, mjpieters

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

Tasks: 13651947

Signature: t1:3972103:1476230834:8f77eac4e8d8681dd9f8125747c1ff75c8da1ad8
2016-10-11 17:41:07 -07:00
Adam Simpkins
89f30244e5 [phrevset] fix "invalid literal for int()" error
Summary:
Fix the revsetdiff() function to always return a revision number.

Previously if the revision information was retreived from phabricator rather
than being found locally we return a changeset string rather than a revision
number.  This fixes the code to convert the changeset string back to a revision
number.  If the specified commit does not exist in the local repository, we
throw an error indicating that the user should run "hg pull"

Test Plan:
Tested running "hg graft -r DXXXXXXX" with a diff that was not present in the
local repository yet.  Confirmed it now prints an error indicating that the
user needs to run "hg pull" to fetch this revision, whereas previously it
crashed with an "invalid literal for int()" error.

Reviewers: #sourcecontrol, durham, simonfar, quark

Reviewed By: quark

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

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

Tasks: 11355408

Signature: t1:3997925:1476201895:9b5832dc28abdddaa281a848246476b78f5a9fe7
2016-10-11 11:13:58 -07:00
Arun Kulshreshtha
19db7fa2a6 Remove unused imports.
Summary:
fbamend.py has several unused imports. This is annoying since I'm actively working on this file.
This change removes and consolidates the imports.

Test Plan: All unit tests for this file (namely test-fbamend.py and test-fbamend-nextrebase.py) still pass.

Reviewers: #sourcecontrol, durham, quark, stash

Reviewed By: stash

Subscribers: mjpieters

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

Signature: t1:3965839:1475573964:e7937ce7e7bc35655d629345156c4d177f185605
2016-10-04 10:29:55 -07:00
Ryan McElroy
78f0c73d4b extension to print commit message that would be supplied to editor
Summary:
the nuclide team would like to be able to get the commit template
message without actually invoking a commit. This small extensions allows them
to do this.

Caveats: ignores subrepositories.

Test Plan: new test

Reviewers: #mercurial, most

Subscribers: mjpieters

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

Tasks: 12771006
2016-10-03 04:39:51 -07:00
Zach Amsden
2f33513a19 Log interactive time, internal command timing to scuba
Summary:
Use wrappers around ui functions to exclude interactive
and log the results to scuba.

Test Plan:
   USE_DIST_HG= FB_HG_DIAGS= CHGDISABLE= hg --config 'extensions.profiling=~/facebook-hg-rpms/fb-hgext/hgext3rd/profiling.py'  --pager=off --config profiling.enabled=False amend --edit
  chg: disabled by CHGDISABLE
  internal stats file: /tmp/scm-internal-statsx9EXSw
  hg profiling mode: SKIPPED
  stats: {
      "int": {
          "builddate": 1471281577,
          "cachehitratio": 75,
          "consumed": 425,
          "diffcachehitratio": -1,
          "elapsed": 1921,
          "errorcode": 0,
          "filesnotincachehitratio": -1,
          "interactive_time": 1534,
          "internal_time": 1701,
          "time": 1473459054
      },



Tested both with and without chg to make sure both modes work, otherwise
there are some subtle bugs that can come up under hg (timer becomes persistent
if invoked too early in uisetup).

Check out scuba table, new columns are showing up.  I still need to clean up the table as I accidentally added data as string first.

Reviewers: #sourcecontrol, ttung, quark, durham

Reviewed By: durham

Subscribers: giorgioc, mjpieters, akushner

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

Tasks: 12879683

Signature: t1:3844697:1475250469:a46aff22781e0e07596e2880d6477a62754f1397
2016-09-30 12:32:21 -07:00
Arun Kulshreshtha
bc3b0cd1c7 Make hg next --rebase intelligently obsolete/inhibit changesets
Summary:
This change updates the behavior hg next --rebase. Specifically:

  - Only one changeset can be rebased at a time. If there are multiple candidate changesets, the command aborts.
  - Each time a changeset is rebased, its precursor is marked as obsolete, inhibition markers are stripped from it and its ancestors, and its preamend bookmark is deleted, if one exists.
  - The result of this is that if no non-obsolete changesets depend on the existence of the pre-rebased changeset, that changeset and its ancestors will be stripped, resulting in a cleaner user experience.
  - This change also adds back the --evolve flag, but makes it show in error instead of working. It turns out that removing the flag outright breaks the evolve extension.

Test Plan:
See updated unit tests for the exact commands to run to test this, as well as an overview of all of the new situations where behavior was changed.

A basic test plan would be:
1. Initialize a new repository, and create a stack of 4 commits.
2. Amend the second commit in the stack.
3. Do `hg next --rebase`. It should work as before.
4. Do `hg next --rebase` again. This time, the entire old stack should "disappear" from hg sl.

Additionally, attempting to run `hg next --rebase` when there are multiple possible child changesets should fail.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: quark, mjpieters

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

Tasks: 13570554

Signature: t1:3941922:1475205056:58a8d1726cfcccbf14a38727be0220a09532ec97
2016-09-30 10:40:58 -07:00
Jun Wu
efb6a83a3e smartlog: remove unused edge when indentnonpublic is set
Summary:
This patch removes the unused line and space so it looks a bit better:

```
 .
 .
 .
 | o          o
 | |          |
 | |          |
 | o          o
 |/          /
 |          |
 o          o
 .          .
 .          .
(before)   (after)
```

Due to the current implementation of graphlog, it's a bit hacky to achieve the
above effect.

Test Plan: Run `test-smartlog*.t`

Reviewers: #mercurial, ttung, mjpieters, durham

Reviewed By: durham

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

Signature: t1:3881516:1475170264:477c66b2372d04c4e5d7c8fbb69de30599706e5d
2016-09-17 02:22:36 +01:00
Ryan McElroy
7e63ec0dce rage: use hg sl instead of smartlog to get better template
Summary:
The default template is more compact and more useful with thigns like remote
bookmarks included.

Also drop '--all' and add '--hidden' since recent commits are much more
interesting than old commits and recent hidden commits will be useful when
people have recently lost something.

Test Plan: run `hg rage`, look at paste produced

Reviewers: #mercurial, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3904646:1475171650:fc1bab0062be39c590b61492bce42236f3bb6123
2016-09-29 11:19:52 -07:00
Jun Wu
4cc05e5d24 absorb: improve rename handling
Summary:
Previously `absorb` does not care too much about copies or renames and
assumesa file path only exists in every changeset of `stack[k:len(stack)]`,
but does not exist in any of `stack[0:k]`. If this assumption is not true,
absorb will likely crash.

This patch implements copy or rename handling correctly. After this patch,
renames happens to a single file is tracked correctly. Copies are ignored
by default. For the "double move" case, like:

  hg cp a a1
  hg cp a a2
  hg rm a

We only follow the first path (sorted alphabetically). In this case, changes
to "a1" could affect the content of "a" in a previous changeset, while changes
to "a2" couldn't.

Test Plan: Added a new test

Reviewers: durham, #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3941438:1475166850:97461174619d469750146e25f6bff16dae19bd3d
2016-09-28 23:56:43 +01:00
Stanislau Hlebik
bbb7f15c99 pushrebase: cleanup
Summary: Remove unused imports + fix missing variable error in `_checkheads()`.

Test Plan: Added a new test.

Reviewers: quark, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3862724:1474283118:deceacc683bb079eb7afb2ea34fb1e196f9bb18b
2016-09-26 01:48:13 -07:00
Arun Kulshreshtha
ce03ceb66c Add hg next --rebase
Summary:
This diff adds the --rebase option to the `hg next` command by extending
the evolve extension in the fbamend extension.

The --rebase option finds any child commits of the obsolete precursor to the
current commit, and rebases them onto the current commit before performing
`hg next`. This way, one can be in the middle of a stack of commits, amend one
in the middle, and do `hg next` without running `hg amend --fixup`. The next
commit will be correctly found, rebased, and updated to.

This is equivalent to:



  hg rebase -d . -r "children(OLD_HASH)" -k && hg next

Test Plan:
I tested this command by hand and created some unit tests. The basic way to test it is:

1. `hg init` a new repository.
2. Create a chain of 3 commits.
3. Amend the 2nd commit.
4. Run `hg next --rebase` and confirm that the 3rd commit was rebased and switched to.

The exact commands to do this are in tests/test-fbamend-nextrebase.t. This file also
contains test cases in which there are multiple child commits on the precursor, and cases
where there is a rebase conflict.

Reviewers: #sourcecontrol, durham

Reviewed By: durham

Subscribers: mjpieters, nain

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

Tasks: 13347995

Signature: t1:3910568:1474650102:8c7dd712afb9d36f29e1e73bb781e1d8e0870371
2016-09-23 10:39:36 -07:00
Jun Wu
aaafeda370 smartlog: use graphstyle.grandparent to draw ellipsis
Summary:
Now that the graph module can draw "..." for grand parents, it's no longer
to have fake nodes for that purpose. Remove most fake node related logic.

This will make the output more compact.

Note that the fake node is still used for "indentnonpublic" and its output
is slightly changed to display an "o" node, which will be fixed in the next
diff.

Since we now rely on a recent version of mercurial, remove some "inspect"
check for ancient mercurial support.

Test Plan: Run the modified `test-smartlog.t` and other `test-smartlog*.t`.

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:3880771:1474306496:3400c70efbb569c5096e724720ead1992b87f160
2016-09-17 00:51:26 +01:00
Jun Wu
dfa3d19fc2 smartlog: add an option to indent the non-public stack at the top
Summary:
One thing that may confuse new users is that when draft changesets are on top
of public changesets:

```
o draft
|
o remote/master
```

It's unclear whether the draft changeset is already in the master branch, or not.

This diff adds an option to move the drafts to the second column to indicate they
are not part of master.

Test Plan: Run `test-smartlog.t`

Reviewers: ttung, durham, #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:3876951:1474043568:c97b26b49917f36a5197af93ea386658b91d56a4
2016-09-16 16:36:10 +01:00
Jun Wu
9fea0c3f0c doc: replace "commit" where it is used as a noun with "changeset"
Summary:
"changeset" is a more official term and let's use it. Note that this patch
only changes documentation / i18n messages visible to the users and header
comment blocks to developers. Other places like comments in the code are
untouched.

With the "dialect" extension enabled, users will still see the more friendly
term - "commit".

Test Plan:
`arc unit`. Note the remotefilelog failure is probably unrelated - seems
related to ongoing / upcoming manifest refactoring upstream.

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3900394:1474470348:6a1b5691e2599cc47df18b227d56d1f9d3c7c906
2016-09-21 15:45:25 +01:00
Jun Wu
9151f4abfb dialect: new extension to "translate" messages to a dialect
Summary:
As discussed before, we think terms like "changeset" is more official to hg,
while less known as "commit" is used more widely.

This extension replaces "changeset" with "commit" so users will get a
consistent view about the term being used, and we can use "changeset" in our
code to be more official while don't need to worry about user friendliness.

Test Plan: Run the newly added test

Reviewers: #sourcecontrol, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3900240:1474470482:44ac6e09d58e624c539bb1336842ce8911c9dcee
2016-09-21 15:04:42 +01:00
Jun Wu
73eac46994 grpcheck: new extension to check if the user is in given groups
Summary:
We have seen issues that users have outdated groups when running hg commands,
which will probably always cause issues:

- Authentication issue, unable to ssh
- Filesystem permission issue, unable to write hgcache
- Even worse with chg server since the long-running server process will keep
  the wrong groups information

This extension is to address the above issues. It allows us to print a message
to let the user know they have group issues. Besides, it allows us to override
configs like `chgserver.idletimeout` so chg servers with wrong groups can have
a much smaller TTL and won't be long-running and causing issues.

Test Plan: Run the newly added test

Reviewers: #sourcecontrol, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:3896628:1474454162:22785ff23e3ada75013ce5f1eead3407068ba172
2016-09-20 23:15:09 +01:00
Jun Wu
4637f4c7f2 absorb: fix insertion to an empty file
Summary:
When diffing a with b, if a is empty, we don't insert a "dummyendline" (see
line 214) because we do not have the last line to copy. In this case, if an
insertion happens, we have no "nearbylinenums" (see line 274) to visit.

The current code assumes "nearbylinenums" have at least one element, which
is wrong in the above case and will crash the program.

The fix is to add a check about whether "annotated" (aka. "a") is empty or
not.

Test Plan: Run `test-absorb-filefixupstate.py`

Reviewers: #sourcecontrol, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: durham, mjpieters

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

Tasks: 13371265

Signature: t1:3867686:1474289020:a183e6837e6e0afb8a5d56641689e240e8cd78c9
2016-09-15 00:59:29 +01:00
Jun Wu
9d18a32174 smartlog: improve documentation
Summary:
Add docstring so `hg help -e smartlog` works and the config options are more
visible to users.

Rename "commit" to "changeset" so it sounds more official in the hg community.

Test Plan: No logic change. Code Review

Reviewers: durham, #mercurial, ttung, mjpieters

Reviewed By: mjpieters

Subscribers: simonfar, mjpieters

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

Signature: t1:3876938:1474288105:cb751cc868e70761cf3b34749eabf2a32c886a2d
2016-09-16 23:48:42 +01:00
Jun Wu
316cae170e absorb: add an interface to edit lines for all involved revisions
Summary:
This feature allows the user to choose what lines exist in what changesets
precisely, for example:

    HG: editing a
    HG: "y" means the line to the right exists in the changeset to the top
    HG:
    HG: /---- 991104c93ef1 commit 1
    HG: |/--- aa7e21df9b0b commit 2
    HG: ||/-- 05b39f5d9141 commit 3
    HG: |||
        yyy : 1
         yy : 2
          y : 3

The feature can be used to "move" lines among changesets, or generally
editing the contents in a new way. So it's not limited in the "absorb"
use-case. We may want to give it another name in the future.

Test Plan: Added a new test case

Reviewers: #mercurial, rmcelroy, ttung

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3841494:1473769708:1bb2a46c010222438ceaae69ea0dca39e37581d2
2016-09-09 14:06:16 +01:00
Kostia Balytskyi
d098615fe2 reset: make reset support -r/--rev as this is what people often expect
Differential Revision: https://phabricator.intern.facebook.com/D3869912
2016-09-15 08:49:23 -07:00
Pierre-Yves David
f1c24eddea absorb: fix a typo in output
From 'changset' to 'changeset'.
2016-09-12 18:00:54 +02:00
Jun Wu
eb9e71ef7d sshaskpass: disable echo for Password: prompt
Summary:
While on Linux, `ssh` prompts `username's password:`, the OS X uses
`Password:`. Change `_shoulddisableecho` to include that case.

Test Plan:
Run `chg push ssh://localhost//tmp/foo` on an OS X system and check echo
is disabled for the password prompt.

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3841947:1473440175:ea2c171a4bfda9d00b4de8c7c51bb00d0b7194f1
2016-09-09 17:24:23 +01:00
Jun Wu
e2c14da0b2 fbhistedit: use ui.system instead of util.system
Summary:
`chg` has some special handling on `ui.system` - if it is simple, it will
be forwarded to the client (the `chg` process) and the new process will be
a child of `chg`, which will inherit the controlling TTY correctly.

Otherwise, it will be a child of a server-side worker process, which does
not have a controlling TTY. That's the case if `util.system` is used.

Test Plan:
Insert `x sleep 1000` in the histedit plan and confirm the `sleep`
process runs as a child of the `chg` process:

```
41876 13176 pts/14   Ss   03:17   0:00  \_ zsh
 4196   732 pts/14   S+   03:20   0:00  |   \_ chg histedit
 7572   664 pts/14   S+   03:20   0:00  |       \_ sleep 1000
```

Reviewers: #mercurial, ttung, rmcelroy, simpkins

Reviewed By: simpkins

Subscribers: mjpieters

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

Tasks: 13295639

Signature: t1:3846243:1473480297:59aaf34cb3a52200321122dc7c054e2454cd3bd3
2016-09-10 03:23:12 +01:00
Jun Wu
62306f5f04 fbhistedit: fix upstream compatibility
Summary:
The upstream changed the signature of `verify` in 9ec9fba6ea06
(`histedit: move constraint verification to the 'action.verify' method`):

  -    def verify(self, prev):
  +    def verify(self, prev, expected, seen):

The upstream also moves the check about `action.node` around so
they become required and we have to set `self.node` in our histedit actions.

Test Plan:
Run histedit with the latest (8a658b) upstream code. Use `x sleep 1` and
ensure it works.

Reviewers: #mercurial, ttung, ikostia

Reviewed By: ikostia

Subscribers: ikostia, mjpieters

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

Signature: t1:3846190:1473671179:97b238748e99a5868bb84614b89360e750b529a4
2016-09-10 03:03:37 +01:00
Stanislau Hlebik
11e4d7be5a logginghelper: return repo name instead of repo root
Summary:
logginghelper extension returns full path to the repo instead of just repo name.
It makes it hard to aggregate results per repo in scuba.
Use just repo name instead of repo root.
We can get repo name either from `paths.default` config value or
a basename of the repo root.

Test Plan:
Before:
{P56637657}

After:
{P56637661}

Diff
{P56637665}

Reviewers: rmcelroy, ttung, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3827912:1473413932:5c38ca48e58a080c97b35610ee8889d66b4d5ab3
2016-09-09 08:07:56 -07:00
Stanislau Hlebik
e64b96276e logginghelper: rename reporootlog to logginghelper
Summary:
We are going to log many different pieces of information in this extensions.
Therefore the `reporootlog` is not an appropriate name anymore.
Change it to `logginghelper`.

Test Plan:
Note that repo root is still logged instead of repo name. It will be changed in subsequent diffs
{P56637657}



Reviewers: rmcelroy, quark, ttung

Reviewed By: ttung

Subscribers: mjpieters

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

Signature: t1:3840985:1473410718:62d83f008f2973b7ed5266b0a5ebf67fe54b48c4
2016-09-09 08:04:03 -07:00
Stanislau Hlebik
92e9887bdb reporootlog: remove unused variable
Test Plan: Not tested

Reviewers: quark, rmcelroy, ttung

Reviewed By: ttung

Subscribers: mjpieters

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

Signature: t1:3827908:1473349204:23fe6cfdf0083be701c14b3988c2a7251321b246
2016-09-08 09:39:55 -07:00
Ryan McElroy
6e5a7ab866 pushrebase: fix for upstream api change
Summary:
In upstream mercurial, 3d5e0fd41e0e changed discovery.outgoing() from taking a
changelog to taking the full repo object.

Test Plan: run tests, fewer stacktraces

Reviewers: #mercurial, ttung, durham, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3819300:1473090807:fd0e4c2956fee4ad7d45051b6b7c5be481c766f1
2016-09-05 12:02:23 -07:00
Mathias De Maré
96605a0ea5 absorb: correctly pass executable mode in getfile
getfile should return the file mode as (islink, isexec),
but it was returned as (islink, isbinary).
As a result, using 'hg absorb' removed executable mode from
the relevant changeset so the mode change showed up in the working directory.

Issue reported with test case by Thomas De Schampheleire.
2016-09-01 13:05:52 -07:00
Jun Wu
1b6413957a chistedit: workaround a Python bug
Summary:
See http://bugs.python.org/issue27666 for details.

`win.box(0, 0)` will crash python if it is built with stack check / protection
(by using hardening-wrapper with `HARDENING_STACK_CHECK=1` and
`HARDENING_STACK_PROTECTOR=2`).

Test Plan: Run `hg chistedit tip` on Arch Linux, and it does not crash instantly.

Reviewers: #sourcecontrol, ttung, jeroenv

Reviewed By: jeroenv

Subscribers: mjpieters

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

Signature: t1:3806224:1472758902:8a73645fd1ef98c9106c3b2766e368d4072a2d46
2016-09-01 20:18:36 +01:00
Jun Wu
9e1c1b0adf sshaskpass: do not import mercurial packages when running standalone
Summary:
The sshaskpass code is both an hg extension and a standalone python script.
In the latter case, it does not need to import mercurial packages (and
doing that may cause `ImportError` if `mercurial` is not in python path).

Test Plan:
Manually make the change in a Mac Mini device and check `chg pull` works
with ssh password authentication.

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:3799653:1472675282:9f7e9f4f29281db239f33cf396057ea12ff21773
2016-08-31 21:05:00 +01:00
Zach Amsden
214a35d6cb Fix statprof for upstream
Summary: Upstream mercurial has changed, breaking statprof

Test Plan: HGPROF=stat ./hg-dev  --config extensions.statprofext=~/facebook-hg-rpms/fb-hgext/hgext3rd/statprofext.py  --config profiling.enabled=True --config profiling.frequency=10000 --profile log -l 1000 --pager=off

Reviewers: durham, quark, #mercurial, ttung

Reviewed By: ttung

Subscribers: mjpieters

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

Signature: t1:3786387:1472497930:488d7d584395ca686de4dc458c87eb05fc944282
2016-08-29 15:23:04 -07:00
Steve Fink
c6e9bfc3fb chistedit: Disable numeric 'goto' command with large number of patches.
You can jump to a patch by pressing its numeric index, but this obviously only works with up to 10 patches. Moreover, with a large number of patches the feature is dangerous, since an accidental number press will lose your place. While we could do something fancy and prompt for multi-digit input in the many-patch case, it doesn't seem worth the complexity, and simply disabling 'goto' seems good enough.
2016-08-26 06:41:26 -07:00
Steve Fink
511e685836 chistedit: fix some off-by-ones in screen height 2016-08-26 06:41:26 -07:00
Mateusz Kwapich
4913062607 check-code fixes
Test Plan: check-code passing

Reviewers: #mercurial, ttung, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

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

Signature: t1:3771131:1472139248:f8ea463552fc0d2261456050e9bf513f26eb727c
2016-08-25 09:04:43 -07:00
Jun Wu
0184b72cf7 Rename "smartfixup" to "absorb"
Summary:
This seems to be an elegant choice. It does not conflict with other names,
and it does explain the concept to some extent vividly.

Credit goes to [trousers at lobste.rs](https://lobste.rs/s/nws1uj/help_us_name_new_mercurial_feature/comments/u4tsw7#c_u4tsw7).

Test Plan: Run the existing tests.

Reviewers: #sourcecontrol, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3763992:1472049269:5bb9de3b7b3a0f0dd9587b952151fc38351bc822
2016-08-24 16:28:47 +01:00
Jun Wu
350dae5587 smartfixup: add a config option to make it a subcommand of "amend"
Summary:
Some people think this command should be a part of "amend". If you check the
meaning of the "amend" English word, that makes sense. But if you look at
the actual "amend" command, there are significant differences:

1. smartfixup rewrites a stack of changesets, and can even delete
   changesets, where amend only rewrites the working directory parent.
2. smartfixup is best-effort, i.e. does not guarantee that 100% of
   user-requested modifications will be included, where amend will just take
   100% (with "-i", it's 100% chunks selected by the user).
3. a lot of "amend" flags do not make much sense to smartfixup, like message
   editing (designed to edit a single changeset), "--addremove", "--secret",
   etc.
4. literally, smartfixup shares little code with the existing "amend" logic.
   "amend" is part of "fbamend" or "evolve". this extension should not
   depend on any of them.

So it's cleaner to be a separate command, not a part of `amend`.

However, I think it makes sense to have an option to satisfy those who want
to use "amend". So they can use "amend --related", "amend --fixups",
"amend --stack", "amend --auto" or whatever they choose. This diff adds such
a config option. We may also ship such a config option to make the command
easier for discovery.

Note the "amend" version is slightly different from the original smartfixup
command. The former targets basic users who expect amend to take all of
their changes, while the latter targets power users understanding what's
going on.

Therefore, the "amend" version will print extra information about what
changes are ignored, for example:

```
# changes not applied and left in working directory:
# M a : 1 modified chunks were ignored
# M c : unsupported file type (ex. binary or link)
# R b : removed files were ignored
```

To support the above change, `fixupstate.status` was added to avoid a second
"status" run and handles the "status" with interactive mode correctly. An
issue about symbolic links being added to `fixupstate.paths` was fixed by
the way.

Test Plan: Run the newly changed test.

Reviewers: #sourcecontrol, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3760498:1472052376:7ddbfe763c7327d044b0d471c31a58fcb1e21dac
2016-08-24 16:28:15 +01:00
Zach Amsden
f99540d161 [fastlog-hg] Thread safety
Summary:
Sharing repo.changelog across threads is problematic in mercurial
since it may internally cache things, and clearing cache while another
thread is executing is not nice.  In particular, code such as the following
is inherently raceful when sharing changelogs (or anything derived from
revlog) across threads:

    if self._cache:
        if self._cache[0] == node:
            return self._cache[2]
        cachedrev = self._cache[1]

Reworked things a bit to make sure the spawned threads have their own
newly created changelogs and member functions internally referencing them.

Test Plan:
No longer seeing random exceptions being thrown from local log
threads (which terminates iteration)

Reviewers: rmcelroy, #mercurial, ttung, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3733592:1471908572:877b56241e56b6ea92c76023460d4fbe80a4263d
2016-08-23 11:46:34 -07:00
Zach Amsden
205a3b8a81 [fastlog-hg] Better multi-path and file support for fastlog
Summary:
The multi-path support is pretty shameful; we can
do much better by issuing multiple queries and combining
results.  File support was also missing.

Test Plan:
Ran fastlog test.  Need to update test to test files.

P56589012

Reviewers: quark, rmcelroy, durham

Reviewed By: durham

Subscribers: stash, mjpieters, jeroenv

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

Tasks: 12341014

Signature: t1:3726318:1471919354:e5e8f40a5b918b493e927c2d620da1fdefa1768c
2016-08-23 11:46:34 -07:00
Zach Amsden
fe94406e9a [fastlog-hg] Add localmatch function
Summary:
Bugfix - we were failing to check local patterns in the fastpath.
Pass a filtering function to the local log thread to limit its results.

Test Plan: Run local log

Reviewers: stash, quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3727573:1471907418:37b83d6c02e61ce2705070c7a86dd815a1c1cb29
2016-08-23 11:46:34 -07:00
Zach Amsden
76529f6745 [fastlog-hg] Pass revfn
Summary: Pass revfn to the thread to unify response messages.

Test Plan: Run unit test, try fastlog

Reviewers: quark, durham, rmcelroy, stash

Reviewed By: stash

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3727506:1471855144:24e622c6add0584d37539ea5ee319e3454f5313e
2016-08-23 11:46:34 -07:00
Zach Amsden
31382f23a3 [fastlog-hg] Better handling of exceptions
Summary: Without this, exceptions are super hard to debug

Test Plan: Manually force exceptions with bogus array indices on non-arrays

Reviewers: quark, #mercurial, ttung, durham

Reviewed By: durham

Subscribers: stash, mjpieters

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

Tasks: 12341014

Signature: t1:3744317:1471919239:8c8d0fce6c212fd677df8b7f94a48d17dbe64b93
2016-08-23 11:46:34 -07:00
Jun Wu
36544a8c4d smartfixup: add an interactive mode
Summary:
Like `commit -i`, this diff adds an `interactive` mode. I'd like
to reuse some patching code but they are tightly coupled about
writing files to disk - while I want to handle everything in memory.

In the future I may want to add `memorystore` and `memorybackend`
to upstream's `patch.py`. But they are not available now therefore
the "patching" logic is a re-invent. Fortunately the logic is just
about 20 lines.

Test Plan:
Manually run `hg sf -i` with some manually crafted random cases.
Also make sure it works with both `text` and `curses` interfaces.

Reviewers: #mercurial, durham, ttung

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3723179:1471582313:b10d278ca5b1a2aee6b41936f315a960edee92ed
2016-08-23 15:20:20 +01:00
Jun Wu
dea474ec1f smartfixup: add command line options to preview changes
Summary:
The `--print-changes` option will show which commit, a changed lines will be
applied to. Note it is a bit expensive so we only calculate the content when
being asked.

The `--dry-run` option will prevent the final commit operation.

Users can now use `-pn` to preview changes to understand what will be changed.

Test Plan: Run `test-smartfixup.t`

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: mjpieters

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

Signature: t1:3719673:1471582117:7f3be3c3bf3829148c3d096d2aae6e7382449b98
2016-08-23 15:19:54 +01:00
Jun Wu
a51d83bec3 smartfixup: implement the command
Summary:
This is the last piece of the initial smartfixup implementation: the command.
A new test was added to test the command.

Test Plan: Run the newly added test

Reviewers: #mercurial, ttung, jbower, durham

Reviewed By: durham

Subscribers: akushner, simonfar, durham, jbower, mjpieters

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

Signature: t1:3717354:1471629588:202e4a5820de472eb131eb968ec73f194d2c077d
2016-08-23 15:19:29 +01:00
Jun Wu
0087ee33bf smartfixup: implement fixupstate
Summary:
If `filefixupstate` is to `filecontext`, `fixupstate` is to `context`.
This does the actual committing, creating obsmarkers, moving bookmarks work.

Test Plan: A new test will be included in the next diff

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3716954:1471639171:9891a0c64365b0592f5a4d86e3c83d521b4c5bb2
2016-08-23 15:18:36 +01:00
Jun Wu
7683c76566 smartfixup: implement filefixupstate
Summary:
The `filefixupstate` object maintains states and contains logic related to
do "smartfixup" to a single file.

Test Plan: Added a new test

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3716761:1471919159:033e79e9d12307785863959dd5d82a7c3c647ff3
2016-08-23 15:17:42 +01:00
Jun Wu
98861bc86e smartfixup: add utilities
Summary:
This series is a rewrite of D3264203, using the `linelog` instead of
`histedit`. The new version has the following advantages:

  - handle more cases where it could be a merge conflict with a traditional
    merge algorithm. the old code tries to "predict" when a merge won't
    cause conflicts. but that's just kinda stupid - comparing with the new
    code using linelog - it is just impossible to produce merge conflicts.
  - do not touch working copy - all intermediate calculations and states are
    in memory. say goodbye to the clean working copy requirement of histedit.
  - handle line numbers cleanly and confidently - the old code struggles (but
    failed) to make line numbers correct after each edits, while it is
    actually hard as the "merge" operation could change line numbers in an
    unpredictable way. the new code using linelog can just edit chunks from
    an old revision, from the latest view without checking out that old
    revision first. therefore no need to mess up with line numbers.

This diff adds utility functions and classes used later. It introduces
unused `import`s but they will be used later.

Test Plan: `arc lint`

Reviewers: #mercurial, ttung, durham

Reviewed By: durham

Subscribers: durham, mjpieters

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

Signature: t1:3716758:1471556512:0fbff8f6fe4bc02d2120c723d2cc28676895c679
2016-08-23 15:16:15 +01:00
Adam Simpkins
b1540c8b8a Fix hgext3rd/__init__.py to make sure it is a namespace package
Summary:
According to the comments hg-crew, hgext3rd is supposed to be a namespace
package, so that extensions can be found in multiple different hgext3rd
directories.

However, the hgext3rd directory in fb-hgext has an empty __init__.py file,
which turns hgext3rd into a plain package instead of a namespace package,
preventing other hgext3rd directories from being found.

This fixes the __init__.py file to perform proper namespace package
initialization, as is done in the hg-crew/hgext3rd/__init__.py file

Test Plan:
Deployed this file on my server and confirmed that extensions in other hgext3rd
directories in $PYTHONPATH are still found correctly.

Reviewers: rmcelroy, durham, quark

Reviewed By: quark

Subscribers: net-systems-diffs@, yogeshwer, mjpieters

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

Tasks: 12792845

Signature: t1:3746098:1471679643:44a274807d3598a670e1742dee4cc2654f6bad97
2016-08-22 17:39:02 -07:00
Zach Amsden
bdc73e2393 [fastlog-hg] Remove limit on threads
Summary:
Limits make no sense anymore because we may be filtering
the results further.

Test Plan: fastlog unit test, run extension against fbsource

Reviewers: quark, durham

Reviewed By: durham

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3743974:1471906692:25f48349bd70781219acdc3cf6b98134035d6236
2016-08-22 16:23:10 -07:00
Zach Amsden
64d75b4864 [fastlog-hg] Get patterns working again
Summary:
When the restriction of only working on a single directory
was dropped, pattern support was neglected.  That has to be done through
a revset, not the looser matches() filter.

Test Plan: P56588753

Reviewers: rmcelroy, quark, stash, durham

Reviewed By: durham

Subscribers: mhammell, meisner, calcsaransh, gqchen, dzhulgakov, kerl, bnitka, mjpieters

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

Tasks: 12341014

Signature: t1:3734232:1471906628:d3995b358d683383fe590fa5848d8450a0ea05dd
2016-08-22 16:21:43 -07:00
Zach Amsden
cde79943b1 [fastlog-hg] For now, import os is still required
Summary: Accidentally removed this dependency too soon

Test Plan: Run fastlog on fbcode; broken before, now fixed

Reviewers: durham, quark, stash

Reviewed By: stash

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3743884:1471853021:ce470e4e42aa1c07aed624285a81824e04e70668
2016-08-22 14:46:39 -07:00
Zach Amsden
f115cd74e9 [fastlog-hg] Remove unused imports
Summary: No need for cruft

Test Plan: Load in Atom, no more complaints about unused imports

Reviewers: durham, rmcelroy, quark

Reviewed By: quark

Subscribers: mjpieters

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

Tasks: 12341014

Signature: t1:3733509:1471519620:08e896aaff65b545d7d16e5d46ba6a8e2a2bc186
2016-08-19 11:59:10 -07:00
Jeremy Fitzhardinge
1fd4455c73 Implement 'hg uncommit'
Summary:
TODO:
 - fix handling of empty commit (leaves stray heads)
 - add tests

Test Plan: Add mercurial unit tests

Reviewers: #mercurial, ttung, rmcelroy, durham

Reviewed By: durham

Subscribers: quark, rmcelroy, mjpieters

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

Tasks: 12340638

Signature: t1:3610409:1471398045:355f20502d917374e99feee4681a7ef6f853ad6c
2016-08-17 13:43:25 -07:00
Zach Amsden
092d645baa Fix comment for fastlog
Summary: Document how to enable the extension

Test Plan: Set this in my actual .hgrc and confirm it works.

Reviewers: durham, rmcelroy, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3721128:1471342825:e274764e036f1c03b9f8795221af6fe587990340
2016-08-16 15:55:48 -07:00
Jun Wu
fab3975b47 sshaskpass: use mkdtemp to create temporary directory
Summary:
Before this patch, sshaskpass has a hardcoded tmp directory, which, if being
abused, can break sshaskpass from working. This diff fixes the issue by
using tempfile.mkdtemp.

Test Plan:
Run `chg push -r . ssh://root@localhost//tmp/foo -f --allow-ano` and make
sure ssh password prompt works. Also run the sshaskpass test.

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3705674:1471373405:aec54ac685b060efb616307552cebcccee5cebe8
2016-08-16 19:51:47 +01:00
Zach Amsden
f1ecf43a83 Parallel callout to scmquery through conduit
Summary:
Parallel callout to scmquery through conduit
This implements the special case of log on a single directory, preserving
follow behavior.  To do this, we backtrackfrom the current head to find
 all draft revisions along the path, then find the common public ancestor of
those.  Once we find that, we can begin paging in results from the scmquery
service.

Pretty much a working diff at this point.  Limits and boundary conditions
have not been fully tested.  Every once in a while I run into a bum query,
which I suspect to be either a bad proxy or a service router failure; still
debugging that.  Could also be an issue with conduit.  Other than that,
things seem to work.

Test Plan:
Testing log with fastest setting (no revsets), revsets (using -M), and with extension disabled (--sparse):

  [zamsden@devbig192.prn1 ~/local/fbcode] time hg log tao --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 -M > a

  real	0m1.895s
  user	0m0.003s
  sys	0m0.004s
  [zamsden@devbig192.prn1 ~/local/fbcode] time hg log tao --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 > b

  real	0m1.308s
  user	0m0.005s
  sys	0m0.001s
  [zamsden@devbig192.prn1 ~/local/fbcode] diff a b
  [zamsden@devbig192.prn1 ~/local/fbcode] time hg log tao --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 --sparse > c

  real	0m7.320s
  user	0m0.004s
  sys	0m0.003s
  [zamsden@devbig192.prn1 ~/local/fbcode] diff a c




Testing --user option:



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/dragon --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 5 -u dmitri > a

  real	0m2.765s
  user	0m0.002s
  sys	0m0.004s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/dragon --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 5 -u dmitri --sparse > b

  real	0m23.247s
  user	0m0.005s
  sys	0m0.001s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource]



Testing same output enabled / disabled for -X option:



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/lithium/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 20 -X '**TARGETS' > a

  real	0m1.292s
  user	0m0.002s
  sys	0m0.003s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/lithium/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 20 -X '**TARGETS' --sparse > b

  real	0m2.697s
  user	0m0.002s
  sys	0m0.004s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource]



Testing -k option:



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/lithium/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -k 'e' -X '**TARGETS' -l 10 > a

  real	0m1.174s
  user	0m0.003s
  sys	0m0.003s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/lithium/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -k 'e' -X '**TARGETS' -l 10 --sparse > b

  real	0m1.259s
  user	0m0.004s
  sys	0m0.002s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource]



Testing -I option:



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/scm/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 20 -I '**.py' > a

  real	0m1.473s
  user	0m0.005s
  sys	0m0.003s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/scm/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 20 -I '**.py' --sparse > b

  real	0m2.911s
  user	0m0.003s
  sys	0m0.002s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource]




Testing multiple directory output in all three modes - revset, fast filtered, and forcing original fallback with --sparse



  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/hphp/hhvm fbcode/hphp/runtime/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 -M > a

  real	0m2.892s
  user	0m0.003s
  sys	0m0.006s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/hphp/hhvm fbcode/hphp/runtime/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 > b

  real	0m2.575s
  user	0m0.697s
  sys	0m0.077s
  [zamsden@devbig192.prn1 ~/local/fbsource] time hg log fbcode/hphp/hhvm fbcode/hphp/runtime/ --config extensions.fbconduit=~/local/fb-hgext/hgext3rd/fbconduit.py --config fbconduit.host=our.zamsden.devbig192.prn1.facebook.com --config extensions.fastlog=~/local/fb-hgext/hgext3rd/fastlog.py --pager=off -l 100 --sparse > c

  real	0m7.339s
  user	0m0.003s
  sys	0m0.004s
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a b
  [zamsden@devbig192.prn1 ~/local/fbsource] diff a c
  [zamsden@devbig192.prn1 ~/local/fbsource]

Reviewers: rmcelroy, #scmquery, #mercurial, ttung, lcharignon, durham, stash

Reviewed By: stash

Subscribers: cdykes, lcharignon, quark, stash, mjpieters, jeroenv

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

Tasks: 12341014

Signature: t1:3634075:1471039212:0989839636847a8e5da6a0ef9150035fcf5bb797
2016-08-12 15:52:50 -07:00
Jun Wu
5b0b861096 sshaskpass: make the prompt similar to systemd
Summary:
This diff makes the prompt similar to what systemd does. See the screenshot:

{F62774663}

It solves an issue that with echo disabled, the user won't know whether they
have pressed ENTER or not - the cursor won't move. Now it explicitly prints
"AUTHENTICATION COMPLETE".


Test Plan: As the screenshot, and also run the sshaskpass test.

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Signature: t1:3705703:1471008095:863ff9820b87ea3f4631295b10472802fb5e459f
2016-08-11 21:56:31 +01:00
Jun Wu
d4366acbd5 sshaskpass: use a standalone script
Summary:
Before this patch, sshaskpass will set SSH_ASKPASS to itself, aka. `__file__`.
This won't work if sshaskpass.py gets installed by setup.py because setup.py
will remove its `+x` bit.

Test Plan:
Run `chg push -r . ssh://root@localhost//tmp/foo -f --allow-ano` and make
sure ssh password prompt works.

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3705657:1471008122:9cfa3adf078e4bbe8f6b6ba05d1fb6be513d3e71
2016-08-11 21:42:54 +01:00
Jun Wu
6015a95c00 tweakdefaults: make "bookmarks" use the unfiltered repo
Summary:
We are seeing perf issues with hidden/obsolete handling.
`hg bookmark` is a frequently used command and by making it use the unfiltered
repo, it could be 200ms-300ms faster.

Test Plan: Added a new test

Reviewers: #mercurial, mitrandir, ikostia, ttung

Reviewed By: mitrandir, ikostia

Subscribers: mitrandir, rmcelroy, akushner, mjpieters

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

Signature: t1:3692968:1470777864:72ad5d0ffb52ecfcaaa607082693b88319d778fd
2016-08-11 18:43:06 +01:00
Jun Wu
cf9686ff3a morestatus: rebase takes precedence over update
Summary:
This happens when pressing Ctrl+C during "hg rebase". We should show
"interrupted rebase" instead of "interrupted update".

Test Plan: Added a new test

Reviewers: ttung, #mercurial, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3697984:1470863868:acd67eeb5099c73ea7df174b3e1dbcbf9ac54944
2016-08-10 22:19:30 +01:00
Oguz Ulgen
585ede8a25 Add sync status and change the conduit call to differential.querydiffhashes
Summary:
1) Add sync status
2) Combine sync status and phab status to use one unified conduit call,
i.e. differential.querydiffhashes

Test Plan:
cd hg-crew
make local
cd ../fb-hgext
make local
cd tests
../../hg-crew/tests/run-tests.py test-phabstatus.t
../../hg-crew/tests/run-tests.py test-syncstatus.t

Reviewers: wqfish, lcharignon, #sourcecontrol, wez, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

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

Tasks: 10100400

Signature: t1:3651915:1470340328:bf003006f6afe9b86a40f204e150e0d12350c21d
2016-08-05 11:33:36 -07:00
Jun Wu
4f1d1c3291 rage: filter "FM:" from blackbox.log
Summary:
Fastmanifest debug logs in blackbox.log are less interesting in a rage report,
but they take a lot of lines. This diff uses `grep` to filter them out from rage report.

Test Plan: `hg rage --preview`

Reviewers: #mercurial, ttung

Reviewed By: ttung

Subscribers: mjpieters

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

Signature: t1:3676751:1470421349:3b5e0cb4118473f5550e83bf9c5e7ac27a59bcb0
2016-08-05 19:17:45 +01:00
Jun Wu
bdb47a171c ownercheck: new extension to prevent operations on repos not owned
Summary:
This is mainly to address the same issue as D3609747: prevent issues caused
by running hg as root. The difference is this extension reads owner and uid
dynamically without config when initializing of a localrepo object.

As a side effect it covers more situations like running hg in others' repos, while
being less restrictive for some other commands like `sudo hg version`.

Test Plan: Added a new test

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: ikostia, rmcelroy, mjpieters

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

Tasks: 11723374

Signature: t1:3619997:1470176448:beaf53c09fca498206767641ffa4315a744ee07e
2016-07-26 13:10:15 +01:00
Tony Tung
c0e7082b92 [reporootlog] report the repo root to the scm wrappers
Summary:
The SCM wrappers do not have a reliable and easy way of detecting the repo root.  For instance, if someone does hg log /full/path/to/repo/content, we cannot actually determine that /full/path/to/repo is the repo root.  We have to somehow integrate an overly large portion of mercurial's commmand parsing infrastrastructure to accomplish this.

However, since mercurial knows the repo root, just extract that knowledge and send it down to the client.

Test Plan:
```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' --config 'extensions.reporootlog=work/facebook-hg-rpms/fb-hgext/hgext3rd/reporootlog.py'  work/facebook-hg-rpms/smoketest.sh
chg: enabled by /etc/mercurial/usechg

<snipped for brevity>

internal stats file: /tmp/scm-internal-stats5BoW29
hg profiling mode: LSPROFILER
stats: {
    "int": {
        "builddate": 1469712764,
        "cachehitratio": 50,
        "consumed": 302,
        "diffcachehitratio": -1,
        "elapsed": 130,
        "errorcode": 0,
        "filesnotincachehitratio": -1,
        "time": 1469819716
    },
    "normal": {
        "chg": "true",
        "command": "log",
        "evolution": "createmarkers",
        "evolutionext": "-*- empty -*-",
        "fastmanifest": "-*- empty -*-",
        "filesystem": "",
        "fsmonitor_ext": "-*- not present -*-",
        "fsmonitor_mode": "on",
        "fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers --config extensions.reporootlog=work\/facebook-hg-rpms\/fb-hgext\/hgext3rd\/reporootlog.py work\/facebook-hg-rpms\/smoketest.sh",
        "generaldelta": "false",
        "host": "dev8692.prn1",
        "iftype": "disconnected",
        "interactive": "true",
        "kernel": "4.0.9-30_fbk4_2311_gd3e5a5c",
        "metrics_type": "fastmanifest-filesnotincachehitratio",
        "msg": "",
        "parent": "\/bin\/bash",
        "remotefilelog": "false",
        "repo": "work\/facebook-hg-rpms",
        "scm": "hg",
        "sid": "",
        "source": "hg",
        "sqldirstate": "false",
        "sqldirstate_enabled": "-*- not present -*-",
        "sqldirstate_loaded": "-*- empty -*-",
        "sqldirstate_upgrade": "True",
        "sshclient": "localhost",
        "tw_job_cluster": "",
        "tw_job_name": "",
        "tw_job_user": "",
        "tw_oncall_team": "",
        "tw_task_id": "",
        "user": "ttung",
        "version": "3.8.4+443-d0746b"
    }
}
[dev8692]:~>
```

Without this change, the repo would be "unknown-repo":

```
[dev8692]:~> USE_DIST_HG= FB_HG_DIAGS= hg log --config 'sampling.key.reporootlog=perfpipe_dev_command_timers' work/facebook-hg-rpms/smoketest.sh 2>&1 | grep repo
        "fullcommand": "\/usr\/bin\/hg log --config sampling.key.reporootlog=perfpipe_dev_command_timers work\/facebook-hg-rpms\/smoketest.sh",
        "repo": "unknown-repo",
[dev8692]:~>
```

Reviewers: #mercurial, rmcelroy, quark

Reviewed By: quark

Subscribers: quark, mitrandir, mjpieters

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

Tasks: 11194713

Signature: t1:3643342:1470163958:8d56291dad575c7ea7186cf5d00420798c5303ab
2016-08-02 11:59:52 -07:00
Durham Goode
c8b5839178 statprofext: import statprof from standard python path
We temporarily changed the statprof import path when it was accidentally moved
into hgext3rd. Since we've moved it out, let's fix the import here too.
2016-08-01 12:00:18 -07:00
Jun Wu
915ce74059 sshaskpass: handle the case that __file__ ends with .pyo
Summary:
We need to get the `.py` file name from `__file__`, which could be `.pyc`
and `.pyo`. Previously only `.pyc` is handled. This diff handles `.pyo`
as well.

Test Plan: Run existing tests

Reviewers: ttung, mjpieters, #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, mjpieters

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

Signature: t1:3627929:1469625182:1c0f5f720fe7eb4cbe3e6abd8e9407ced617d2a0
2016-07-27 14:05:16 +01:00
Jun Wu
34c0e30789 sshaskpass: enable ssh to ask password if running with chg
Summary:
During chg pull or push over ssh, ssh is started by chgserver which does not
have a controlling tty. Therefore the ssh process won't be able to ask for
passwords interactively.

This is actually a hard issue because an unprivileged process without a ctty
cannot attach to a ctty of another process.

The discussion at upstream tends to make it clear it's part of limitations
of chg. Therefore if we decide to workaround it, it has to live outside core,
thus fb-hgext.

GUI ssh-askpass is actually a good and clean choice. See D3510178 and D3515604.
However, they are for OS X but not Linux.

This diff is a very hacky solution to make ssh-askpass works in terminal.
It starts a "tty server" providing tty I/O fds and set `SSH_ASKPASS` to use a
custom script talking to the "tty server".

Test Plan:
Run the new test. Start a sshd locally and try:
```
$ hg push ssh://root@localhost/tmp
pushing to ssh://root@localhost/tmp
root@localhost's password:
remote: Permission denied (publickey,password).
abort: no suitable response from remote hg!

$ chg push ssh://root@localhost/tmp
pushing to ssh://root@localhost/tmp
==== SSH Authenticating ====
root@localhost's password:
remote: Permission denied (publickey,password).
abort: no suitable response from remote hg!
```

Reviewers: #mercurial, ttung, mpm

Reviewed By: mpm

Subscribers: durham, mpm, mjpieters

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

Tasks: 12029680

Signature: t1:3577509:1469467700:cd93565bd47e535bb4cb41fcdaa39e45dddfae28
2016-07-17 20:35:34 +01:00
Martijn Pieters
481b9898e0 Remove the journal extension, fully upstreamed
Summary:
All of hg journal is now fully upstreamed to mercurial core and remotenames.
Remove the outdated copy here.

Test Plan: --

Reviewers: #mercurial, ttung

Subscribers: mjpieters

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

Tasks: 10804988
2016-07-24 00:01:33 +01:00
Durham Goode
b3a9a1ebef statprof: move statprof out of hgext3rd
Summary:
Since statprof is not an extension, it needs to be treated like a normal python
module.

Test Plan:
```
~/local/fb-hgext> python setup.py build
~/local/fb-hgext> ls build/lib.linux-x86_64-2.6/
cfastmanifest.so  hgext3rd/         sqldirstate/
fastmanifest/     phabricator/      statprof.py
```

Reviewers: ttung, #sourcecontrol, quark

Reviewed By: quark

Subscribers: mjpieters

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

Signature: t1:3607202:1469216683:9aa08aee567425c239ddc5d1bb68fd892a8cf6a9
2016-07-22 12:44:59 -07:00
Mateusz Kwapich
1d2abfa980 statprof: change the hotpath to be less biased towards IO
Summary:
Let's use deltas between the subsequent samples instead of sample count
to count the time spent.

Rationale:
When the process is IO blocked the other thread doing the sampling can be waken
up much more often (GIL is not held) causing the profiler to collect much more
samples in that state.

Test Plan:
works in my sandbox
do we have any tests for statprof.py?

Reviewers: durham

Reviewed By: durham

Subscribers: quark, mjpieters, #mercurial

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

Signature: t1:3551431:1468543377:f6b86245c957dd59d0334dbb1898f6ad0bb8c617
2016-07-20 13:41:35 -07:00
Jun Wu
b0380393f2 phrevset: do not depend on hgsubversion
Summary:
`import hgsubversion` can error out if demandimport is disabled and svn
bindings are not found. In that case, we should be able to continue and
just skip handling svn revisions.

Test Plan: Code review

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

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

Signature: t1:3594810:1469042572:3f9ab69f5503f6925f455769a78dac42a47087de
2016-07-20 20:09:29 +01:00
Jun Wu
8a3a99ba21 hgext: move single file extensions to hgext3rd
Summary:
Be a better citizen under system python path.

Fix all tests issues and change setup.py to use glob pattern to include
all extensions.

Test Plan:
Run tests and `make local`.
Also build and install the package and run `hg sl` in major repos.

Reviewers: #mercurial, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, durham, mjpieters

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

Signature: t1:3534311:1468275426:fe122646c8bd6c541e1889e73e9df28f86747ff2
2016-07-08 13:15:42 +01:00