D818: tests: add tests for histedit copy and move

mbthomas (Mark Thomas) phabricator at mercurial-scm.org
Tue Sep 26 06:14:35 EDT 2017


mbthomas created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D818

AFFECTED FILES
  tests/test-histedit-copymove-obs.t
  tests/test-histedit-copymove.t

CHANGE DETAILS

diff --git a/tests/test-histedit-copymove.t b/tests/test-histedit-copymove.t
new file mode 100644
--- /dev/null
+++ b/tests/test-histedit-copymove.t
@@ -0,0 +1,255 @@
+  $ . "$TESTDIR/histedit-helpers.sh"
+
+  $ cat >> $HGRCPATH <<EOF
+  > [alias]
+  > tglog = log -G --template "{rev}:{node}:{phase} '{desc}'\n"
+  > [extensions]
+  > histedit=
+  > EOF
+
+Create repo with an additional commit not in the linear history
+
+  $ hg init repo
+  $ cd repo
+  $ echo base > base
+  $ hg add base
+  $ hg commit -m "base"
+  $ echo other1 > other1
+  $ hg add other1
+  $ hg commit -m "other 1"
+  $ hg up -q 0
+  $ for x in a b c ; do
+  >   echo $x > $x
+  >   hg add $x
+  >   hg commit -m $x
+  > done
+  created new head
+  $ hg tglog
+  @  4:f9d2e574dc5853aac398917ed798d8640e8203af:draft 'c'
+  |
+  o  3:c87fe1ae405ff0a6dcc1ce27064cb9d303a05734:draft 'b'
+  |
+  o  2:c604726e05fb3a349978173b3ab4a3ee6e43cd6c:draft 'a'
+  |
+  | o  1:1bd41d4d54b3433c51c6074309626007aa50c41b:draft 'other 1'
+  |/
+  o  0:d20a80d4def38df63a4b330b7fb688f3d4cae1e3:draft 'base'
+  
+Use histedit to copy the extra commit into the linear history
+
+  $ hg histedit 2 --commands - 2>&1 << EOF | fixbundle
+  > pick c604726e05fb
+  > pick c87fe1ae405f
+  > copy 1bd41d4d54b3
+  > pick f9d2e574dc58
+  > EOF
+
+  $ hg tglog
+  @  5:48cb5c108f6a0ba49cf4c19f51e95a07a31aeee5:draft 'c'
+  |
+  o  4:08093bb58cfe15f581872229983b45aef50ce2eb:draft 'other 1'
+  |
+  o  3:c87fe1ae405ff0a6dcc1ce27064cb9d303a05734:draft 'b'
+  |
+  o  2:c604726e05fb3a349978173b3ab4a3ee6e43cd6c:draft 'a'
+  |
+  | o  1:1bd41d4d54b3433c51c6074309626007aa50c41b:draft 'other 1'
+  |/
+  o  0:d20a80d4def38df63a4b330b7fb688f3d4cae1e3:draft 'base'
+  
+Use histedit to move the extra commit into the linear history
+
+  $ hg histedit 2 --command  - 2>&1 << EOF | fixbundle
+  > pick c604726e05fb
+  > move 1bd41d4d54b3
+  > pick c87fe1ae405f
+  > drop 08093bb58cfe
+  > pick 48cb5c108f6a
+  > EOF
+
+  $ hg tglog
+  @  4:f647aec54d8c9b7688f475eb90127eb6bda0bc22:draft 'c'
+  |
+  o  3:bc3bbfd1a1e54a2b37fdd1d09cd138ea8641c5c8:draft 'b'
+  |
+  o  2:674f74e24e11522e03d59ea2593d93a77b715b3f:draft 'other 1'
+  |
+  o  1:c604726e05fb3a349978173b3ab4a3ee6e43cd6c:draft 'a'
+  |
+  o  0:d20a80d4def38df63a4b330b7fb688f3d4cae1e3:draft 'base'
+  
+Try to use histedit to copy a non-existent commit
+
+  $ hg histedit 3 --command - 2>&1 << EOF | fixbundle
+  > pick bc3bbfd1a1e5
+  > copy 123456789abc
+  > pick f647aec54d8c
+  > EOF
+  hg: parse error: unknown changeset 123456789abc listed
+
+Try to use histedit to move a commit in the pick set
+
+  $ hg histedit 3 --command - 2>&1 << EOF | fixbundle
+  > pick bc3bbfd1a1e5
+  > pick f647aec54d8c
+  > move bc3bbfd1a1e5
+  > EOF
+  hg: parse error: move "bc3bbfd1a1e5" changeset was an edited list candidate
+  (move must only use unlisted changesets)
+
+Try to use histedit to move a commit from the linear history
+
+  $ hg histedit 3 --command - 2>&1 << EOF | fixbundle
+  > pick bc3bbfd1a1e5
+  > pick f647aec54d8c
+  > move c604726e05fb
+  > EOF
+  hg: parse error: move "c604726e05fb" is an ancestor of base changeset "674f74e24e11"
+  (use histedit with a larger range to move older changesets)
+
+Try to use histedit to move a public commit
+
+  $ hg phase -p 1
+  $ hg histedit 3 --command - 2>&1 << EOF | fixbundle
+  > pick bc3bbfd1a1e5
+  > pick f647aec54d8c
+  > move c604726e05fb
+  > EOF
+  hg: parse error: move "c604726e05fb" is public
+  (cannot move public changesets)
+
+Add a new branch with some more commits
+
+  $ hg up -q 1
+  $ for x in d e f ; do
+  >   echo $x > $x
+  >   hg add $x
+  >   hg commit -m $x
+  > done
+  created new head
+  $ hg tglog
+  @  7:5e8ba7becadd7603f9dc3930bf2eca7e1de7b5b7:draft 'f'
+  |
+  o  6:85655859b8253b037439b48987f0c55bb37a7561:draft 'e'
+  |
+  o  5:73c0a6e5dda8e5233bdfa4ee0ec172d719046e92:draft 'd'
+  |
+  | o  4:f647aec54d8c9b7688f475eb90127eb6bda0bc22:draft 'c'
+  | |
+  | o  3:bc3bbfd1a1e54a2b37fdd1d09cd138ea8641c5c8:draft 'b'
+  | |
+  | o  2:674f74e24e11522e03d59ea2593d93a77b715b3f:draft 'other 1'
+  |/
+  o  1:c604726e05fb3a349978173b3ab4a3ee6e43cd6c:public 'a'
+  |
+  o  0:d20a80d4def38df63a4b330b7fb688f3d4cae1e3:public 'base'
+  
+Try to use histedit to orphan a changeset - this just copies as obsolescence markers are disabled
+
+  $ hg histedit 5 --command - 2>&1 << EOF | fixbundle
+  > pick 73c0a6e5dda8 'd'
+  > pick 85655859b825 'e'
+  > move bc3bbfd1a1e5 'b' (has child changeset 'c')
+  > pick 5e8ba7becadd 'f'
+  > EOF
+  warning: orphaned descendants detected, not stripping bc3bbfd1a1e5
+  $ hg tglog
+  @  8:befbee4980c1f797ffcb4c408511bf71a06c0d07:draft 'f'
+  |
+  o  7:397d9f24f9c7bc877948318e48b1ec1d58d65381:draft 'b'
+  |
+  o  6:85655859b8253b037439b48987f0c55bb37a7561:draft 'e'
+  |
+  o  5:73c0a6e5dda8e5233bdfa4ee0ec172d719046e92:draft 'd'
+  |
+  | o  4:f647aec54d8c9b7688f475eb90127eb6bda0bc22:draft 'c'
+  | |
+  | o  3:bc3bbfd1a1e54a2b37fdd1d09cd138ea8641c5c8:draft 'b'
+  | |
+  | o  2:674f74e24e11522e03d59ea2593d93a77b715b3f:draft 'other 1'
+  |/
+  o  1:c604726e05fb3a349978173b3ab4a3ee6e43cd6c:public 'a'
+  |
+  o  0:d20a80d4def38df63a4b330b7fb688f3d4cae1e3:public 'base'
+  
+
+Try to use histedit to move an ancestor changeset while splitting history
+
+  $ hg histedit 5 --config experimental.histeditng=true --command - 2>&1 << EOF | fixbundle
+  > pick 73c0a6e5dda8 'd'
+  > base f647aec54d8c 'c'
+  > pick 85655859b825 'e'
+  > pick 397d9f24f9c7 'b'
+  > move 674f74e24e11 'other 1' (ancestor of 'c')
+  > pick befbee4980c1 'f'
+  > EOF
+  hg: parse error: move "674f74e24e11" is an ancestor of base changeset "f647aec54d8c"
+  (use histedit with a larger range to move older changesets)
+
+Add a new branch with some more commits
+
+  $ hg up -q 1
+  $ for x in g h ; do
+  >   echo $x > $x
+  >   hg add $x
+  >   hg commit -m $x
+  > done
+  created new head
+  $ hg tglog
+  @  10:9ed351767a9bcb2c1599c78c51a563b34a89a51d:draft 'h'
+  |
+  o  9:b715e87e9d48541c48201bebae76adab0c52c267:draft 'g'
+  |
+  | o  8:befbee4980c1f797ffcb4c408511bf71a06c0d07:draft 'f'
+  | |
+  | o  7:397d9f24f9c7bc877948318e48b1ec1d58d65381:draft 'b'
+  | |
+  | o  6:85655859b8253b037439b48987f0c55bb37a7561:draft 'e'
+  | |
+  | o  5:73c0a6e5dda8e5233bdfa4ee0ec172d719046e92:draft 'd'
+  |/
+  | o  4:f647aec54d8c9b7688f475eb90127eb6bda0bc22:draft 'c'
+  | |
+  | o  3:bc3bbfd1a1e54a2b37fdd1d09cd138ea8641c5c8:draft 'b'
+  | |
+  | o  2:674f74e24e11522e03d59ea2593d93a77b715b3f:draft 'other 1'
+  |/
+  o  1:c604726e05fb3a349978173b3ab4a3ee6e43cd6c:public 'a'
+  |
+  o  0:d20a80d4def38df63a4b330b7fb688f3d4cae1e3:public 'base'
+  
+
+Use histedit to copy and move changesets while splitting history
+
+  $ hg histedit 9 --config experimental.histeditng=true --command - 2>&1 << EOF | fixbundle
+  > pick 9ed351767a9b 'h'
+  > base f647aec54d8c 'c'
+  > copy 85655859b825 'e'
+  > pick b715e87e9d48 'g'
+  > move befbee4980c1 'f'
+  > EOF
+  $ hg tglog
+  @  11:a243a7bd85a097c807ee9009c97af5f111ef6241:draft 'f'
+  |
+  o  10:c33a0add54804e6555c0e1c1ca930df2f39e0251:draft 'g'
+  |
+  o  9:eeabd497703b4776a37a8f49fa50ea894aef97d3:draft 'e'
+  |
+  | o  8:0650d87880a6a3b54da277dbd4eecc68fba74c2f:draft 'h'
+  | |
+  | | o  7:397d9f24f9c7bc877948318e48b1ec1d58d65381:draft 'b'
+  | | |
+  | | o  6:85655859b8253b037439b48987f0c55bb37a7561:draft 'e'
+  | | |
+  | | o  5:73c0a6e5dda8e5233bdfa4ee0ec172d719046e92:draft 'd'
+  | |/
+  o |  4:f647aec54d8c9b7688f475eb90127eb6bda0bc22:draft 'c'
+  | |
+  o |  3:bc3bbfd1a1e54a2b37fdd1d09cd138ea8641c5c8:draft 'b'
+  | |
+  o |  2:674f74e24e11522e03d59ea2593d93a77b715b3f:draft 'other 1'
+  |/
+  o  1:c604726e05fb3a349978173b3ab4a3ee6e43cd6c:public 'a'
+  |
+  o  0:d20a80d4def38df63a4b330b7fb688f3d4cae1e3:public 'base'
+  
diff --git a/tests/test-histedit-copymove-obs.t b/tests/test-histedit-copymove-obs.t
new file mode 100644
--- /dev/null
+++ b/tests/test-histedit-copymove-obs.t
@@ -0,0 +1,70 @@
+  $ . "$TESTDIR/histedit-helpers.sh"
+
+  $ cat >> $HGRCPATH <<EOF
+  > [alias]
+  > tglog = log -G --template "{rev}:{node}:{phase} '{desc}'\n"
+  > [extensions]
+  > histedit=
+  > [experimental]
+  > evolution=createmarkers, allowunstable
+  > EOF
+
+Create repo with two branches
+
+  $ hg init repo
+  $ cd repo
+  $ echo base > base
+  $ hg add base
+  $ hg commit -m "base"
+  $ for x in a b c ; do
+  >   echo $x > $x
+  >   hg add $x
+  >   hg commit -m $x
+  > done
+  $ hg up -q 0
+  $ for x in d e f ; do
+  >   echo $x > $x
+  >   hg add $x
+  >   hg commit -m $x
+  > done
+  created new head
+  $ hg tglog
+  @  6:1eb7eda15cd7b2222738a7c9b47d1f51349b2bdb:draft 'f'
+  |
+  o  5:581a2eefdc84e2ec03c03b152f4982eefd77d7d8:draft 'e'
+  |
+  o  4:331acda6ee0072ace4b46c46bf80bb585d55d799:draft 'd'
+  |
+  | o  3:f9d2e574dc5853aac398917ed798d8640e8203af:draft 'c'
+  | |
+  | o  2:c87fe1ae405ff0a6dcc1ce27064cb9d303a05734:draft 'b'
+  | |
+  | o  1:c604726e05fb3a349978173b3ab4a3ee6e43cd6c:draft 'a'
+  |/
+  o  0:d20a80d4def38df63a4b330b7fb688f3d4cae1e3:draft 'base'
+  
+Use histedit to orphan a changeset
+
+  $ hg histedit 4 --command - 2>&1 << EOF | fixbundle
+  > p 331acda6ee
+  > p 581a2eefdc
+  > v c87fe1ae40
+  > p 1eb7eda15c
+  > EOF
+  $ hg tglog
+  @  8:b5b75ed229c82a78962586c18f88e923a09fcbe1:draft 'f'
+  |
+  o  7:7a1a952d8f3643e0afae039e737b10b99a40ca03:draft 'b'
+  |
+  o  5:581a2eefdc84e2ec03c03b152f4982eefd77d7d8:draft 'e'
+  |
+  o  4:331acda6ee0072ace4b46c46bf80bb585d55d799:draft 'd'
+  |
+  | o  3:f9d2e574dc5853aac398917ed798d8640e8203af:draft 'c'
+  | |
+  | x  2:c87fe1ae405ff0a6dcc1ce27064cb9d303a05734:draft 'b'
+  | |
+  | o  1:c604726e05fb3a349978173b3ab4a3ee6e43cd6c:draft 'a'
+  |/
+  o  0:d20a80d4def38df63a4b330b7fb688f3d4cae1e3:draft 'base'
+  



To: mbthomas, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list