Skip to content
Snippets Groups Projects
test-keyword.t 31.6 KiB
Newer Older
kwshrink a inside directory x

  $ hg --verbose kwshrink a
  overwriting x/a shrinking keywords
  $ cat a
  expand $Id$
  do not process $Id:
  xxx $
  $Xinfo$
  $ cd ..

kwexpand nonexistent

  $ hg kwexpand nonexistent
  nonexistent:* (glob)
hg serve
 - expand with hgweb file
 - no expansion with hgweb annotate/changeset/filediff/comparison
 - check errors

  $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
  $ cat hg.pid >> $DAEMON_PIDS
  $ get-with-headers.py localhost:$HGPORT 'file/tip/a/?style=raw'
  200 Script output follows
  
  expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
  do not process $Id:
  xxx $
  $Xinfo: User Name <user@example.com>: firstline $
  $ get-with-headers.py localhost:$HGPORT 'annotate/tip/a/?style=raw'
  200 Script output follows
  
  
  user@1: expand $Id$
  user@1: do not process $Id:
  user@1: xxx $
  user@2: $Xinfo$
  
  
  
  
  $ get-with-headers.py localhost:$HGPORT 'rev/tip/?style=raw'
  200 Script output follows
  
  
  # HG changeset patch
  # User User Name <user@example.com>
  # Date 3 0
  # Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
  # Parent  bb948857c743469b22bbf51f7ec8112279ca5d83
  xa
  
  diff -r bb948857c743 -r b4560182a3f9 x/a
  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
  +++ b/x/a	Thu Jan 01 00:00:03 1970 +0000
  @@ -0,0 +1,4 @@
  +expand $Id$
  +do not process $Id:
  +xxx $
  +$Xinfo$
  
  $ get-with-headers.py localhost:$HGPORT 'diff/bb948857c743/a?style=raw'
  200 Script output follows
  
  
  diff -r ef63ca68695b -r bb948857c743 a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	Thu Jan 01 00:00:02 1970 +0000
  @@ -1,3 +1,4 @@
   expand $Id$
   do not process $Id:
   xxx $
  +$Xinfo$
  
  
  
  
  $ get-with-headers.py localhost:$HGPORT 'comparison/bb948857c743/a' | grep '\$[a-zA-Z]'
  <td class="source equal"><a href="#l1r1">     1</a> expand $Id$</td>
  <td class="source equal"><a href="#l1r1">     1</a> expand $Id$</td>
  <td class="source equal"><a href="#l2r2">     2</a> do not process $Id:</td>
  <td class="source equal"><a href="#l2r2">     2</a> do not process $Id:</td>
  <td class="source insert"><a href="#r4">     4</a> $Xinfo$</td>

(check "kwweb_skip"-ed webcommand doesn't suppress expanding keywords
at subsequent webcommands)

  $ get-with-headers.py localhost:$HGPORT 'file/tip/a/?style=raw'
  200 Script output follows
  
  expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
  do not process $Id:
  xxx $
  $Xinfo: User Name <user@example.com>: firstline $

  $ cat errors.log

Prepare merge and resolve tests

  $ echo '$Id$' > m
  $ hg add m
  $ echo foo >> m
  $ hg commit -m 5foo

simplemerge

  $ hg update 4
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo foo >> m
  $ hg commit -m 6foo
  created new head
  $ hg merge
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg commit -m simplemerge
  $ cat m
  $Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
  foo

conflict: keyword should stay outside conflict zone

  $ hg update 4
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo bar >> m
  $ hg commit -m 8bar
  created new head
  $ hg merge
  merging m
  warning: conflicts while merging m! (edit, then use 'hg resolve --mark')
  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
  use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
  <<<<<<< working copy: 88a80c8d172e - test: 8bar
  >>>>>>> merge rev:    85d2d2d732a5 - test: simplemerge
resolve to local, m must contain hash of last change (local parent)
  $ hg resolve -t internal:local -a
  $ hg commit -m localresolve
  $ cat m
  $Id: m 88a80c8d172e Thu, 01 Jan 1970 00:00:00 +0000 test $
  bar

Test restricted mode with transplant -b

  $ hg update 6
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg branch foo
  marked working directory as branch foo
Matt Mackall's avatar
Matt Mackall committed
  (branches are permanent and global, did you want a bookmark?)
  $ mv a a.bak
  $ echo foobranch > a
  $ cat a.bak >> a
  $ rm a.bak
  $ hg commit -m 9foobranch
  $ hg update default
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg -y transplant -b foo tip
  applying 4aa30d025d50
  4aa30d025d50 transplanted to e00abbf63521

Expansion in changeset but not in file

  $ hg tip -p
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     9foobranch
  
  diff -r 800511b3a22d -r e00abbf63521 a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,3 +1,4 @@
  +foobranch
   expand $Id$
   do not process $Id:
   xxx $
  
  $ head -n 2 a
  foobranch
  expand $Id: a e00abbf63521 Thu, 01 Jan 1970 00:00:00 +0000 test $
Turn off expansion

  $ hg -q rollback
  $ hg -q update -C

kwshrink with unknown file u

  $ cp a u
  $ hg --verbose kwshrink
  overwriting a shrinking keywords
  overwriting m shrinking keywords
  overwriting x/a shrinking keywords

Keywords shrunk in working directory, but not yet disabled
 - cat shows unexpanded keywords
 - hg cat shows expanded keywords

  $ cat a b
  expand $Id$
  do not process $Id:
  xxx $
  $Xinfo$
  ignore $Id$
  $ hg cat sym a b && echo
  expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
  do not process $Id:
  xxx $
  $Xinfo: User Name <user@example.com>: firstline $
  ignore $Id$

