##// END OF EJS Templates
tests: unify test-custom-filters
Nicolas Dumazet -
r12124:7edda6c7 default
parent child Browse files
Show More
@@ -1,60 +1,69 b''
1 #!/bin/sh
2
3 hg init
1 $ hg init
4 2
5 cat > .hg/hgrc <<EOF
6 [extensions]
7 prefixfilter = prefix.py
8 [encode]
9 *.txt = stripprefix: Copyright 2046, The Masters
10 [decode]
11 *.txt = insertprefix: Copyright 2046, The Masters
12 EOF
3 $ cat > .hg/hgrc <<EOF
4 > [extensions]
5 > prefixfilter = prefix.py
6 > [encode]
7 > *.txt = stripprefix: Copyright 2046, The Masters
8 > [decode]
9 > *.txt = insertprefix: Copyright 2046, The Masters
10 > EOF
13 11
14 cat > prefix.py <<EOF
15 from mercurial import util
16 def stripprefix(s, cmd, filename, **kwargs):
17 header = '%s\n' % cmd
18 if s[:len(header)] != header:
19 raise util.Abort('missing header "%s" in %s' % (cmd, filename))
20 return s[len(header):]
21 def insertprefix(s, cmd):
22 return '%s\n%s' % (cmd, s)
23 def reposetup(ui, repo):
24 repo.adddatafilter('stripprefix:', stripprefix)
25 repo.adddatafilter('insertprefix:', insertprefix)
26 EOF
12 $ cat > prefix.py <<EOF
13 > from mercurial import util
14 > def stripprefix(s, cmd, filename, **kwargs):
15 > header = '%s\n' % cmd
16 > if s[:len(header)] != header:
17 > raise util.Abort('missing header "%s" in %s' % (cmd, filename))
18 > return s[len(header):]
19 > def insertprefix(s, cmd):
20 > return '%s\n%s' % (cmd, s)
21 > def reposetup(ui, repo):
22 > repo.adddatafilter('stripprefix:', stripprefix)
23 > repo.adddatafilter('insertprefix:', insertprefix)
24 > EOF
25
26 $ cat > .hgignore <<EOF
27 > .hgignore
28 > prefix.py
29 > prefix.pyc
30 > EOF
27 31
28 cat > .hgignore <<EOF
29 .hgignore
30 prefix.py
31 prefix.pyc
32 EOF
32 $ cat > stuff.txt <<EOF
33 > Copyright 2046, The Masters
34 > Some stuff to ponder very carefully.
35 > EOF
36 $ hg add stuff.txt
37 $ hg ci -m stuff
33 38
34 cat > stuff.txt <<EOF
35 Copyright 2046, The Masters
36 Some stuff to ponder very carefully.
37 EOF
38 hg add stuff.txt
39 hg ci -m stuff
39 Repository data:
40 40
41 echo '% Repository data:'
42 hg cat stuff.txt
41 $ hg cat stuff.txt
42 Some stuff to ponder very carefully.
43
44 Fresh checkout:
43 45
44 echo '% Fresh checkout:'
45 rm stuff.txt
46 hg up -C
47 cat stuff.txt
48 echo >> stuff.txt <<EOF
49 Very very carefully.
50 EOF
51 hg stat
46 $ rm stuff.txt
47 $ hg up -C
48 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
49 $ cat stuff.txt
50 Copyright 2046, The Masters
51 Some stuff to ponder very carefully.
52 $ echo >> stuff.txt <<EOF
53 > Very very carefully.
54 > EOF
55 $ hg stat
56 M stuff.txt
52 57
53 cat > morestuff.txt <<EOF
54 Unauthorized material subject to destruction.
55 EOF
58 $ cat > morestuff.txt <<EOF
59 > Unauthorized material subject to destruction.
60 > EOF
61
62 Problem encoding:
56 63
57 echo '% Problem encoding:'
58 hg add morestuff.txt
59 hg ci -m morestuff
60 hg stat
64 $ hg add morestuff.txt
65 $ hg ci -m morestuff
66 abort: missing header "Copyright 2046, The Masters" in morestuff.txt
67 $ hg stat
68 M stuff.txt
69 A morestuff.txt
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now