Commit Graph

113 Commits

Author SHA1 Message Date
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