Now disable keyword expansion

  $ rm "$HGRCPATH"
  $ cat a b
  expand $Id$
  do not process $Id:
  xxx $
  $Xinfo$
  ignore $Id$
  $ hg cat sym a b && echo
  expand $Id$
  do not process $Id:
  xxx $
  $Xinfo$
  ignore $Id$
enable keyword expansion again

  $ cat $HGRCPATH.backup >> $HGRCPATH

Test restricted mode with unshelve

  $ echo xxxx >> a
  $ hg diff
  diff -r 800511b3a22d a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	* (glob)
  @@ -2,3 +2,4 @@
   do not process $Id:
   xxx $
   $Xinfo$
  +xxxx
  $ hg shelve -q --name tmp
  $ hg shelve --list --patch
  tmp             (*)* changes to: localresolve (glob)
  
  diff --git a/a b/a
  --- a/a
  +++ b/a
  @@ -2,3 +2,4 @@
   do not process $Id:
   xxx $
   $Xinfo$
  +xxxx

  $ hg update -q -C 10
  $ hg unshelve -q tmp
  $ hg diff
  diff -r 4aa30d025d50 a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	* (glob)
  @@ -3,3 +3,4 @@
   do not process $Id:
   xxx $
   $Xinfo$
  +xxxx

Test restricted mode with rebase

  $ cat <<EOF >> $HGRCPATH
  > [extensions]
  > rebase =
  > EOF

  $ hg update -q -C 9

  $ echo xxxx >> a
  $ hg commit -m '#11'
  $ hg diff -c 11
  diff -r 800511b3a22d -r b07670694489 a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
  @@ -2,3 +2,4 @@
   do not process $Id:
   xxx $
   $Xinfo$
  +xxxx

  $ hg diff -c 10
  diff -r 27d48ee14f67 -r 4aa30d025d50 a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,3 +1,4 @@
  +foobranch
   expand $Id$
   do not process $Id:
   xxx $

  $ hg rebase -q -s 10 -d 11 --keep
  $ hg diff -r 9 -r 12 a
  diff -r 800511b3a22d -r 1939b927726c a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,4 +1,6 @@
  +foobranch
   expand $Id$
   do not process $Id:
   xxx $
   $Xinfo$
  +xxxx

Test restricted mode with graft

  $ hg graft -q 10
  $ hg diff -r 9 -r 13 a
  diff -r 800511b3a22d -r 01a68de1003a a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,4 +1,6 @@
  +foobranch
   expand $Id$
   do not process $Id:
   xxx $
   $Xinfo$
  +xxxx

  $ hg backout -q 11 --no-commit
  $ hg diff a
  diff -r 01a68de1003a a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	* (glob)
  @@ -3,4 +3,3 @@
   do not process $Id:
   xxx $
   $Xinfo$
  -xxxx

Test restricted mode with histedit

  $ cat <<EOF >> $HGRCPATH
  > [extensions]
  > histedit =
  > EOF

  $ hg commit -m 'backout #11'
  $ hg histedit -q --command - 13 <<EOF
  > pick 49f5f2d940c3 14 backout #11
  > pick 01a68de1003a 13 9foobranch
  > EOF

Test restricted mode with fetch (with merge)

  $ cat <<EOF >> $HGRCPATH
  > [extensions]
  > fetch =
  > EOF

  $ hg clone -q -r 9 . ../fetch-merge
  $ cd ../fetch-merge
  $ hg -R ../Test export 10 | hg import -q -
  $ hg fetch -q -r 11
  $ hg diff -r 9 a
  diff -r 800511b3a22d a
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
  +++ b/a	* (glob)
  @@ -1,4 +1,6 @@
  +foobranch
   expand $Id$
   do not process $Id:
   xxx $
   $Xinfo$
  +xxxx

Test that patch.diff(), which is implied by "hg diff" or so, doesn't
suppress expanding keywords at subsequent commands

#if windows
  $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
#else
  $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
#endif
  $ export PYTHONPATH

  $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
  $ mv $HGRCPATH.new $HGRCPATH

  >>> from hgclient import check, readchannel, runcommand
  >>> @check
  ... def check(server):
  ...     # hello block
  ...     readchannel(server)
  ... 
  ...     runcommand(server, [b'cat', b'm'])
  ...     runcommand(server, [b'diff', b'-c', b'.', b'm'])
  ...     runcommand(server, [b'cat', b'm'])
  *** runcommand cat m
  $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
  bar
  *** runcommand diff -c . m
  *** runcommand cat m
  $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
  bar

  $ cd ..

#if serve

Test that keywords are expanded only in repositories, which enable
keyword extension, even if multiple repositories are served in a
process

  $ cat >> fetch-merge/.hg/hgrc <<EOF
  > [extensions]
  > keyword = !
  > EOF

  $ cat > paths.conf <<EOF
  > [paths]
  > enabled=Test
  > disabled=fetch-merge
  > EOF

  $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E error.log --webdir-conf paths.conf
  $ cat hg.pid >> $DAEMON_PIDS

  $ get-with-headers.py localhost:$HGPORT 'enabled/file/tip/m/?style=raw'
  200 Script output follows
  
  $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
  bar

  $ get-with-headers.py localhost:$HGPORT 'disabled/file/tip/m/?style=raw'
  200 Script output follows
  
  $Id$
  bar

(check expansion again, for safety)

  $ get-with-headers.py localhost:$HGPORT 'enabled/file/tip/m/?style=raw'
  200 Script output follows
  
  $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
  bar

  $ killdaemons.py
#endif