Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
5674:659955e2e366 | 5675:a5fe27b83a4a |
---|---|
1 #!/bin/sh | |
2 | |
3 hg init | |
4 echo '[hooks]' >> .hg/hgrc | |
5 echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc | |
6 echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc | |
7 cat .hg/hgrc | |
8 echo | |
9 | |
10 echo hello > f | |
11 hg add f | |
12 hg ci -m 1 -d'0 0' | |
13 echo | |
14 | |
15 unix2dos f | |
16 hg ci -m 2 -d'0 0' | |
17 hg revert -a | |
18 echo | |
19 | |
20 mkdir d | |
21 echo hello > d/f2 | |
22 unix2dos d/f2 | |
23 hg add d/f2 | |
24 hg ci -m 3 -d'0 0' | |
25 hg revert -a | |
26 rm d/f2 | |
27 echo | |
28 | |
29 hg rem f | |
30 hg ci -m 4 -d'0 0' | |
31 echo | |
32 | |
33 printf 'hello\x00\x0D\x0A' > bin | |
34 hg add bin | |
35 hg ci -m 5 -d'0 0' | |
36 hg log -v | |
37 echo | |
38 | |
39 hg clone . dupe | |
40 echo | |
41 for x in a b c d; do echo content > dupe/$x; done | |
42 hg -R dupe add | |
43 unix2dos dupe/b dupe/c dupe/d | |
44 hg -R dupe ci -m a -d'0 0' dupe/a | |
45 hg -R dupe ci -m b/c -d'0 0' dupe/[bc] | |
46 hg -R dupe ci -m d -d'0 0' dupe/d | |
47 hg -R dupe log -v | |
48 echo | |
49 | |
50 hg pull dupe | |
51 echo | |
52 | |
53 hg log -v | |
54 echo | |
55 | |
56 # XXX missing tests for encode/decode hooks |