tests/test-keyword
changeset 782 09bae16e7a6d
parent 781 c7a471b49819
child 783 8a23ff764a02
child 785 77154fe0e3a5
equal deleted inserted replaced
781:c7a471b49819 782:09bae16e7a6d
     1 #!/bin/sh
       
     2 
       
     3 cat <<EOF >> $HGRCPATH
       
     4 [extensions]
       
     5 keyword =
       
     6 mq =
       
     7 notify =
       
     8 record =
       
     9 transplant =
       
    10 [ui]
       
    11 interactive = true
       
    12 EOF
       
    13 
       
    14 # demo before [keyword] files are set up
       
    15 # would succeed without uisetup otherwise
       
    16 echo % hg kwdemo
       
    17 hg --quiet kwdemo \
       
    18 | sed -e 's![^ ][^ ]*demo.txt,v!/TMP/demo.txt,v!' \
       
    19  -e 's/,v [a-z0-9][a-z0-9]* /,v xxxxxxxxxxxx /' \
       
    20  -e '/[$]Revision/ s/: [a-z0-9][a-z0-9]* /: xxxxxxxxxxxx /' \
       
    21  -e 's! 20[0-9][0-9]/[01][0-9]/[0-3][0-9] [0-2][0-9]:[0-6][0-9]:[0-6][0-9]! 2000/00/00 00:00:00!'
       
    22 
       
    23 hg --quiet kwdemo "Branch = {branches}"
       
    24 
       
    25 cat <<EOF >> $HGRCPATH
       
    26 [keyword]
       
    27 ** =
       
    28 b = ignore
       
    29 [hooks]
       
    30 commit=
       
    31 commit.test=cp a hooktest
       
    32 EOF
       
    33 
       
    34 hg init Test-bndl
       
    35 cd Test-bndl
       
    36 
       
    37 echo % kwshrink should exit silently in empty/invalid repo
       
    38 hg kwshrink
       
    39 
       
    40 # Symlinks cannot be created on Windows. The bundle was made with:
       
    41 #
       
    42 # hg init t
       
    43 # cd t
       
    44 # echo a > a
       
    45 # ln -s a sym
       
    46 # hg add sym
       
    47 # hg ci -m addsym -u mercurial
       
    48 # hg bundle --base null ../test-keyword.hg
       
    49 #
       
    50 hg pull -u "$TESTDIR/test-keyword.hg" \
       
    51     | sed 's/pulling from.*test-keyword.hg/pulling from test-keyword.hg/'
       
    52 
       
    53 echo 'expand $Id$' > a
       
    54 echo 'do not process $Id:' >> a
       
    55 echo 'xxx $' >> a
       
    56 echo 'ignore $Id$' > b
       
    57 echo % cat
       
    58 cat a b
       
    59 
       
    60 echo % no kwfiles
       
    61 hg kwfiles
       
    62 echo % untracked candidates
       
    63 hg -v kwfiles --unknown
       
    64 
       
    65 echo % addremove
       
    66 hg addremove
       
    67 echo % status
       
    68 hg status
       
    69 
       
    70 echo % default keyword expansion including commit hook
       
    71 echo % interrupted commit should not change state or run commit hook
       
    72 hg --debug commit
       
    73 echo % status
       
    74 hg status
       
    75 
       
    76 echo % commit
       
    77 hg --debug commit -mabsym -u 'User Name <user@example.com>'
       
    78 echo % status
       
    79 hg status
       
    80 echo % identify
       
    81 hg debugrebuildstate
       
    82 hg --quiet identify
       
    83 echo % cat
       
    84 cat a b
       
    85 echo % hg cat
       
    86 hg cat sym a b
       
    87 
       
    88 echo
       
    89 echo % diff a hooktest
       
    90 diff a hooktest
       
    91 
       
    92 echo % removing commit hook from config
       
    93 sed -e '/\[hooks\]/,$ d' "$HGRCPATH" > $HGRCPATH.nohook
       
    94 mv "$HGRCPATH".nohook "$HGRCPATH"
       
    95 rm hooktest
       
    96 
       
    97 echo % bundle
       
    98 hg bundle --base null ../kw.hg
       
    99 
       
   100 cd ..
       
   101 hg init Test
       
   102 cd Test
       
   103 
       
   104 echo % notify on pull to check whether keywords stay as is in email
       
   105 echo % ie. if patch.diff wrapper acts as it should
       
   106 
       
   107 cat <<EOF >> $HGRCPATH
       
   108 [hooks]
       
   109 incoming.notify = python:hgext.notify.hook
       
   110 [notify]
       
   111 sources = pull
       
   112 diffstat = False
       
   113 [reposubs]
       
   114 * = Test
       
   115 EOF
       
   116 
       
   117 echo % pull from bundle
       
   118 hg pull -u ../kw.hg 2>&1 | sed -e '/^Content-Type:/,/^diffs (/ d'
       
   119 
       
   120 echo % remove notify config
       
   121 sed -e '/\[hooks\]/,$ d' "$HGRCPATH" > $HGRCPATH.nonotify
       
   122 mv "$HGRCPATH".nonotify "$HGRCPATH"
       
   123 
       
   124 echo % touch
       
   125 touch a b
       
   126 echo % status
       
   127 hg status
       
   128 
       
   129 rm sym a b
       
   130 echo % update
       
   131 hg update -C
       
   132 echo % cat
       
   133 cat a b
       
   134 
       
   135 echo % check whether expansion is filewise
       
   136 echo '$Id$' > c
       
   137 echo 'tests for different changenodes' >> c
       
   138 echo % commit c
       
   139 hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
       
   140 echo % force expansion
       
   141 hg -v kwexpand
       
   142 echo % compare changenodes in a c
       
   143 cat a c
       
   144 
       
   145 echo % record chunk
       
   146 python -c \
       
   147 'l=open("a").readlines();l.insert(1,"foo\n");l.append("bar\n");open("a","w").writelines(l);'
       
   148 hg record -d '1 10' -m rectest<<EOF
       
   149 y
       
   150 y
       
   151 n
       
   152 EOF
       
   153 echo
       
   154 hg identify
       
   155 hg status
       
   156 echo % cat modified file
       
   157 cat a
       
   158 hg diff | grep -v 'b/a'
       
   159 hg rollback
       
   160 
       
   161 echo % record file
       
   162 echo foo > msg
       
   163 # do not use "hg record -m" here!
       
   164 hg record -l msg -d '1 11'<<EOF
       
   165 y
       
   166 y
       
   167 y
       
   168 EOF
       
   169 echo % a should be clean
       
   170 hg status -A a
       
   171 rm msg
       
   172 hg rollback
       
   173 hg update -C
       
   174 
       
   175 echo % init --mq
       
   176 hg init --mq
       
   177 echo % qimport
       
   178 hg qimport -r tip -n mqtest.diff
       
   179 echo % commit --mq
       
   180 hg commit --mq -m mqtest
       
   181 echo % keywords should not be expanded in patch
       
   182 cat .hg/patches/mqtest.diff
       
   183 echo % qpop
       
   184 hg qpop
       
   185 echo % qgoto - should imply qpush
       
   186 hg qgoto mqtest.diff
       
   187 echo % cat
       
   188 cat c
       
   189 echo % hg cat
       
   190 hg cat c
       
   191 echo % keyword should not be expanded in filelog
       
   192 hg --config 'extensions.keyword=!' cat c
       
   193 echo % qpop and move on
       
   194 hg qpop
       
   195 
       
   196 echo % copy
       
   197 hg cp a c
       
   198 
       
   199 echo % kwfiles added
       
   200 hg kwfiles
       
   201 
       
   202 echo % commit
       
   203 hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
       
   204 echo % cat a c
       
   205 cat a c
       
   206 echo % touch copied c
       
   207 touch c
       
   208 echo % status
       
   209 hg status
       
   210 
       
   211 echo % kwfiles
       
   212 hg kwfiles
       
   213 echo % ignored files
       
   214 hg -v kwfiles --ignore
       
   215 echo % all files
       
   216 hg kwfiles --all
       
   217 
       
   218 echo % diff --rev
       
   219 hg diff --rev 1 | grep -v 'b/c'
       
   220 
       
   221 echo % rollback
       
   222 hg rollback
       
   223 echo % status
       
   224 hg status
       
   225 echo % update -C
       
   226 hg update --clean
       
   227 
       
   228 echo % custom keyword expansion
       
   229 echo % try with kwdemo
       
   230 hg --quiet kwdemo "Xinfo = {author}: {desc}"
       
   231 
       
   232 cat <<EOF >>$HGRCPATH
       
   233 [keywordmaps]
       
   234 Id = {file} {node|short} {date|rfc822date} {author|user}
       
   235 Xinfo = {author}: {desc}
       
   236 EOF
       
   237 
       
   238 echo % cat
       
   239 cat a b
       
   240 echo % hg cat
       
   241 hg cat sym a b
       
   242 
       
   243 echo
       
   244 echo '$Xinfo$' >> a
       
   245 cat <<EOF >> log
       
   246 firstline
       
   247 secondline
       
   248 EOF
       
   249 
       
   250 echo % interrupted commit should not change state
       
   251 hg commit
       
   252 echo % status
       
   253 hg status
       
   254 
       
   255 echo % commit
       
   256 hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
       
   257 rm log
       
   258 echo % status
       
   259 hg status
       
   260 echo % verify
       
   261 hg verify
       
   262 
       
   263 echo % cat
       
   264 cat a b
       
   265 echo % hg cat
       
   266 hg cat sym a b
       
   267 echo
       
   268 echo % annotate
       
   269 hg annotate a
       
   270 
       
   271 echo % remove
       
   272 hg debugrebuildstate
       
   273 hg remove a
       
   274 hg --debug commit -m rma
       
   275 echo % status
       
   276 hg status
       
   277 echo % rollback
       
   278 hg rollback
       
   279 echo % status
       
   280 hg status
       
   281 echo % revert a
       
   282 hg revert --no-backup --rev tip a
       
   283 echo % cat a
       
   284 cat a
       
   285 
       
   286 echo % clone
       
   287 cd ..
       
   288 
       
   289 echo % expansion in dest
       
   290 hg --quiet clone Test globalconf
       
   291 cat globalconf/a
       
   292 echo % no expansion in dest
       
   293 hg --quiet --config 'keyword.**=ignore' clone Test localconf
       
   294 cat localconf/a
       
   295 
       
   296 echo % clone to test incoming
       
   297 hg clone -r1 Test Test-a
       
   298 cd Test-a
       
   299 cat <<EOF >> .hg/hgrc
       
   300 [paths]
       
   301 default = ../Test
       
   302 EOF
       
   303 echo % incoming
       
   304 # remove path to temp dir
       
   305 hg incoming | sed -e 's/^\(comparing with \).*\(test-keyword.*\)/\1\2/'
       
   306 
       
   307 sed -e 's/Id.*/& rejecttest/' a > a.new
       
   308 mv a.new a
       
   309 echo % commit rejecttest
       
   310 hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
       
   311 echo % export
       
   312 hg export -o ../rejecttest.diff tip
       
   313 
       
   314 cd ../Test
       
   315 echo % import
       
   316 hg import ../rejecttest.diff
       
   317 echo % cat
       
   318 cat a b
       
   319 echo
       
   320 echo % rollback
       
   321 hg rollback
       
   322 echo % clean update
       
   323 hg update --clean
       
   324 
       
   325 echo % kwexpand/kwshrink on selected files
       
   326 mkdir x
       
   327 echo % copy a x/a
       
   328 hg copy a x/a
       
   329 echo % kwexpand a
       
   330 hg --verbose kwexpand a
       
   331 echo % kwexpand x/a should abort
       
   332 hg --verbose kwexpand x/a
       
   333 cd x
       
   334 hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
       
   335 echo % cat a
       
   336 cat a
       
   337 echo % kwshrink a inside directory x
       
   338 hg --verbose kwshrink a
       
   339 echo % cat a
       
   340 cat a
       
   341 cd ..
       
   342 
       
   343 echo % kwexpand nonexistent
       
   344 hg kwexpand nonexistent 2>&1 | sed 's/nonexistent:.*/nonexistent:/'
       
   345 
       
   346 echo % hg serve
       
   347 hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
       
   348 cat hg.pid >> $DAEMON_PIDS
       
   349 echo % expansion
       
   350 echo % hgweb file
       
   351 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/a/?style=raw')
       
   352 echo % no expansion
       
   353 echo % hgweb annotate
       
   354 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/a/?style=raw')
       
   355 echo % hgweb changeset
       
   356 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/rev/tip/?style=raw')
       
   357 echo % hgweb filediff
       
   358 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/diff/bb948857c743/a?style=raw')
       
   359 echo % errors encountered
       
   360 cat errors.log
       
   361 
       
   362 echo % merge/resolve
       
   363 echo '$Id$' > m
       
   364 hg add m
       
   365 hg commit -m 4kw 
       
   366 echo foo >> m
       
   367 hg commit -m 5foo
       
   368 echo % simplemerge
       
   369 hg update 4
       
   370 echo foo >> m
       
   371 hg commit -m 6foo
       
   372 hg merge
       
   373 hg commit -m simplemerge
       
   374 cat m
       
   375 echo % conflict
       
   376 hg update 4
       
   377 echo bar >> m
       
   378 hg commit -m 8bar
       
   379 hg merge
       
   380 echo % keyword stays outside conflict zone
       
   381 cat m
       
   382 echo % resolve to local
       
   383 HGMERGE=internal:local hg resolve -a
       
   384 hg commit -m localresolve
       
   385 cat m
       
   386 
       
   387 echo % test restricted mode with transplant -b
       
   388 hg update 6
       
   389 hg branch foo
       
   390 mv a a.bak
       
   391 echo foobranch > a
       
   392 cat a.bak >> a
       
   393 rm a.bak
       
   394 hg commit -m 9foobranch
       
   395 hg update default
       
   396 hg -y transplant -b foo tip
       
   397 echo % no expansion in changeset
       
   398 hg tip -p
       
   399 echo % expansion in file
       
   400 head -n 2 a
       
   401 hg -q rollback
       
   402 hg -q update -C
       
   403 
       
   404 echo % switch off expansion
       
   405 echo % kwshrink with unknown file u
       
   406 cp a u
       
   407 hg --verbose kwshrink
       
   408 echo % cat
       
   409 cat a b
       
   410 echo % hg cat
       
   411 hg cat sym a b
       
   412 echo
       
   413 rm "$HGRCPATH"
       
   414 echo % cat
       
   415 cat a b
       
   416 echo % hg cat
       
   417 hg cat sym a b
       
   418 echo