tests/test-push-warn
changeset 12279 28e2e3804f2e
parent 12278 c4c2ba553401
child 12280 6ee719f56f01
equal deleted inserted replaced
12278:c4c2ba553401 12279:28e2e3804f2e
     1 #!/bin/sh
       
     2 
       
     3 echo "[extensions]" >> $HGRCPATH
       
     4 echo "graphlog=" >> $HGRCPATH
       
     5 
       
     6 mkdir a
       
     7 cd a
       
     8 hg init
       
     9 echo foo > t1
       
    10 hg add t1
       
    11 hg commit -m "1"
       
    12 
       
    13 cd ..
       
    14 hg clone a b
       
    15 
       
    16 cd a
       
    17 echo foo > t2
       
    18 hg add t2
       
    19 hg commit -m "2"
       
    20 
       
    21 cd ../b
       
    22 echo foo > t3
       
    23 hg add t3
       
    24 hg commit -m "3"
       
    25 
       
    26 hg push ../a
       
    27 hg pull ../a
       
    28 hg push ../a
       
    29 hg merge
       
    30 hg commit -m "4"
       
    31 hg push ../a
       
    32 cd ..
       
    33 
       
    34 hg init c
       
    35 cd c
       
    36 for i in 0 1 2; do
       
    37     echo $i >> foo
       
    38     hg ci -Am $i
       
    39 done
       
    40 cd ..
       
    41 
       
    42 hg clone c d
       
    43 cd d
       
    44 for i in 0 1; do
       
    45     hg co -C $i
       
    46     echo d-$i >> foo
       
    47     hg ci -m d-$i
       
    48 done
       
    49 
       
    50 HGMERGE=true hg merge 3
       
    51 hg ci -m c-d
       
    52 
       
    53 hg push ../c; echo $?
       
    54 hg push -r 2 ../c; echo $?
       
    55 hg push -r 3 ../c; echo $?
       
    56 hg push -r 3 -r 4 ../c; echo $?
       
    57 hg push -f -r 3 -r 4 ../c; echo $?
       
    58 hg push -r 5 ../c; echo $?
       
    59 hg in ../c
       
    60 
       
    61 echo % issue 450
       
    62 hg init ../e
       
    63 hg push -r 0 ../e ; echo $?
       
    64 hg push -r 1 ../e ; echo $?
       
    65 
       
    66 cd ..
       
    67 
       
    68 echo % issue 736
       
    69 hg init f
       
    70 cd f
       
    71 hg -q branch a
       
    72 echo 0 > foo
       
    73 hg -q ci -Am 0
       
    74 echo 1 > foo
       
    75 hg -q ci -m 1
       
    76 hg -q up 0
       
    77 echo 2 > foo
       
    78 hg -q ci -m 2
       
    79 hg -q up 0
       
    80 hg -q branch b
       
    81 echo 3 > foo
       
    82 hg -q ci -m 3
       
    83 cd ..
       
    84 
       
    85 hg -q clone f g
       
    86 cd g
       
    87 
       
    88 echo % push on existing branch and new branch
       
    89 hg -q up 1
       
    90 echo 4 > foo
       
    91 hg -q ci -m 4
       
    92 hg -q up 0
       
    93 echo 5 > foo
       
    94 hg -q branch c
       
    95 hg -q ci -m 5
       
    96 hg push ../f; echo $?
       
    97 hg push -r 4 -r 5 ../f; echo $?
       
    98 
       
    99 echo % multiple new branches
       
   100 hg -q branch d
       
   101 echo 6 > foo
       
   102 hg -q ci -m 6
       
   103 hg push ../f; echo $?
       
   104 hg push -r 4 -r 6 ../f; echo $?
       
   105 cd ../g
       
   106 
       
   107 echo % fail on multiple head push
       
   108 hg -q up 1
       
   109 echo 7 > foo
       
   110 hg -q ci -m 7
       
   111 hg push -r 4 -r 7 ../f; echo $?
       
   112 
       
   113 echo % push replacement head on existing branches
       
   114 hg -q up 3
       
   115 echo 8 > foo
       
   116 hg -q ci -m 8
       
   117 hg push -r 7 -r 8 ../f; echo $?
       
   118 
       
   119 echo % merge of branch a to other branch b followed by unrelated push on branch a
       
   120 hg -q up 7
       
   121 HGMERGE=true hg -q merge 8
       
   122 hg -q ci -m 9
       
   123 hg -q up 8
       
   124 echo 10 > foo
       
   125 hg -q ci -m 10
       
   126 hg push -r 9 ../f; echo $?
       
   127 hg push -r 10 ../f; echo $?
       
   128 
       
   129 echo % cheating the counting algorithm
       
   130 hg -q up 9
       
   131 HGMERGE=true hg -q merge 2
       
   132 hg -q ci -m 11
       
   133 hg -q up 1
       
   134 echo 12 > foo
       
   135 hg -q ci -m 12
       
   136 hg push -r 11 -r 12 ../f; echo $?
       
   137 
       
   138 echo % failed push of new named branch
       
   139 echo 12 > foo
       
   140 hg -q ci -m 12a
       
   141 hg -q up 11
       
   142 echo 13 > foo
       
   143 hg -q branch e
       
   144 hg -q ci -m 13d
       
   145 hg push -r 12 -r 13 ../f; echo $?
       
   146 
       
   147 echo % using --new-branch to push new named branch
       
   148 hg push --new-branch -r 12 -r 13 ../f; echo $?
       
   149 
       
   150 echo % checking prepush logic does not allow silently pushing multiple new heads
       
   151 cd ..
       
   152 hg init h
       
   153 echo init > h/init
       
   154 hg -R h ci -Am init
       
   155 echo a > h/a
       
   156 hg -R h ci -Am a
       
   157 hg clone h i
       
   158 hg -R h up 0
       
   159 echo b > h/b
       
   160 hg -R h ci -Am b
       
   161 hg -R i up 0
       
   162 echo c > i/c
       
   163 hg -R i ci -Am c
       
   164 hg -R i push h
       
   165 echo
       
   166 
       
   167 echo % check prepush logic with merged branches
       
   168 hg init j
       
   169 hg -R j branch a
       
   170 echo init > j/foo
       
   171 hg -R j ci -Am init
       
   172 hg clone j k
       
   173 echo a1 > j/foo
       
   174 hg -R j ci -m a1
       
   175 hg -R k branch b
       
   176 echo b > k/foo
       
   177 hg -R k ci -m b
       
   178 hg -R k up 0
       
   179 hg -R k merge b
       
   180 hg -R k ci -m merge
       
   181 hg -R k push -r a j
       
   182 echo
       
   183 
       
   184 echo % prepush -r should not allow you to sneak in new heads
       
   185 hg init l
       
   186 cd l
       
   187 echo a >> foo
       
   188 hg -q add foo
       
   189 hg -q branch a
       
   190 hg -q ci -ma
       
   191 hg -q up null
       
   192 echo a >> foo
       
   193 hg -q add foo
       
   194 hg -q branch b
       
   195 hg -q ci -mb
       
   196 cd ..
       
   197 hg -q clone l m -u a
       
   198 cd m
       
   199 hg -q merge b
       
   200 hg -q ci -mmb
       
   201 hg -q up 0
       
   202 echo a >> foo
       
   203 hg -q ci -ma2
       
   204 hg -q up 2
       
   205 echo a >> foo
       
   206 hg -q branch -f b
       
   207 hg -q ci -mb2
       
   208 hg -q merge 3
       
   209 hg -q ci -mma
       
   210 hg push ../l -b b
       
   211 cd ..
       
   212 
       
   213 echo % check prepush with new branch head on former topo non-head
       
   214 hg init n
       
   215 cd n
       
   216 hg branch A
       
   217 echo a >a
       
   218 hg ci -Ama
       
   219 hg branch B
       
   220 echo b >b
       
   221 hg ci -Amb
       
   222 # b is now branch head of B, and a topological head
       
   223 # a is now branch head of A, but not a topological head
       
   224 hg clone . inner
       
   225 cd inner
       
   226 hg up B
       
   227 echo b1 >b1
       
   228 hg ci -Amb1
       
   229 # in the clone b1 is now the head of B
       
   230 cd ..
       
   231 hg up 0
       
   232 echo a2 >a2
       
   233 hg ci -Ama2
       
   234 # a2 is now the new branch head of A, and a new topological head
       
   235 # it replaces a former inner branch head, so it should at most warn about A, not B
       
   236 echo %% glog of local
       
   237 hg glog --template "{rev}: {branches} {desc}\n"
       
   238 echo %% glog of remote
       
   239 hg glog -R inner --template "{rev}: {branches} {desc}\n"
       
   240 echo %% outgoing
       
   241 hg out inner --template "{rev}: {branches} {desc}\n"
       
   242 hg push inner
       
   243 cd ..
       
   244 
       
   245 echo % check prepush with new branch head on former topo head
       
   246 hg init o
       
   247 cd o
       
   248 hg branch A
       
   249 echo a >a
       
   250 hg ci -Ama
       
   251 hg branch B
       
   252 echo b >b
       
   253 hg ci -Amb
       
   254 # b is now branch head of B, and a topological head
       
   255 hg up 0
       
   256 echo a1 >a1
       
   257 hg ci -Ama1
       
   258 # a1 is now branch head of A, and a topological head
       
   259 hg clone . inner
       
   260 cd inner
       
   261 hg up B
       
   262 echo b1 >b1
       
   263 hg ci -Amb1
       
   264 # in the clone b1 is now the head of B
       
   265 cd ..
       
   266 echo a2 >a2
       
   267 hg ci -Ama2
       
   268 # a2 is now the new branch head of A, and a topological head
       
   269 # it replaces a former topological and branch head, so this should not warn
       
   270 echo %% glog of local
       
   271 hg glog --template "{rev}: {branches} {desc}\n"
       
   272 echo %% glog of remote
       
   273 hg glog -R inner --template "{rev}: {branches} {desc}\n"
       
   274 echo %% outgoing
       
   275 hg out inner --template "{rev}: {branches} {desc}\n"
       
   276 hg push inner
       
   277 cd ..
       
   278 
       
   279 echo % check prepush with new branch head and new child of former branch head
       
   280 echo % but child is on different branch
       
   281 hg init p
       
   282 cd p
       
   283 hg branch A
       
   284 echo a0 >a
       
   285 hg ci -Ama0
       
   286 echo a1 >a
       
   287 hg ci -ma1
       
   288 hg up null
       
   289 hg branch B
       
   290 echo b0 >b
       
   291 hg ci -Amb0
       
   292 echo b1 >b
       
   293 hg ci -mb1
       
   294 
       
   295 hg clone . inner
       
   296 
       
   297 hg up A
       
   298 hg branch -f B
       
   299 echo a3 >a
       
   300 hg ci -ma3
       
   301 hg up 3
       
   302 hg branch -f A
       
   303 echo b3 >b
       
   304 hg ci -mb3
       
   305 
       
   306 echo %% glog of local
       
   307 hg glog --template "{rev}: {branches} {desc}\n"
       
   308 echo %% glog of remote
       
   309 hg glog -R inner --template "{rev}: {branches} {desc}\n"
       
   310 echo %% outgoing
       
   311 hg out inner --template "{rev}: {branches} {desc}\n"
       
   312 hg push inner
       
   313 hg push inner -r4 -r5
       
   314 hg in inner
       
   315 cd ..
       
   316 
       
   317 exit 0