tests/test-mq-qrefresh
changeset 12324 b701610f6c56
parent 12318 d643ae555a4d
child 12325 5f6231861e09
equal deleted inserted replaced
12318:d643ae555a4d 12324:b701610f6c56
     1 #!/bin/sh
       
     2 
       
     3 echo "[extensions]" >> $HGRCPATH
       
     4 echo "mq=" >> $HGRCPATH
       
     5 
       
     6 catpatch() {
       
     7     cat $1 | sed -e "s/^\(# Parent \).*/\1/"
       
     8 }
       
     9 
       
    10 echo % init
       
    11 hg init a
       
    12 cd a
       
    13 
       
    14 echo % commit
       
    15 mkdir 1 2
       
    16 echo 'base' > 1/base
       
    17 echo 'base' > 2/base
       
    18 hg ci -Ambase -d '1 0'
       
    19 
       
    20 echo % qnew mqbase
       
    21 hg qnew -mmqbase mqbase
       
    22 
       
    23 echo % qrefresh
       
    24 echo 'patched' > 1/base
       
    25 echo 'patched' > 2/base
       
    26 hg qrefresh
       
    27 
       
    28 echo % qdiff
       
    29 hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    30                -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    31 
       
    32 echo % qdiff dirname
       
    33 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    34                  -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    35 
       
    36 echo % patch file contents
       
    37 catpatch .hg/patches/mqbase | \
       
    38 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    39     -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    40 
       
    41 echo % qrefresh 1
       
    42 echo 'patched again' > base
       
    43 hg qrefresh 1
       
    44 
       
    45 echo % qdiff
       
    46 hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    47                -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    48 
       
    49 echo % qdiff dirname
       
    50 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    51                  -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    52 
       
    53 echo % patch file contents
       
    54 catpatch .hg/patches/mqbase | \
       
    55 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    56     -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    57 
       
    58 echo % qrefresh . in subdir
       
    59 ( cd 1 ; hg qrefresh . )
       
    60 
       
    61 echo % qdiff
       
    62 hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    63                -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    64 
       
    65 echo % qdiff dirname
       
    66 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    67                  -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    68 
       
    69 echo % patch file contents
       
    70 catpatch .hg/patches/mqbase | \
       
    71 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    72     -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    73 
       
    74 echo % qrefresh in hg-root again
       
    75 hg qrefresh
       
    76 
       
    77 echo % qdiff
       
    78 hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    79                -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    80 
       
    81 echo % qdiff dirname
       
    82 hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    83                  -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    84 
       
    85 echo % patch file contents
       
    86 catpatch .hg/patches/mqbase | \
       
    87 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
    88     -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
    89 
       
    90 echo
       
    91 echo % qrefresh --short tests:
       
    92 echo 'orphan' > orphanchild
       
    93 hg add orphanchild
       
    94 
       
    95 echo % - add 1/base and 2/base one by one
       
    96 hg qrefresh nonexistingfilename # clear patch
       
    97 hg qrefresh --short 1/base
       
    98 hg qrefresh --short 2/base
       
    99 
       
   100 echo % -- qdiff output
       
   101 hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
   102                -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
   103 
       
   104 echo % -- patch file content
       
   105 catpatch .hg/patches/mqbase | \
       
   106 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
   107     -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
       
   108 hg st
       
   109 
       
   110 echo % -- diff shows what is not in patch
       
   111 hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
       
   112               -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" \
       
   113               -e "s/^\(diff\).*/\1/"
       
   114 echo % - before starting exclusive tests
       
   115 sed -n '/^diff/s/diff -r [^ ]* //p' .hg/patches/mqbase
       
   116 echo % - exclude 2/base
       
   117 hg qref -s -X 2/base
       
   118 sed -n '/^diff/s/diff -r [^ ]* //p' .hg/patches/mqbase
       
   119 echo % -- status shows 2/base as dirty
       
   120 hg st
       
   121 echo % - remove 1/base and add 2/base again but not orphanchild
       
   122 hg qref -s -X orphanchild -X 1/base 2/base orphanchild
       
   123 sed -n '/^diff/s/diff -r [^ ]* //p' .hg/patches/mqbase
       
   124 echo % - add 1/base with include filter - and thus remove 2/base from patch
       
   125 hg qref -s -I 1/ o* */*
       
   126 sed -n '/^diff/s/diff -r [^ ]* //p' .hg/patches/mqbase
       
   127 echo
       
   128 cd ..
       
   129 
       
   130 # Test qrefresh --git losing copy metadata
       
   131 echo % create test repo
       
   132 hg init repo
       
   133 cd repo
       
   134 echo "[diff]" >> .hg/hgrc
       
   135 echo "git=True" >> .hg/hgrc
       
   136 echo a > a
       
   137 hg ci -Am adda
       
   138 hg copy a ab
       
   139 echo b >> ab
       
   140 hg copy a ac
       
   141 echo c >> ac
       
   142 echo % capture changes
       
   143 hg qnew -f p1
       
   144 hg qdiff
       
   145 echo % refresh and check changes again
       
   146 hg qref
       
   147 hg qdiff
       
   148 cd ..
       
   149 
       
   150 # Test issue 1441: qrefresh confused after hg rename
       
   151 echo % issue1441 without git patches
       
   152 hg init repo-1441
       
   153 cd repo-1441
       
   154 echo a > a
       
   155 hg add a
       
   156 hg qnew -f p
       
   157 hg mv a b
       
   158 hg qrefresh
       
   159 hg qdiff --nodates
       
   160 cd ..
       
   161 
       
   162 echo '% issue2025: qrefresh does not honor filtering options when tip != qtip'
       
   163 hg init repo-2025
       
   164 cd repo-2025
       
   165 echo a > a
       
   166 echo b > b
       
   167 hg ci -qAm addab
       
   168 echo a >> a
       
   169 echo b >> b
       
   170 hg qnew -f patch
       
   171 hg up -qC 0
       
   172 echo c > c
       
   173 hg ci -qAm addc
       
   174 hg up -qC 1
       
   175 echo '% refresh with tip != qtip'
       
   176 hg --config diff.nodates=1 qrefresh -I b 2>&1 \
       
   177     | sed 's/saving bundle.*/saving bundle.../g'
       
   178 echo '% status after refresh'
       
   179 hg st
       
   180 echo '% b after refresh'
       
   181 cat b
       
   182 echo '% patch file after refresh'
       
   183 catpatch .hg/patches/patch
       
   184 cd ..
       
   185 
       
   186 
       
   187 echo % issue1441 with git patches
       
   188 hg init repo-1441-git
       
   189 cd repo-1441-git
       
   190 echo "[diff]" >> .hg/hgrc
       
   191 echo "git=True" >> .hg/hgrc
       
   192 echo a > a
       
   193 hg add a
       
   194 hg qnew -f p
       
   195 hg mv a b
       
   196 hg qrefresh
       
   197 hg qdiff --nodates
       
   198 cd ..