##// 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
1 $ hg init
2
2
3 hg init
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
4
11
5 cat > .hg/hgrc <<EOF
12 $ cat > prefix.py <<EOF
6 [extensions]
13 > from mercurial import util
7 prefixfilter = prefix.py
14 > def stripprefix(s, cmd, filename, **kwargs):
8 [encode]
15 > header = '%s\n' % cmd
9 *.txt = stripprefix: Copyright 2046, The Masters
16 > if s[:len(header)] != header:
10 [decode]
17 > raise util.Abort('missing header "%s" in %s' % (cmd, filename))
11 *.txt = insertprefix: Copyright 2046, The Masters
18 > return s[len(header):]
12 EOF
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
13
25
14 cat > prefix.py <<EOF
26 $ cat > .hgignore <<EOF
15 from mercurial import util
27 > .hgignore
16 def stripprefix(s, cmd, filename, **kwargs):
28 > prefix.py
17 header = '%s\n' % cmd
29 > prefix.pyc
18 if s[:len(header)] != header:
30 > EOF
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
27
31
28 cat > .hgignore <<EOF
32 $ cat > stuff.txt <<EOF
29 .hgignore
33 > Copyright 2046, The Masters
30 prefix.py
34 > Some stuff to ponder very carefully.
31 prefix.pyc
35 > EOF
32 EOF
36 $ hg add stuff.txt
37 $ hg ci -m stuff
38
39 Repository data:
33
40
34 cat > stuff.txt <<EOF
41 $ hg cat stuff.txt
42 Some stuff to ponder very carefully.
43
44 Fresh checkout:
45
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
35 Copyright 2046, The Masters
50 Copyright 2046, The Masters
36 Some stuff to ponder very carefully.
51 Some stuff to ponder very carefully.
37 EOF
52 $ echo >> stuff.txt <<EOF
38 hg add stuff.txt
53 > Very very carefully.
39 hg ci -m stuff
54 > EOF
40
55 $ hg stat
41 echo '% Repository data:'
56 M stuff.txt
42 hg cat stuff.txt
43
57
44 echo '% Fresh checkout:'
58 $ cat > morestuff.txt <<EOF
45 rm stuff.txt
59 > Unauthorized material subject to destruction.
46 hg up -C
60 > EOF
47 cat stuff.txt
61
48 echo >> stuff.txt <<EOF
62 Problem encoding:
49 Very very carefully.
50 EOF
51 hg stat
52
63
53 cat > morestuff.txt <<EOF
64 $ hg add morestuff.txt
54 Unauthorized material subject to destruction.
65 $ hg ci -m morestuff
55 EOF
66 abort: missing header "Copyright 2046, The Masters" in morestuff.txt
56
67 $ hg stat
57 echo '% Problem encoding:'
68 M stuff.txt
58 hg add morestuff.txt
69 A morestuff.txt
59 hg ci -m morestuff
60 hg stat
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now