tests/test-evolve-list.t
author Pulkit Goyal <7895pulkit@gmail.com>
Sun, 18 Mar 2018 23:48:06 +0530
changeset 3660 f018656ca3bf
parent 3373 3ff0da45d4c7
child 3418 85cdce113c2c
child 4363 a2fdbece7ce1
child 4471 3caa4a459439
permissions -rw-r--r--
amend: add a new flag `--patch` to `hg amend` This patch adds a new flag `--patch` to `hg amend` which pops up an editor with the patch of working directory parent which you can change, and when you exit the editor the patch with changes is applied to current working directory with old changeset being obsoleted in favour of new one created by the applied patch. If supplied filenames, only those filenames are present in the popped editor and rest files stay the same way in the commit as they were. The extension of the file which opens up in editor is '.diff', we cannot have it as '.patch' as there will be develwarns related to that. We need to change to patch core and undo some change to achieve this. The implementation does not use any core API rather it has picked chunks from API which are required. One main reason to not use core import API is that we have to change wdir parent before using patch.patch() which I will like to avoid to make sure we handle merge cases too. While writing this patch I have spend lot of time try to use internal API's to work for this but none of them served the purpose well. If I have time in future and work on similar problem again, I am going to write better high-level API's which uses patchstore to achieve this. A new test file test-amend-patch.t which contains a lot of testing of the feature.

Set up some configs
  $ cat >> $HGRCPATH <<EOF
  > [extensions]
  > rebase=
  > EOF
  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH

Test the instability listing
  $ hg init r2
  $ cd r2
  $ echo a > a && hg ci -Am a
  adding a
  $ echo b > b && hg ci -Am b
  adding b
  $ echo c > c && hg ci -Am c
  adding c
  $ hg up 0
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ echo a >> a && hg ci --amend -m a
  2 new orphan changesets
  $ hg evolve --list
  d2ae7f538514: b
    orphan: cb9a9f314b8b (obsolete parent)
  
  177f92b77385: c
    orphan: d2ae7f538514 (orphan parent)
  
  $ cd ..

Test the bumpedness listing
  $ hg init r3
  $ cd r3
  $ echo a > a && hg ci -Am a
  adding a
  $ echo b > b && hg ci --amend -m ab
  $ hg phase --public --rev 0 --hidden
  1 new phase-divergent changesets
  $ hg evolve --list
  88cc282e27fc: ab
    phase-divergent: cb9a9f314b8b (immutable precursor)
  
  $ cd ..

Test the divergence listing
  $ hg init r1
  $ cd r1
  $ echo a > a && hg ci -Am a
  adding a
  $ hg up 0
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo b > b && hg ci -Am b
  adding b
  $ hg up 0
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ echo c > c && hg ci -Am c
  adding c
  created new head
  $ hg up 0
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ echo d > d && hg ci -Am d
  adding d
  created new head
  $ hg rebase -s 1 -d 2
  rebasing 1:d2ae7f538514 "b"
  $ hg rebase -s 1 -d 3 --hidden --config experimental.allowdivergence=True
  rebasing 1:d2ae7f538514 "b"
  2 new content-divergent changesets
  $ hg evolve --list
  c882616e9d84: b
    content-divergent: a922b3733e98 (draft) (precursor d2ae7f538514)
  
  a922b3733e98: b
    content-divergent: c882616e9d84 (draft) (precursor d2ae7f538514)
  
  $ hg evolve --list --rev c882616e9d84
  c882616e9d84: b
    content-divergent: a922b3733e98 (draft) (precursor d2ae7f538514)
  
  $ hg phase -p a922b3733e98
  $ hg evolve --list
  c882616e9d84: b
    content-divergent: a922b3733e98 (public) (precursor d2ae7f538514)
  
  $ cd ..