tests/test-grab.t
author Pulkit Goyal <7895pulkit@gmail.com>
Thu, 18 Jan 2018 16:57:19 +0530
changeset 3460 ada7fb453034
parent 3453 32ed5b6fadd3
child 3473 b2f591aa4507
permissions -rw-r--r--
evolve: remove not required calls to phases.retractboundary() To make sure phases are preserved during evolve, we started using the phases.new-commit config option. Now we don't need to call phases.retractboundary(). Let's remove the redundant code.

Test for the grab command

  $ cat >> $HGRCPATH <<EOF
  > [alias]
  > glog = log -G -T "{rev}:{node|short} {desc}\n"
  > [extensions]
  > EOF
  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH

  $ mkcommit() {
  >    echo "$1" > "$1"
  >    hg add "$1"
  >    hg ci -m "add $1"
  > }

  $ hg init repo
  $ cd repo
  $ hg help grab
  hg grab [-r] rev
  
  grabs a commit, move it on the top of working directory parent and
      updates to it.
  
  options:
  
   -r --rev VALUE revision to grab
      --continue  continue interrupted grab
      --abort     abort interrupted grab
  
  (some details hidden, use --verbose to show complete help)

  $ mkcommit a
  $ mkcommit b
  $ mkcommit c

  $ hg glog
  @  2:4538525df7e2 add c
  |
  o  1:7c3bad9141dc add b
  |
  o  0:1f0dee641bb7 add a
  

Grabbing an ancestor

  $ hg grab -r 7c3bad9141dc
  abort: cannot grab an ancestor revision
  [255]

Specifying multiple revisions to grab

  $ hg grab 1f0dee641bb7 -r 7c3bad9141dc
  abort: specify just one revision
  [255]

Specifying no revisions to grab

  $ hg grab
  abort: empty revision set
  [255]

Continuing without interrupted grab

  $ hg grab --continue
  abort: no interrupted grab state exists
  [255]

Aborting without interrupted grab

  $ hg grab --abort
  abort: no interrupted grab state exists
  [255]

Specifying both continue and revs

  $ hg up 1f0dee641bb7
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ hg grab -r 4538525df7e2 --continue
  abort: cannot specify both --continue and revision
  [255]

Making new branch heads

  $ mkcommit x
  created new head
  $ mkcommit y

  $ hg glog
  @  4:d46dc301d92f add y
  |
  o  3:8e224524cd09 add x
  |
  | o  2:4538525df7e2 add c
  | |
  | o  1:7c3bad9141dc add b
  |/
  o  0:1f0dee641bb7 add a
  
Grabbing a revision

  $ hg grab 7c3bad9141dc
  grabbing 1:7c3bad9141dc "add b"
  1 new orphan changesets
  $ hg glog
  @  5:7c15c05db6fa add b
  |
  o  4:d46dc301d92f add y
  |
  o  3:8e224524cd09 add x
  |
  | *  2:4538525df7e2 add c
  | |
  | x  1:7c3bad9141dc add b
  |/
  o  0:1f0dee641bb7 add a
  

When grab does not create any changes

  $ hg graft -r 4538525df7e2
  grafting 2:4538525df7e2 "add c"

  $ hg glog
  @  6:c4636a81ebeb add c
  |
  o  5:7c15c05db6fa add b
  |
  o  4:d46dc301d92f add y
  |
  o  3:8e224524cd09 add x
  |
  | *  2:4538525df7e2 add c
  | |
  | x  1:7c3bad9141dc add b
  |/
  o  0:1f0dee641bb7 add a
  
  $ hg grab -r 4538525df7e2
  grabbing 2:4538525df7e2 "add c"
  note: grab of 2:4538525df7e2 created no changes to commit

  $ hg glog
  @  6:c4636a81ebeb add c
  |
  o  5:7c15c05db6fa add b
  |
  o  4:d46dc301d92f add y
  |
  o  3:8e224524cd09 add x
  |
  o  0:1f0dee641bb7 add a
  
interrupted grab

  $ hg up d46dc301d92f
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ echo foo > c
  $ hg ci -Aqm "foo to c"
  $ hg grab -r c4636a81ebeb
  grabbing 6:c4636a81ebeb "add c"
  merging c
  warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
  unresolved merge conflicts (see hg help resolve)
  [1]

  $ echo foobar > c
  $ hg resolve --all --mark
  (no more unresolved files)
  $ hg grab --continue
  $ hg glog
  @  8:44e155eb95c7 add c
  |
  o  7:2ccc03d1d096 foo to c
  |
  | o  5:7c15c05db6fa add b
  |/
  o  4:d46dc301d92f add y
  |
  o  3:8e224524cd09 add x
  |
  o  0:1f0dee641bb7 add a
  
Testing the abort functionality of hg grab

  $ echo foo > b
  $ hg ci -Aqm "foo to b"
  $ hg glog -r .^::
  @  9:902d4f4602bb foo to b
  |
  o  8:44e155eb95c7 add c
  |
  ~

  $ hg grab -r 7c15c05db6fa
  grabbing 5:7c15c05db6fa "add b"
  merging b
  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
  unresolved merge conflicts (see hg help resolve)
  [1]

  $ hg grab --abort
  aborting grab, updating to 902d4f4602bb

  $ hg glog
  @  9:902d4f4602bb foo to b
  |
  o  8:44e155eb95c7 add c
  |
  o  7:2ccc03d1d096 foo to c
  |
  | o  5:7c15c05db6fa add b
  |/
  o  4:d46dc301d92f add y
  |
  o  3:8e224524cd09 add x
  |
  o  0:1f0dee641bb7 add a
  

Trying to grab a public changeset

  $ hg phase -r 7c15c05db6fa -p

  $ hg grab -r 7c15c05db6fa
  abort: cannot grab public changesets: 7c15c05db6fa
  (see 'hg help phases' for details)
  [255]

  $ hg glog
  @  9:902d4f4602bb foo to b
  |
  o  8:44e155eb95c7 add c
  |
  o  7:2ccc03d1d096 foo to c
  |
  | o  5:7c15c05db6fa add b
  |/
  o  4:d46dc301d92f add y
  |
  o  3:8e224524cd09 add x
  |
  o  0:1f0dee641bb7 add a