tests/test-rebase-cache.t
author Matt Harbison <matt_harbison@yahoo.com>
Sat, 20 Oct 2012 21:43:46 -0400
branchstable
changeset 17847 1e4eb1faba6e
parent 17345 4f8054d3171b
child 18983 31bcc5112191
permissions -rw-r--r--
largefiles: use 'default' instead of 'default-push' when pulling (issue3584) This only applies to downloading largefiles, and only when no source for the pull is explicitly provided. The repository itself was properly being pulled via 'default' previously. Using --all-largefiles is not necessary on a bare pull to test this (this existing test is merely a convenience), but it is required to test pulling on the rebase path. Note that the errors generated in the --rebase case are because the repo specified doesn't have the largefiles in its cache (though they are in the user cache), so the errors are misleading. Specifying --all-largefiles when cloning to 'b' fixes this, but instead of errors, it reports caching only 5 largefiles instead of the 9 that come up missing. Likely this is because the largefile download procedure tries to download missing files for each rev, and some of the files have standins in more than one rev that gets pulled.

  $ cat >> $HGRCPATH <<EOF
  > [extensions]
  > graphlog=
  > rebase=
  > mq=
  > 
  > [phases]
  > publish=False
  > 
  > [alias]
  > tglog  = log -G --template "{rev}: '{desc}' {branches}\n"
  > theads = heads --template "{rev}: '{desc}' {branches}\n"
  > EOF

  $ hg init a
  $ cd a

  $ echo a > a
  $ hg ci -Am A
  adding a

  $ hg branch branch1
  marked working directory as branch branch1
  (branches are permanent and global, did you want a bookmark?)
  $ hg ci -m 'branch1'

  $ echo b > b
  $ hg ci -Am B
  adding b

  $ hg up -q 0

  $ hg branch branch2
  marked working directory as branch branch2
  (branches are permanent and global, did you want a bookmark?)
  $ hg ci -m 'branch2'

  $ echo c > C
  $ hg ci -Am C
  adding C

  $ hg up -q 2

  $ hg branch -f branch2
  marked working directory as branch branch2
  (branches are permanent and global, did you want a bookmark?)
  $ echo d > d
  $ hg ci -Am D
  adding d
  created new head

  $ echo e > e
  $ hg ci -Am E
  adding e

  $ hg update default
  0 files updated, 0 files merged, 3 files removed, 0 files unresolved

  $ hg branch branch3
  marked working directory as branch branch3
  (branches are permanent and global, did you want a bookmark?)
  $ hg ci -m 'branch3'

  $ echo f > f
  $ hg ci -Am F
  adding f

  $ cd ..


Rebase part of branch2 (5-6) onto branch3 (8):

  $ hg clone -q -u . a a1
  $ cd a1

  $ hg tglog
  @  8: 'F' branch3
  |
  o  7: 'branch3' branch3
  |
  | o  6: 'E' branch2
  | |
  | o  5: 'D' branch2
  | |
  | | o  4: 'C' branch2
  | | |
  +---o  3: 'branch2' branch2
  | |
  | o  2: 'B' branch1
  | |
  | o  1: 'branch1' branch1
  |/
  o  0: 'A'
  
  $ hg branches
  branch3                        8:4666b71e8e32
  branch2                        6:5097051d331d
  branch1                        2:0a03079c47fd (inactive)
  default                        0:1994f17a630e (inactive)

  $ hg theads
  8: 'F' branch3
  6: 'E' branch2
  4: 'C' branch2
  2: 'B' branch1
  0: 'A' 

  $ hg rebase -s 5 -d 8
  saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)

  $ hg branches
  branch3                        8:466cdfb14b62
  branch2                        4:e4fdb121d036
  branch1                        2:0a03079c47fd
  default                        0:1994f17a630e (inactive)

  $ hg theads
  8: 'E' branch3
  4: 'C' branch2
  2: 'B' branch1
  0: 'A' 

  $ hg tglog
  @  8: 'E' branch3
  |
  o  7: 'D' branch3
  |
  o  6: 'F' branch3
  |
  o  5: 'branch3' branch3
  |
  | o  4: 'C' branch2
  | |
  | o  3: 'branch2' branch2
  |/
  | o  2: 'B' branch1
  | |
  | o  1: 'branch1' branch1
  |/
  o  0: 'A'
  
  $ cd ..


