annotate tests/test-win32text @ 5675:a5fe27b83a4a

Issue 882: add standard hook to reject text files with CRLF. While the win32text extension does LF <-> CRLF conversion, and will issue a warning in case a file already in the repository uses CRLF, it provides no mechanism for verifying that incoming changes use LF. In a large development team with some Windows users, it is virtually guaranteed that someone will forget to set up the encode filter correctly and accidentally check in a file using CRLF, which can cause warnings for other Windows users when they next fetch changes. Since this is a general problem it is desirable to have a pre-commit (or -push) hook available to reject such accidents earlier rather than trying to fix them up after the fact.
author Jesse Glick <jesse.glick@sun.com>
date Wed, 19 Dec 2007 17:02:31 -0500
parents
children 963c516bb38c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5675
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
1 #!/bin/sh
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
2
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
3 hg init
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
4 echo '[hooks]' >> .hg/hgrc
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
5 echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
6 echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
7 cat .hg/hgrc
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
8 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
9
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
10 echo hello > f
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
11 hg add f
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
12 hg ci -m 1 -d'0 0'
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
13 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
14
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
15 unix2dos f
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
16 hg ci -m 2 -d'0 0'
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
17 hg revert -a
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
18 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
19
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
20 mkdir d
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
21 echo hello > d/f2
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
22 unix2dos d/f2
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
23 hg add d/f2
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
24 hg ci -m 3 -d'0 0'
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
25 hg revert -a
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
26 rm d/f2
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
27 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
28
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
29 hg rem f
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
30 hg ci -m 4 -d'0 0'
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
31 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
32
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
33 printf 'hello\x00\x0D\x0A' > bin
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
34 hg add bin
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
35 hg ci -m 5 -d'0 0'
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
36 hg log -v
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
37 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
38
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
39 hg clone . dupe
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
40 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
41 for x in a b c d; do echo content > dupe/$x; done
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
42 hg -R dupe add
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
43 unix2dos dupe/b dupe/c dupe/d
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
44 hg -R dupe ci -m a -d'0 0' dupe/a
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
45 hg -R dupe ci -m b/c -d'0 0' dupe/[bc]
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
46 hg -R dupe ci -m d -d'0 0' dupe/d
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
47 hg -R dupe log -v
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
48 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
49
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
50 hg pull dupe
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
51 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
52
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
53 hg log -v
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
54 echo
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
55
a5fe27b83a4a Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff changeset
56 # XXX missing tests for encode/decode hooks