Commit Graph

17 Commits

Author SHA1 Message Date
Jun Wu
4d005373fc test-restack: add a case demonstrating restack rebase a single commit twice
The test shows that restack moves "D" twice while it could have moved it
only once. It is a side effect when I spent 1.5 hours on investigating a
user report that a commit was duplicated with `amend --rebase` somehow. I
didn't have conclusion about that report (maybe it's because old inhibit was
used?), but thought it's nice to have this interesting test case added.

If `hg rebase -r C -d B2 -q` were moved after `hg commit --amend -m B3`,
then restack will move "D" only once.

It can be solved by using another topo sort, which was planned in the
multi-dest series [1].

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-June/100247.html

Differential Revision: https://phab.mercurial-scm.org/D163
2017-07-20 22:23:14 -07:00
Jun Wu
0b38d6d44e hiddenoverride: unhide permanently by bookmark and working parent
We want these behaviors:

  - Checking out an obsoleted revision makes it visible even if another
    revision was checked out later
  - Putting a bookmark on an obsoleted revision makes it visible even if the
    bookmark was removed later
  - Strip/prune could make them hidden again

This is basically a lightweight version of independent hidden.

Differential Revision: https://phab.mercurial-scm.org/D70
2017-07-13 11:04:56 -07:00
Jun Wu
99386e40fd inhibit: update existing code to work with the rewritten version
Summary:
debuginhibit was removed since we no longer have a separate inhibit state.

smartlog hack about changing "o" to "x" was removed since "obsolete()"
revset is correct and the hack is unnecessary now.

directaccess was removed from tests since inhibit does not depend on it.

`- obsolete()` was added to some revsets to avoid divergence and other
surprises.

Use `inhibit.revive` API in infinitepush and reset to revive changesets
properly.

Remove various hacky code that mangle inhibit state in corner cases.

Most test changes are `o` changed to `x` in output since we draw
`obsolete()` state correctly now. `test-infinitepush-backup-remotefilelog.t`
change was because output could be `bytes/sec` instead of `KB/sec`.

Test Plan: arc unit

Reviewers: #mercurial, kulshrax

Reviewed By: kulshrax

Subscribers: kulshrax, medson, mjpieters

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

Signature: t1:5391361:1499722618:d3c1cf629f0c59ecdf1dfd5e653c1eb6176646b8
2017-07-10 15:45:31 -07:00
Therin Irwin
66b64d8fb6 fbamend: change hint text to suggest running restack
Summary: Instead of referencing `hg rebase` --restack option, just reference the `restack` subcommand.

Test Plan:
1. Make a few commits 1, 2, 3, 4 on any branch
2. `hg update 1`
3. Try to amend commit 1
4. Warning message should appear about children left behind
expected: Hint text does not mention `hg rebase --restack`

Reviewers: durham, kulshrax

Reviewed By: kulshrax

Subscribers: medson, mjpieters, kkrewink

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

Tasks: 19601780

Signature: t1:5313108:1498249314:98f31f4424341ef51997687293bf99b7297b6cd0
2017-06-26 07:31:28 -07:00
Jun Wu
4a936cee21 codemod: remove extpath in tests
Summary:
Previously, the following pattern is common in our tests:

```
   $ extpath=`dirname $TESTDIR`
   $ cp $extpath/hgext3rd/name.py $TESTTMP # use $TESTTMP substitution in message
   $ cat >> $HGRCPATH<<EOF
   > [extensions]
   > name=$TESTTMP/name.py
   > EOF
```

Now, it gets simplified to:

```
   $ cat >> $HGRCPATH<<EOF
   > [extensions]
   > name=$TESTDIR/../hgext3rd/name.py
   > EOF
```

This removes unnecessary `dirname` and `cp`.

Also fixed a regex that does not match `bytes`:

```
-  transferred 268 bytes in [\d.]+ seconds \([\d.]+ KB/sec\) (re)
+  transferred 268 bytes in 0.3 seconds (939 bytes/sec)
```

Test Plan: arc unit

Reviewers: #mercurial, phillco

Reviewed By: phillco

Subscribers: medson, mjpieters

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

Signature: t1:5270897:1497663052:bf860a0b480c751b1e4b53cebf6526193f0f6652
2017-06-16 18:31:25 -07:00
Jun Wu
be7ac42b50 codemod: replace evolve by fbamend
Summary:
Now that fbamend has most of the features we want. Replace evolve
used by tests.

Minor changes are made to some extensions to make test pass:
- reset: drop commit reviving support (was provided by "hg touch")
- smartlog: do not assume who provides "allsuccessors" revset
- fbamend: return 1 on "nothing changed"
- fbamend: write operation data for split and fold
- fbamend: do not print incompatibility notice
- fbamend: do not disable itself when rebase is not enabled
- inhibit: remove `bookmark -D` option - use `prune -B` instead

Test Plan: arc unit

Reviewers: #mercurial, stash

Reviewed By: stash

Subscribers: stash, mjpieters, medson

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

Signature: t1:5258813:1497604051:0c7334f9a6554cf31aaaaa2a4995b17d4e445847
2017-06-16 15:50:01 -07:00
Jun Wu
f1b6191c18 fbamend: move to a package
Summary: `fbamend.py` is already long. It will become more complex so let's move it.

Test Plan: arc unit

Reviewers: #mercurial, ikostia

Reviewed By: ikostia

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

Signature: t1:5209475:1497260957:e84aec4a2f90c8dd1d247b2b0caef48cfbb59c55
2017-06-13 17:08:20 -07:00
Jun Wu
01a471b159 codemod: use vendored directaccess and inhibit extension in tests
Summary:
This diff makes the tests use the vendored directaccess and inhibit instead the
foreign ones.

Test Plan: arc unit

Reviewers: #mercurial, sid0

Reviewed By: sid0

Subscribers: mjpieters

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

Signature: t1:5142981:1496173851:3a8f3a1c689711dbef517c893bf72c90ab144761
2017-05-30 12:56:40 -07:00
Arun Kulshreshtha
f84233c8dc fbamend: minor cosmetic changes to test-fbamend-restack.t
Summary: Minor stylistic cleanup for this test.

Test Plan: Test still passes.

Reviewers: #sourcecontrol, mitrandir

Reviewed By: mitrandir

Subscribers: mjpieters

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

Signature: t1:4486391:1485876954:0d800a4ba3858b23560d7ae9d3ba5a9981e9eb6a
2017-01-31 12:48: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
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
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
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
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
cdfe81c7d3 fbamend: change test for restack to use globs for rev numbers
Summary: One of the new features I'm adding to `hg previous` and `hg next` is replacing the rev numbers with commit hashes, since these are more familiar and intuitive to users. As a first step, update this test to glob out the rev numbers.

Test Plan: Test still passes.

Reviewers: durham, quark, #sourcecontrol, stash

Reviewed By: stash

Subscribers: mjpieters

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

Tasks: 14119420

Signature: t1:4121748:1478162085:c7bc64f133dcfd7af67f349a10c0e0a587a8aa19
2016-11-03 11:11:37 -07: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
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