mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
cb90ed6abe
Summary: After testing locally, I couldn't conclusively prove if rebasing a single change with IMM was any faster or slower than on disk. Using IMM on the working copy will definitely be better for rebasing stacks, and it's just nicer to not have the working copy thrash around as much. It also might be interesting to (possibly) let you work while the rebase is running, too.* So I've added the code that will let us enable this more widely (as a subset of IMM) to experiment. *I've made it so that if you make any changes during the rebase (causing the last update to fail), we just print a nice message telling you to checkout the new rebased working copy commit, instead of failing/aborting. TBD whether this is something we want to encourage people to do, however. I've kept the existing up-front check for uncommited changes when rebasing the WCP with IMM for now. Reviewed By: DurhamG Differential Revision: D7051282 fbshipit-source-id: c04302539021f481c17e47c23d3f4d8b3ed59db6
323 lines
6.9 KiB
Perl
323 lines
6.9 KiB
Perl
#require symlink execbit
|
|
$ cat << EOF >> $HGRCPATH
|
|
> [extensions]
|
|
> amend=
|
|
> purge=
|
|
> rebase=
|
|
> [rebase]
|
|
> experimental.inmemory=1
|
|
> [diff]
|
|
> git=1
|
|
> [alias]
|
|
> tglog = log -G --template "{rev}: {node|short} '{desc}'\n"
|
|
> EOF
|
|
|
|
Rebase a simple DAG:
|
|
$ hg init repo1
|
|
$ cd repo1
|
|
$ hg debugdrawdag <<'EOS'
|
|
> c b
|
|
> |/
|
|
> d
|
|
> |
|
|
> a
|
|
> EOS
|
|
$ hg up -C a
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
$ hg tglog
|
|
o 3: 814f6bd05178 'c'
|
|
|
|
|
| o 2: db0e82a16a62 'b'
|
|
|/
|
|
o 1: 02952614a83d 'd'
|
|
|
|
|
@ 0: b173517d0057 'a'
|
|
|
|
$ hg cat -r 3 c
|
|
c (no-eol)
|
|
$ hg cat -r 2 b
|
|
b (no-eol)
|
|
$ hg rebase --debug -r b -d c | grep rebasing
|
|
rebasing in-memory
|
|
rebasing 2:db0e82a16a62 "b" (b)
|
|
$ hg tglog
|
|
o 3: ca58782ad1e4 'b'
|
|
|
|
|
o 2: 814f6bd05178 'c'
|
|
|
|
|
o 1: 02952614a83d 'd'
|
|
|
|
|
@ 0: b173517d0057 'a'
|
|
|
|
$ hg cat -r 3 b
|
|
b (no-eol)
|
|
$ hg cat -r 2 c
|
|
c (no-eol)
|
|
|
|
Case 2:
|
|
$ hg init repo2
|
|
$ cd repo2
|
|
$ hg debugdrawdag <<'EOS'
|
|
> c b
|
|
> |/
|
|
> d
|
|
> |
|
|
> a
|
|
> EOS
|
|
|
|
Add a symlink and executable file:
|
|
$ hg up -C c
|
|
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
$ ln -s somefile e
|
|
$ echo f > f
|
|
$ chmod +x f
|
|
$ hg add e f
|
|
$ hg amend -q
|
|
$ hg up -Cq a
|
|
|
|
Write files to the working copy, and ensure they're still there after the rebase
|
|
$ echo "abc" > a
|
|
$ ln -s def b
|
|
$ echo "ghi" > c
|
|
$ echo "jkl" > d
|
|
$ echo "mno" > e
|
|
$ hg tglog
|
|
o 3: f56b71190a8f 'c'
|
|
|
|
|
| o 2: db0e82a16a62 'b'
|
|
|/
|
|
o 1: 02952614a83d 'd'
|
|
|
|
|
@ 0: b173517d0057 'a'
|
|
|
|
$ hg cat -r 3 c
|
|
c (no-eol)
|
|
$ hg cat -r 2 b
|
|
b (no-eol)
|
|
$ hg cat -r 3 e
|
|
somefile (no-eol)
|
|
$ hg rebase --debug -s b -d a | grep rebasing
|
|
rebasing in-memory
|
|
rebasing 2:db0e82a16a62 "b" (b)
|
|
$ hg tglog
|
|
o 3: fc055c3b4d33 'b'
|
|
|
|
|
| o 2: f56b71190a8f 'c'
|
|
| |
|
|
| o 1: 02952614a83d 'd'
|
|
|/
|
|
@ 0: b173517d0057 'a'
|
|
|
|
$ hg cat -r 2 c
|
|
c (no-eol)
|
|
$ hg cat -r 3 b
|
|
b (no-eol)
|
|
$ hg rebase --debug -s 1 -d 3 | grep rebasing
|
|
rebasing in-memory
|
|
rebasing 1:02952614a83d "d" (d)
|
|
rebasing 2:f56b71190a8f "c"
|
|
$ hg tglog
|
|
o 3: 753feb6fd12a 'c'
|
|
|
|
|
o 2: 09c044d2cb43 'd'
|
|
|
|
|
o 1: fc055c3b4d33 'b'
|
|
|
|
|
@ 0: b173517d0057 'a'
|
|
|
|
Ensure working copy files are still there:
|
|
$ cat a
|
|
abc
|
|
$ readlink.py b
|
|
b -> def
|
|
$ cat e
|
|
mno
|
|
|
|
Ensure symlink and executable files were rebased properly:
|
|
$ hg up -Cq 3
|
|
$ readlink.py e
|
|
e -> somefile
|
|
$ ls -l f | cut -c -10
|
|
-rwxr-xr-x
|
|
$ cd ..
|
|
|
|
Make a change that only changes the flags of a file and ensure it rebases
|
|
cleanly.
|
|
$ hg clone repo2 repo3
|
|
updating to branch default
|
|
6 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
$ cd repo3
|
|
$ hg tglog
|
|
@ 3: 753feb6fd12a 'c'
|
|
|
|
|
o 2: 09c044d2cb43 'd'
|
|
|
|
|
o 1: fc055c3b4d33 'b'
|
|
|
|
|
o 0: b173517d0057 'a'
|
|
|
|
$ chmod +x a
|
|
$ hg commit -m "change a's flags"
|
|
$ hg up 0
|
|
1 files updated, 0 files merged, 5 files removed, 0 files unresolved
|
|
$ hg rebase -r 4 -d .
|
|
rebasing 4:0666f6a71f74 "change a's flags" (tip)
|
|
saved backup bundle to $TESTTMP/repo1/repo3/.hg/strip-backup/0666f6a71f74-a2618702-rebase.hg
|
|
$ hg up -q tip
|
|
$ ls -l a | cut -c -10
|
|
-rwxr-xr-x
|
|
$ cd ..
|
|
|
|
Rebase the working copy parent, which should default to an on-disk merge even if
|
|
we requested in-memory.
|
|
$ cd repo2
|
|
$ hg up -C 3
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
$ hg rebase -r 3 -d 0 --debug | egrep 'rebasing|disabling'
|
|
disabling IMM because: wcp in rebaseset
|
|
rebasing on disk
|
|
rebasing 3:753feb6fd12a "c" (tip)
|
|
$ hg tglog
|
|
@ 3: 844a7de3e617 'c'
|
|
|
|
|
| o 2: 09c044d2cb43 'd'
|
|
| |
|
|
| o 1: fc055c3b4d33 'b'
|
|
|/
|
|
o 0: b173517d0057 'a'
|
|
|
|
Rerun with merge conflicts:
|
|
$ hg up 2
|
|
2 files updated, 0 files merged, 3 files removed, 0 files unresolved
|
|
$ echo 'e' > c
|
|
$ hg add
|
|
adding c
|
|
$ hg com -m 'e -> c'
|
|
$ hg up 1
|
|
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
|
|
$ hg tglog
|
|
o 4: 6af061510c70 'e -> c'
|
|
|
|
|
| o 3: 844a7de3e617 'c'
|
|
| |
|
|
o | 2: 09c044d2cb43 'd'
|
|
| |
|
|
@ | 1: fc055c3b4d33 'b'
|
|
|/
|
|
o 0: b173517d0057 'a'
|
|
|
|
$ hg rebase -r 3 -d 4
|
|
rebasing 3:844a7de3e617 "c"
|
|
merging c
|
|
hit merge conflicts; re-running rebase without in-memory merge (in-memory merge does not support merge conflicts)
|
|
rebase aborted
|
|
rebasing 3:844a7de3e617 "c"
|
|
merging c
|
|
warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
|
|
unresolved conflicts (see hg resolve, then hg rebase --continue)
|
|
[1]
|
|
|
|
Also ensure the last test works if rebasing the WCP (turning off IMM mid-call):
|
|
$ hg rebase --abort
|
|
rebase aborted
|
|
$ hg up -C 3
|
|
3 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
|
$ hg rebase -r 3 -d 4
|
|
rebasing 3:844a7de3e617 "c"
|
|
merging c
|
|
warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
|
|
unresolved conflicts (see hg resolve, then hg rebase --continue)
|
|
[1]
|
|
$ hg rebase --abort
|
|
rebase aborted
|
|
|
|
Test inmemorydisallowedpaths carve-out:
|
|
$ cat <<EOF >> $HGRCPATH
|
|
> [rebase]
|
|
> experimental.inmemorydisallowedpaths=c|g
|
|
> EOF
|
|
$ hg up 3
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
$ echo 'g' > g
|
|
$ hg add -q g
|
|
$ hg com -qm g
|
|
$ hg up -qC 4
|
|
$ echo 'h' > h
|
|
$ hg add -q h
|
|
$ hg com -qm h
|
|
$ hg up 0
|
|
0 files updated, 0 files merged, 4 files removed, 0 files unresolved
|
|
$ hg tglog
|
|
o 6: 02554e3f8526 'h'
|
|
|
|
|
| o 5: e8cedfb0cf72 'g'
|
|
| |
|
|
o | 4: 6af061510c70 'e -> c'
|
|
| |
|
|
| o 3: 844a7de3e617 'c'
|
|
| |
|
|
o | 2: 09c044d2cb43 'd'
|
|
| |
|
|
o | 1: fc055c3b4d33 'b'
|
|
|/
|
|
@ 0: b173517d0057 'a'
|
|
|
|
$ hg rebase -r 5 -d 0 --debug | grep disabling
|
|
disabling IMM because: path matched inmemory_disallowed_paths: g
|
|
$ hg rebase -s 3 -d 0 --debug | grep disabling
|
|
disabling IMM because: path matched inmemory_disallowed_paths: c
|
|
$ hg tglog
|
|
o 6: f3a876323b82 'g'
|
|
|
|
|
| o 5: 02554e3f8526 'h'
|
|
| |
|
|
| o 4: 6af061510c70 'e -> c'
|
|
| |
|
|
+---o 3: 844a7de3e617 'c'
|
|
| |
|
|
| o 2: 09c044d2cb43 'd'
|
|
| |
|
|
| o 1: fc055c3b4d33 'b'
|
|
|/
|
|
@ 0: b173517d0057 'a'
|
|
|
|
$ hg rebase -r 5 -d 0 --debug | grep disabling
|
|
[1]
|
|
|
|
Allow the working copy parent to be rebased with IMM, if configured:
|
|
$ cat <<EOF >> .hg/hgrc
|
|
> [rebase]
|
|
> experimental.inmemory.canrebaseworkingcopy=True
|
|
> experimental.inmemorywarning=rebasing in-memory!
|
|
> EOF
|
|
$ hg up -C 6
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
$ hg rebase -r . -d 5
|
|
rebasing in-memory!
|
|
rebasing 6:f19e4c5309bc "h" (tip)
|
|
saved backup bundle to $TESTTMP/repo1/repo2/.hg/strip-backup/f19e4c5309bc-e3db5525-rebase.hg
|
|
$ hg tglog
|
|
@ 6: 0b514f19a9ab 'h'
|
|
|
|
|
o 5: f3a876323b82 'g'
|
|
|
|
|
| o 4: 6af061510c70 'e -> c'
|
|
| |
|
|
+---o 3: 844a7de3e617 'c'
|
|
| |
|
|
| o 2: 09c044d2cb43 'd'
|
|
| |
|
|
| o 1: fc055c3b4d33 'b'
|
|
|/
|
|
o 0: b173517d0057 'a'
|
|
|
|
|
|
Ensure if we rebase the WCP, we still require the working copy to be clean up
|
|
front:
|
|
$ echo 'd' > i
|
|
$ hg add i
|
|
$ hg rebase -r . -d 0
|
|
abort: uncommitted changes
|
|
[255]
|
|
$ hg up -Cq .
|