Rebase head of branch3 (8) onto branch2 (6):

  $ hg clone -q -u . a a2
  $ cd a2

  $ hg tglog
  @  8: 'F' branch3
  |
  o  7: 'branch3' branch3
  |
  | o  6: 'E' branch2
  | |
  | o  5: 'D' branch2
  | |
  | | o  4: 'C' branch2
  | | |
  +---o  3: 'branch2' branch2
  | |
  | o  2: 'B' branch1
  | |
  | o  1: 'branch1' branch1
  |/
  o  0: 'A'
  
  $ hg rebase -s 8 -d 6
  saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)

  $ hg branches
  branch2                        8:6b4bdc1b5ac0
  branch3                        7:653b9feb4616
  branch1                        2:0a03079c47fd (inactive)
  default                        0:1994f17a630e (inactive)

  $ hg theads
  8: 'F' branch2
  7: 'branch3' branch3
  4: 'C' branch2
  2: 'B' branch1
  0: 'A' 

  $ hg tglog
  @  8: 'F' branch2
  |
  | o  7: 'branch3' branch3
  | |
  o |  6: 'E' branch2
  | |
  o |  5: 'D' branch2
  | |
  | | o  4: 'C' branch2
  | | |
  | | o  3: 'branch2' branch2
  | |/
  o |  2: 'B' branch1
  | |
  o |  1: 'branch1' branch1
  |/
  o  0: 'A'
  
  $ hg verify -q

  $ cd ..


Rebase entire branch3 (7-8) onto branch2 (6):

  $ hg clone -q -u . a a3
  $ cd a3

  $ hg tglog
  @  8: 'F' branch3
  |
  o  7: 'branch3' branch3
  |
  | o  6: 'E' branch2
  | |
  | o  5: 'D' branch2
  | |
  | | o  4: 'C' branch2
  | | |
  +---o  3: 'branch2' branch2
  | |
  | o  2: 'B' branch1
  | |
  | o  1: 'branch1' branch1
  |/
  o  0: 'A'
  
  $ hg rebase -s 7 -d 6
  saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)

  $ hg branches
  branch2                        7:6b4bdc1b5ac0
  branch1                        2:0a03079c47fd (inactive)
  default                        0:1994f17a630e (inactive)

  $ hg theads
  7: 'F' branch2
  4: 'C' branch2
  2: 'B' branch1
  0: 'A' 

  $ hg tglog
  @  7: 'F' branch2
  |
  o  6: 'E' branch2
  |
  o  5: 'D' branch2
  |
  | o  4: 'C' branch2
  | |
  | o  3: 'branch2' branch2
  | |
  o |  2: 'B' branch1
  | |
  o |  1: 'branch1' branch1
  |/
  o  0: 'A'
  
  $ hg verify -q

Stripping multiple branches in one go bypasses the fast-case code to
update the branch cache.

  $ hg strip 2
  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
  saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)

  $ hg tglog
  o  3: 'C' branch2
  |
  o  2: 'branch2' branch2
  |
  | @  1: 'branch1' branch1
  |/
  o  0: 'A'
  

  $ hg branches
  branch2                        3:e4fdb121d036
  branch1                        1:63379ac49655
  default                        0:1994f17a630e (inactive)

  $ hg theads
  3: 'C' branch2
  1: 'branch1' branch1
  0: 'A' 

Fast path branchcache code should not be invoked if branches stripped is not
the same as branches remaining.

  $ hg init b
  $ cd b

  $ hg branch branch1
  marked working directory as branch branch1
  (branches are permanent and global, did you want a bookmark?)
  $ hg ci -m 'branch1'

  $ hg branch branch2
  marked working directory as branch branch2
  (branches are permanent and global, did you want a bookmark?)
  $ hg ci -m 'branch2'

  $ hg branch -f branch1
  marked working directory as branch branch1
  (branches are permanent and global, did you want a bookmark?)

  $ echo a > A
  $ hg ci -Am A
  adding A
  created new head

  $ hg tglog
  @  2: 'A' branch1
  |
  o  1: 'branch2' branch2
  |
  o  0: 'branch1' branch1
  

  $ hg theads
  2: 'A' branch1
  1: 'branch2' branch2

  $ hg strip 2
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  saved backup bundle to $TESTTMP/a3/b/.hg/strip-backup/*-backup.hg (glob)

  $ hg theads
  1: 'branch2' branch2
  0: 'branch1' branch1


Make sure requesting to strip a revision already stripped does not confuse things.
Try both orders.

  $ cd ..

  $ hg init c
  $ cd c

  $ 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
  $ echo d > d
  $ hg ci -Am D
  adding d
  $ echo e > e
  $ hg ci -Am E
  adding e

  $ hg tglog
  @  4: 'E'
  |
  o  3: 'D'
  |
  o  2: 'C'
  |
  o  1: 'B'
  |
  o  0: 'A'
  

  $ hg strip 3 4
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  saved backup bundle to $TESTTMP/a3/c/.hg/strip-backup/*-backup.hg (glob)

  $ hg theads
  2: 'C' 

  $ hg strip 2 1
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  saved backup bundle to $TESTTMP/a3/c/.hg/strip-backup/*-backup.hg (glob)

  $ hg theads
  0: 'A'