tests/test-rebase-transaction.t
author Martin von Zweigbergk <martinvonz@google.com>
Fri, 10 Jan 2020 14:22:20 -0800
changeset 44347 9c9cfecd4600
parent 42613 35ebdbb38efb
child 45150 dc5e5577af39
permissions -rw-r--r--
rebase: don't use rebased node as dirstate p2 (BC) When rebasing a node, we currently use the rebased node as p2 in the dirstate until just before we commit it (we then change to the desired parents). This p2 is visible to the user when the rebase gets interrupted because of merge conflicts. That can be useful to the user as a reminder of which commit is currently being rebased, but I believe it's incorrect for a few reasons: * I think the dirstate parents should be the ones that will be set when the commit is created. * I think having two parents means that you're merging those two commits, but when rebasing, you're generally grafting, not merging. * When rebasing a merge commit, we should use the two desired parents as dirstate parents (and we clearly can't have the rebased node as a third dirstate parent). * `hg graft` (and `hg update --merge`) sets only one parent and `hg rebase` should be consistent with that. I realize that this is a somewhat large user-visible change, but I think it's worth it because it will simplify things quite a bit. Differential Revision: https://phab.mercurial-scm.org/D7827

#testcases continuecommand continueflag
Rebasing using a single transaction

  $ cat >> $HGRCPATH <<EOF
  > [extensions]
  > rebase=
  > drawdag=$TESTDIR/drawdag.py
  > 
  > [rebase]
  > singletransaction=True
  > 
  > [phases]
  > publish=False
  > 
  > [alias]
  > tglog = log -G --template "{rev}: {desc}"
  > EOF

#if continueflag
  $ cat >> $HGRCPATH <<EOF
  > [alias]
  > continue = rebase --continue
  > EOF
#endif

Check that a simple rebase works

  $ hg init simple && cd simple
  $ hg debugdrawdag <<'EOF'
  >   Z
  >   |
  >   | D
  >   | |
  >   | C
  >   | |
  >   Y B
  >   |/
  >   A
  > EOF
- We should only see one status stored message. It comes from the start.
  $ hg rebase --debug -b D -d Z | grep 'status stored'
  rebase status stored
  $ hg tglog
  o  5: D
  |
  o  4: C
  |
  o  3: B
  |
  o  2: Z
  |
  o  1: Y
  |
  o  0: A
  
  $ cd ..

Check that --collapse works

  $ hg init collapse && cd collapse
  $ hg debugdrawdag <<'EOF'
  >   Z
  >   |
  >   | D
  >   | |
  >   | C
  >   | |
  >   Y B
  >   |/
  >   A
  > EOF
- We should only see two status stored messages. One from the start, one from
- cmdutil.commitforceeditor() which forces tr.writepending()
  $ hg rebase --collapse --debug -b D -d Z | grep 'status stored'
  rebase status stored
  rebase status stored
  $ hg tglog
  o  3: Collapsed revision
  |  * B
  |  * C
  |  * D
  o  2: Z
  |
  o  1: Y
  |
  o  0: A
  
  $ cd ..

With --collapse, check that conflicts can be resolved and rebase can then be
continued

  $ hg init collapse-conflict && cd collapse-conflict
  $ hg debugdrawdag <<'EOF'
  >   Z   # Z/conflict=Z
  >   |
  >   | D
  >   | |
  >   | C # C/conflict=C
  >   | |
  >   Y B
  >   |/
  >   A
  > EOF
  $ hg rebase --collapse -b D -d Z
  rebasing 1:112478962961 "B" (B)
  rebasing 3:c26739dbe603 "C" (C)
  merging conflict
  warning: conflicts while merging conflict! (edit, then use 'hg resolve --mark')
  unresolved conflicts (see hg resolve, then hg rebase --continue)
  [1]
  $ hg tglog
  o  5: D
  |
  | @  4: Z
  | |
  % |  3: C
  | |
  | o  2: Y
  | |
  o |  1: B
  |/
  o  0: A
  
  $ hg st
  M conflict
  A B
  A C
  ? conflict.orig
  $ echo resolved > conflict
  $ hg resolve -m
  (no more unresolved files)
  continue: hg rebase --continue
  $ hg continue
  already rebased 1:112478962961 "B" (B) as 79bc8f4973ce
  rebasing 3:c26739dbe603 "C" (C)
  rebasing 5:d24bb333861c "D" (D tip)
  saved backup bundle to $TESTTMP/collapse-conflict/.hg/strip-backup/112478962961-b5b34645-rebase.hg
  $ hg tglog
  o  3: Collapsed revision
  |  * B
  |  * C
  |  * D
  o  2: Z
  |
  o  1: Y
  |
  o  0: A
  
  $ cd ..

With --collapse, check that the commit message editing can be canceled and
rebase can then be continued

  $ hg init collapse-cancel-editor && cd collapse-cancel-editor
  $ hg debugdrawdag <<'EOF'
  >   Z
  >   |
  >   | D
  >   | |
  >   | C
  >   | |
  >   Y B
  >   |/
  >   A
  > EOF
  $ HGEDITOR=false hg --config ui.interactive=1 rebase --collapse -b D -d Z
  rebasing 1:112478962961 "B" (B)
  rebasing 3:26805aba1e60 "C" (C)
  rebasing 5:f585351a92f8 "D" (D tip)
  transaction abort!
  rollback completed
  abort: edit failed: false exited with status 1
  [255]
  $ hg tglog
  o  5: D
  |
  | o  4: Z
  | |
  o |  3: C
  | |
  | o  2: Y
  | |
  o |  1: B
  |/
  o  0: A
  
  $ hg continue
  rebasing 1:112478962961 "B" (B)
  rebasing 3:26805aba1e60 "C" (C)
  rebasing 5:f585351a92f8 "D" (D tip)
  saved backup bundle to $TESTTMP/collapse-cancel-editor/.hg/strip-backup/112478962961-cb2a9b47-rebase.hg
  $ hg tglog
  o  3: Collapsed revision
  |  * B
  |  * C
  |  * D
  o  2: Z
  |
  o  1: Y
  |
  o  0: A
  
  $ cd ..