tests/test-custom-filters
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
Wed, 18 Nov 2009 12:47:58 +0100
changeset 9881 54b518fc6671
parent 8742 a964ab624385
permissions -rwxr-xr-x
httprepo: suppress the `real URL is...' message in safe, common cases. When the actual and requested URL only differ by trailing slashes, there is no need to warn. As an example, this easily happens when accessing repositories on Bitbucket over HTTP(S). As far as I could tell, there were no existing tests for this behaviour.
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
8742
a964ab624385 merge: allow merging going backwards
Matt Mackall <mpm@selenic.com>
parents: 6066
diff changeset
    46
hg up -C
6066
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