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