tests/test-update-branches.t
author Matt Mackall <mpm@selenic.com>
Wed, 12 Oct 2011 18:46:23 -0500
changeset 15240 bfb93963bb39
parent 14485 610873cf064a
child 16491 bfe89d65d651
permissions -rw-r--r--
graft: add user, date, and tool options
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
     1
# Construct the following history tree:
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
     2
#
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
     3
# @  5:e1bb631146ca  b1
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
     4
# |
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
     5
# o  4:a4fdb3b883c4 0:b608b9236435  b1
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
     6
# |
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
     7
# | o  3:4b57d2520816 1:44592833ba9f
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
     8
# | |
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
     9
# | | o  2:063f31070f65
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    10
# | |/
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    11
# | o  1:44592833ba9f
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    12
# |/
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    13
# o  0:b608b9236435
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    14
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    15
  $ hg init
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    16
  $ echo foo > foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    17
  $ echo zero > a
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    18
  $ hg ci -qAm0
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    19
  $ echo one > a ; hg ci -m1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    20
  $ echo two > a ; hg ci -m2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    21
  $ hg up -q 1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    22
  $ echo three > a ; hg ci -qm3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    23
  $ hg up -q 0
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    24
  $ hg branch -q b1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    25
  $ echo four > a ; hg ci -qm4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    26
  $ echo five > a ; hg ci -qm5
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    27
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    28
Initial repo state:
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    29
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    30
  $ hg --config 'extensions.graphlog=' \
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    31
  >    glog --template '{rev}:{node|short} {parents} {branches}\n'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    32
  @  5:e1bb631146ca  b1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    33
  |
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    34
  o  4:a4fdb3b883c4 0:b608b9236435  b1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    35
  |
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    36
  | o  3:4b57d2520816 1:44592833ba9f
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    37
  | |
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    38
  | | o  2:063f31070f65
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    39
  | |/
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    40
  | o  1:44592833ba9f
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    41
  |/
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    42
  o  0:b608b9236435
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    43
  
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    44
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    45
Test helper functions:
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    46
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    47
  $ revtest () {
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    48
  >     msg=$1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    49
  >     dirtyflag=$2   # 'clean' or 'dirty'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    50
  >     startrev=$3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    51
  >     targetrev=$4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    52
  >     opt=$5
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    53
  >     hg up -qC $startrev
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    54
  >     test $dirtyflag = dirty && echo dirty > foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    55
  >     hg up $opt $targetrev
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    56
  >     hg parent --template 'parent={rev}\n'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    57
  >     hg stat
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    58
  > }    
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    59
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    60
  $ norevtest () {
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    61
  >     msg=$1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    62
  >     dirtyflag=$2   # 'clean' or 'dirty'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    63
  >     startrev=$3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    64
  >     opt=$4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    65
  >     hg up -qC $startrev
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    66
  >     test $dirtyflag = dirty && echo dirty > foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    67
  >     hg up $opt
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    68
  >     hg parent --template 'parent={rev}\n'
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    69
  >     hg stat
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    70
  > }    
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    71
12328
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12279
diff changeset
    72
Test cases are documented in a table in the update function of merge.py.
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12279
diff changeset
    73
Cases are run as shown in that table, row by row.
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    74
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    75
  $ norevtest 'none clean linear' clean 4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    76
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    77
  parent=5
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    78
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    79
  $ norevtest 'none clean same'   clean 2
14485
610873cf064a Make pull -u behave like pull && update
Brendan Cully <brendan@kublai.com>
parents: 12681
diff changeset
    80
  abort: crosses branches (merge branches or update --check to force update)
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    81
  parent=2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    82
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    83
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    84
  $ revtest 'none clean linear' clean 1 2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    85
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    86
  parent=2
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
    87
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    88
  $ revtest 'none clean same'   clean 2 3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    89
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    90
  parent=3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    91
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    92
  $ revtest 'none clean cross'  clean 3 4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    93
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    94
  parent=4
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    95
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    96
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    97
  $ revtest 'none dirty linear' dirty 1 2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    98
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
    99
  parent=2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   100
  M foo
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
   101
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   102
  $ revtest 'none dirty same'   dirty 2 3
12681
bc13e17067d9 update: use higher level wording for "crosses branches" error
Brodie Rao <brodie@bitheap.org>
parents: 12328
diff changeset
   103
  abort: crosses branches (merge branches or use --clean to discard changes)
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   104
  parent=2
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   105
  M foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   106
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   107
  $ revtest 'none dirty cross'  dirty 3 4
12681
bc13e17067d9 update: use higher level wording for "crosses branches" error
Brodie Rao <brodie@bitheap.org>
parents: 12328
diff changeset
   108
  abort: crosses branches (merge branches or use --clean to discard changes)
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   109
  parent=3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   110
  M foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   111
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   112
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   113
  $ revtest '-C dirty linear'   dirty 1 2 -C
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   114
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   115
  parent=2
9716
ea8c207a0f78 update: add comments and test cases for updating across branches
Stuart W Marks <smarks@smarks.org>
parents:
diff changeset
   116
12279
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   117
  $ revtest '-c dirty linear'   dirty 1 2 -c
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   118
  abort: uncommitted local changes
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   119
  parent=1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   120
  M foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   121
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   122
  $ norevtest '-c clean same'   clean 2 -c
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   123
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   124
  parent=3
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   125
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   126
  $ revtest '-cC dirty linear'  dirty 1 2 -cC
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   127
  abort: cannot specify both -c/--check and -C/--clean
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   128
  parent=1
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   129
  M foo
28e2e3804f2e combine tests
Adrian Buehlmann <adrian@cadifra.com>
parents: 9716
diff changeset
   130