tests/test-custom-filters
author Dirkjan Ochtman <dirkjan@ochtman.nl>
Thu, 28 Feb 2008 19:08:04 +0100
changeset 6182 07f2236c4dee
parent 6066 f3a8b5360100
child 8742 a964ab624385
permissions -rwxr-xr-x
add a blame alias for annotate The original cvs command was called blame. SVN has both, and other VC systems typically also have this as an alias. Makes things easier for converts.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6066
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
     1
#!/bin/sh
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
     2
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
     3
hg init
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
     4
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
     5
cat > .hg/hgrc <<EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
     6
[extensions]
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
     7
prefixfilter = prefix.py
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
     8
[encode]
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
     9
*.txt = stripprefix: Copyright 2046, The Masters
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    10
[decode]
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    11
*.txt = insertprefix: Copyright 2046, The Masters
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    12
EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    13
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    14
cat > prefix.py <<EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    15
from mercurial import util
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    16
def stripprefix(s, cmd, filename, **kwargs):
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    17
    header = '%s\n' % cmd
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    18
    if s[:len(header)] != header:
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    19
        raise util.Abort('missing header "%s" in %s' % (cmd, filename))
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    20
    return s[len(header):]
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    21
def insertprefix(s, cmd):
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    22
    return '%s\n%s' % (cmd, s)
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    23
def reposetup(ui, repo):
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    24
    repo.adddatafilter('stripprefix:', stripprefix)
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    25
    repo.adddatafilter('insertprefix:', insertprefix)
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    26
EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    27
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    28
cat > .hgignore <<EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    29
.hgignore
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    30
prefix.py
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    31
prefix.pyc
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    32
EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    33
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    34
cat > stuff.txt <<EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    35
Copyright 2046, The Masters
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    36
Some stuff to ponder very carefully.
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    37
EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    38
hg add stuff.txt
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    39
hg ci -m stuff
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    40
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    41
echo '% Repository data:'
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    42
hg cat stuff.txt
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    43
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    44
echo '% Fresh checkout:'
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    45
rm stuff.txt
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    46
hg up
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    47
cat stuff.txt
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    48
echo >> stuff.txt <<EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    49
Very very carefully.
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    50
EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    51
hg stat
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    52
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    53
cat > morestuff.txt <<EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    54
Unauthorized material subject to destruction.
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    55
EOF
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    56
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    57
echo '% Problem encoding:'
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    58
hg add morestuff.txt
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    59
hg ci -m morestuff
f3a8b5360100 Strip filter name from command before passing to filter function.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
    60
hg stat