##// END OF EJS Templates
win32text: lowercase warning message
Martin Geisler -
r16932:7985a9e2 default
parent child Browse files
Show More
@@ -1,172 +1,172 b''
1 # win32text.py - LF <-> CRLF/CR translation utilities for Windows/Mac users
1 # win32text.py - LF <-> CRLF/CR translation utilities for Windows/Mac users
2 #
2 #
3 # Copyright 2005, 2007-2009 Matt Mackall <mpm@selenic.com> and others
3 # Copyright 2005, 2007-2009 Matt Mackall <mpm@selenic.com> and others
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 '''perform automatic newline conversion
8 '''perform automatic newline conversion
9
9
10 Deprecation: The win32text extension requires each user to configure
10 Deprecation: The win32text extension requires each user to configure
11 the extension again and again for each clone since the configuration
11 the extension again and again for each clone since the configuration
12 is not copied when cloning.
12 is not copied when cloning.
13
13
14 We have therefore made the ``eol`` as an alternative. The ``eol``
14 We have therefore made the ``eol`` as an alternative. The ``eol``
15 uses a version controlled file for its configuration and each clone
15 uses a version controlled file for its configuration and each clone
16 will therefore use the right settings from the start.
16 will therefore use the right settings from the start.
17
17
18 To perform automatic newline conversion, use::
18 To perform automatic newline conversion, use::
19
19
20 [extensions]
20 [extensions]
21 win32text =
21 win32text =
22 [encode]
22 [encode]
23 ** = cleverencode:
23 ** = cleverencode:
24 # or ** = macencode:
24 # or ** = macencode:
25
25
26 [decode]
26 [decode]
27 ** = cleverdecode:
27 ** = cleverdecode:
28 # or ** = macdecode:
28 # or ** = macdecode:
29
29
30 If not doing conversion, to make sure you do not commit CRLF/CR by accident::
30 If not doing conversion, to make sure you do not commit CRLF/CR by accident::
31
31
32 [hooks]
32 [hooks]
33 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
33 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
34 # or pretxncommit.cr = python:hgext.win32text.forbidcr
34 # or pretxncommit.cr = python:hgext.win32text.forbidcr
35
35
36 To do the same check on a server to prevent CRLF/CR from being
36 To do the same check on a server to prevent CRLF/CR from being
37 pushed or pulled::
37 pushed or pulled::
38
38
39 [hooks]
39 [hooks]
40 pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
40 pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
41 # or pretxnchangegroup.cr = python:hgext.win32text.forbidcr
41 # or pretxnchangegroup.cr = python:hgext.win32text.forbidcr
42 '''
42 '''
43
43
44 from mercurial.i18n import _
44 from mercurial.i18n import _
45 from mercurial.node import short
45 from mercurial.node import short
46 from mercurial import util
46 from mercurial import util
47 import re
47 import re
48
48
49 testedwith = 'internal'
49 testedwith = 'internal'
50
50
51 # regexp for single LF without CR preceding.
51 # regexp for single LF without CR preceding.
52 re_single_lf = re.compile('(^|[^\r])\n', re.MULTILINE)
52 re_single_lf = re.compile('(^|[^\r])\n', re.MULTILINE)
53
53
54 newlinestr = {'\r\n': 'CRLF', '\r': 'CR'}
54 newlinestr = {'\r\n': 'CRLF', '\r': 'CR'}
55 filterstr = {'\r\n': 'clever', '\r': 'mac'}
55 filterstr = {'\r\n': 'clever', '\r': 'mac'}
56
56
57 def checknewline(s, newline, ui=None, repo=None, filename=None):
57 def checknewline(s, newline, ui=None, repo=None, filename=None):
58 # warn if already has 'newline' in repository.
58 # warn if already has 'newline' in repository.
59 # it might cause unexpected eol conversion.
59 # it might cause unexpected eol conversion.
60 # see issue 302:
60 # see issue 302:
61 # http://mercurial.selenic.com/bts/issue302
61 # http://mercurial.selenic.com/bts/issue302
62 if newline in s and ui and filename and repo:
62 if newline in s and ui and filename and repo:
63 ui.warn(_('WARNING: %s already has %s line endings\n'
63 ui.warn(_('WARNING: %s already has %s line endings\n'
64 'and does not need EOL conversion by the win32text plugin.\n'
64 'and does not need EOL conversion by the win32text plugin.\n'
65 'Before your next commit, please reconsider your '
65 'Before your next commit, please reconsider your '
66 'encode/decode settings in \nMercurial.ini or %s.\n') %
66 'encode/decode settings in \nMercurial.ini or %s.\n') %
67 (filename, newlinestr[newline], repo.join('hgrc')))
67 (filename, newlinestr[newline], repo.join('hgrc')))
68
68
69 def dumbdecode(s, cmd, **kwargs):
69 def dumbdecode(s, cmd, **kwargs):
70 checknewline(s, '\r\n', **kwargs)
70 checknewline(s, '\r\n', **kwargs)
71 # replace single LF to CRLF
71 # replace single LF to CRLF
72 return re_single_lf.sub('\\1\r\n', s)
72 return re_single_lf.sub('\\1\r\n', s)
73
73
74 def dumbencode(s, cmd):
74 def dumbencode(s, cmd):
75 return s.replace('\r\n', '\n')
75 return s.replace('\r\n', '\n')
76
76
77 def macdumbdecode(s, cmd, **kwargs):
77 def macdumbdecode(s, cmd, **kwargs):
78 checknewline(s, '\r', **kwargs)
78 checknewline(s, '\r', **kwargs)
79 return s.replace('\n', '\r')
79 return s.replace('\n', '\r')
80
80
81 def macdumbencode(s, cmd):
81 def macdumbencode(s, cmd):
82 return s.replace('\r', '\n')
82 return s.replace('\r', '\n')
83
83
84 def cleverdecode(s, cmd, **kwargs):
84 def cleverdecode(s, cmd, **kwargs):
85 if not util.binary(s):
85 if not util.binary(s):
86 return dumbdecode(s, cmd, **kwargs)
86 return dumbdecode(s, cmd, **kwargs)
87 return s
87 return s
88
88
89 def cleverencode(s, cmd):
89 def cleverencode(s, cmd):
90 if not util.binary(s):
90 if not util.binary(s):
91 return dumbencode(s, cmd)
91 return dumbencode(s, cmd)
92 return s
92 return s
93
93
94 def macdecode(s, cmd, **kwargs):
94 def macdecode(s, cmd, **kwargs):
95 if not util.binary(s):
95 if not util.binary(s):
96 return macdumbdecode(s, cmd, **kwargs)
96 return macdumbdecode(s, cmd, **kwargs)
97 return s
97 return s
98
98
99 def macencode(s, cmd):
99 def macencode(s, cmd):
100 if not util.binary(s):
100 if not util.binary(s):
101 return macdumbencode(s, cmd)
101 return macdumbencode(s, cmd)
102 return s
102 return s
103
103
104 _filters = {
104 _filters = {
105 'dumbdecode:': dumbdecode,
105 'dumbdecode:': dumbdecode,
106 'dumbencode:': dumbencode,
106 'dumbencode:': dumbencode,
107 'cleverdecode:': cleverdecode,
107 'cleverdecode:': cleverdecode,
108 'cleverencode:': cleverencode,
108 'cleverencode:': cleverencode,
109 'macdumbdecode:': macdumbdecode,
109 'macdumbdecode:': macdumbdecode,
110 'macdumbencode:': macdumbencode,
110 'macdumbencode:': macdumbencode,
111 'macdecode:': macdecode,
111 'macdecode:': macdecode,
112 'macencode:': macencode,
112 'macencode:': macencode,
113 }
113 }
114
114
115 def forbidnewline(ui, repo, hooktype, node, newline, **kwargs):
115 def forbidnewline(ui, repo, hooktype, node, newline, **kwargs):
116 halt = False
116 halt = False
117 seen = set()
117 seen = set()
118 # we try to walk changesets in reverse order from newest to
118 # we try to walk changesets in reverse order from newest to
119 # oldest, so that if we see a file multiple times, we take the
119 # oldest, so that if we see a file multiple times, we take the
120 # newest version as canonical. this prevents us from blocking a
120 # newest version as canonical. this prevents us from blocking a
121 # changegroup that contains an unacceptable commit followed later
121 # changegroup that contains an unacceptable commit followed later
122 # by a commit that fixes the problem.
122 # by a commit that fixes the problem.
123 tip = repo['tip']
123 tip = repo['tip']
124 for rev in xrange(len(repo)-1, repo[node].rev()-1, -1):
124 for rev in xrange(len(repo)-1, repo[node].rev()-1, -1):
125 c = repo[rev]
125 c = repo[rev]
126 for f in c.files():
126 for f in c.files():
127 if f in seen or f not in tip or f not in c:
127 if f in seen or f not in tip or f not in c:
128 continue
128 continue
129 seen.add(f)
129 seen.add(f)
130 data = c[f].data()
130 data = c[f].data()
131 if not util.binary(data) and newline in data:
131 if not util.binary(data) and newline in data:
132 if not halt:
132 if not halt:
133 ui.warn(_('Attempt to commit or push text file(s) '
133 ui.warn(_('attempt to commit or push text file(s) '
134 'using %s line endings\n') %
134 'using %s line endings\n') %
135 newlinestr[newline])
135 newlinestr[newline])
136 ui.warn(_('in %s: %s\n') % (short(c.node()), f))
136 ui.warn(_('in %s: %s\n') % (short(c.node()), f))
137 halt = True
137 halt = True
138 if halt and hooktype == 'pretxnchangegroup':
138 if halt and hooktype == 'pretxnchangegroup':
139 crlf = newlinestr[newline].lower()
139 crlf = newlinestr[newline].lower()
140 filter = filterstr[newline]
140 filter = filterstr[newline]
141 ui.warn(_('\nTo prevent this mistake in your local repository,\n'
141 ui.warn(_('\nTo prevent this mistake in your local repository,\n'
142 'add to Mercurial.ini or .hg/hgrc:\n'
142 'add to Mercurial.ini or .hg/hgrc:\n'
143 '\n'
143 '\n'
144 '[hooks]\n'
144 '[hooks]\n'
145 'pretxncommit.%s = python:hgext.win32text.forbid%s\n'
145 'pretxncommit.%s = python:hgext.win32text.forbid%s\n'
146 '\n'
146 '\n'
147 'and also consider adding:\n'
147 'and also consider adding:\n'
148 '\n'
148 '\n'
149 '[extensions]\n'
149 '[extensions]\n'
150 'win32text =\n'
150 'win32text =\n'
151 '[encode]\n'
151 '[encode]\n'
152 '** = %sencode:\n'
152 '** = %sencode:\n'
153 '[decode]\n'
153 '[decode]\n'
154 '** = %sdecode:\n') % (crlf, crlf, filter, filter))
154 '** = %sdecode:\n') % (crlf, crlf, filter, filter))
155 return halt
155 return halt
156
156
157 def forbidcrlf(ui, repo, hooktype, node, **kwargs):
157 def forbidcrlf(ui, repo, hooktype, node, **kwargs):
158 return forbidnewline(ui, repo, hooktype, node, '\r\n', **kwargs)
158 return forbidnewline(ui, repo, hooktype, node, '\r\n', **kwargs)
159
159
160 def forbidcr(ui, repo, hooktype, node, **kwargs):
160 def forbidcr(ui, repo, hooktype, node, **kwargs):
161 return forbidnewline(ui, repo, hooktype, node, '\r', **kwargs)
161 return forbidnewline(ui, repo, hooktype, node, '\r', **kwargs)
162
162
163 def reposetup(ui, repo):
163 def reposetup(ui, repo):
164 if not repo.local():
164 if not repo.local():
165 return
165 return
166 for name, fn in _filters.iteritems():
166 for name, fn in _filters.iteritems():
167 repo.adddatafilter(name, fn)
167 repo.adddatafilter(name, fn)
168
168
169 def extsetup(ui):
169 def extsetup(ui):
170 if ui.configbool('win32text', 'warn', True):
170 if ui.configbool('win32text', 'warn', True):
171 ui.warn(_("win32text is deprecated: "
171 ui.warn(_("win32text is deprecated: "
172 "http://mercurial.selenic.com/wiki/Win32TextExtension\n"))
172 "http://mercurial.selenic.com/wiki/Win32TextExtension\n"))
@@ -1,38 +1,38 b''
1
1
2 $ cat > unix2mac.py <<EOF
2 $ cat > unix2mac.py <<EOF
3 > import sys
3 > import sys
4 >
4 >
5 > for path in sys.argv[1:]:
5 > for path in sys.argv[1:]:
6 > data = file(path, 'rb').read()
6 > data = file(path, 'rb').read()
7 > data = data.replace('\n', '\r')
7 > data = data.replace('\n', '\r')
8 > file(path, 'wb').write(data)
8 > file(path, 'wb').write(data)
9 > EOF
9 > EOF
10 $ cat > print.py <<EOF
10 $ cat > print.py <<EOF
11 > import sys
11 > import sys
12 > print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>'))
12 > print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>'))
13 > EOF
13 > EOF
14 $ hg init
14 $ hg init
15 $ echo '[hooks]' >> .hg/hgrc
15 $ echo '[hooks]' >> .hg/hgrc
16 $ echo 'pretxncommit.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc
16 $ echo 'pretxncommit.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc
17 $ echo 'pretxnchangegroup.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc
17 $ echo 'pretxnchangegroup.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc
18 $ cat .hg/hgrc
18 $ cat .hg/hgrc
19 [hooks]
19 [hooks]
20 pretxncommit.cr = python:hgext.win32text.forbidcr
20 pretxncommit.cr = python:hgext.win32text.forbidcr
21 pretxnchangegroup.cr = python:hgext.win32text.forbidcr
21 pretxnchangegroup.cr = python:hgext.win32text.forbidcr
22
22
23 $ echo hello > f
23 $ echo hello > f
24 $ hg add f
24 $ hg add f
25 $ hg ci -m 1
25 $ hg ci -m 1
26
26
27 $ python unix2mac.py f
27 $ python unix2mac.py f
28 $ hg ci -m 2
28 $ hg ci -m 2
29 Attempt to commit or push text file(s) using CR line endings
29 attempt to commit or push text file(s) using CR line endings
30 in dea860dc51ec: f
30 in dea860dc51ec: f
31 transaction abort!
31 transaction abort!
32 rollback completed
32 rollback completed
33 abort: pretxncommit.cr hook failed
33 abort: pretxncommit.cr hook failed
34 [255]
34 [255]
35 $ hg cat f | python print.py
35 $ hg cat f | python print.py
36 hello<LF>
36 hello<LF>
37 $ cat f | python print.py
37 $ cat f | python print.py
38 hello<CR>
38 hello<CR>
@@ -1,426 +1,426 b''
1
1
2 $ hg init t
2 $ hg init t
3 $ cd t
3 $ cd t
4 $ cat > unix2dos.py <<EOF
4 $ cat > unix2dos.py <<EOF
5 > import sys
5 > import sys
6 >
6 >
7 > for path in sys.argv[1:]:
7 > for path in sys.argv[1:]:
8 > data = file(path, 'rb').read()
8 > data = file(path, 'rb').read()
9 > data = data.replace('\n', '\r\n')
9 > data = data.replace('\n', '\r\n')
10 > file(path, 'wb').write(data)
10 > file(path, 'wb').write(data)
11 > EOF
11 > EOF
12 $ echo '[hooks]' >> .hg/hgrc
12 $ echo '[hooks]' >> .hg/hgrc
13 $ echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
13 $ echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
14 $ echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
14 $ echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
15 $ cat .hg/hgrc
15 $ cat .hg/hgrc
16 [hooks]
16 [hooks]
17 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
17 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
18 pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
18 pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
19
19
20 $ echo hello > f
20 $ echo hello > f
21 $ hg add f
21 $ hg add f
22
22
23 commit should succeed
23 commit should succeed
24
24
25 $ hg ci -m 1
25 $ hg ci -m 1
26
26
27 $ hg clone . ../zoz
27 $ hg clone . ../zoz
28 updating to branch default
28 updating to branch default
29 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
29 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
30 $ cp .hg/hgrc ../zoz/.hg
30 $ cp .hg/hgrc ../zoz/.hg
31 $ python unix2dos.py f
31 $ python unix2dos.py f
32
32
33 commit should fail
33 commit should fail
34
34
35 $ hg ci -m 2.1
35 $ hg ci -m 2.1
36 Attempt to commit or push text file(s) using CRLF line endings
36 attempt to commit or push text file(s) using CRLF line endings
37 in f583ea08d42a: f
37 in f583ea08d42a: f
38 transaction abort!
38 transaction abort!
39 rollback completed
39 rollback completed
40 abort: pretxncommit.crlf hook failed
40 abort: pretxncommit.crlf hook failed
41 [255]
41 [255]
42
42
43 $ mv .hg/hgrc .hg/hgrc.bak
43 $ mv .hg/hgrc .hg/hgrc.bak
44
44
45 commits should succeed
45 commits should succeed
46
46
47 $ hg ci -m 2
47 $ hg ci -m 2
48 $ hg cp f g
48 $ hg cp f g
49 $ hg ci -m 2.2
49 $ hg ci -m 2.2
50
50
51 push should fail
51 push should fail
52
52
53 $ hg push ../zoz
53 $ hg push ../zoz
54 pushing to ../zoz
54 pushing to ../zoz
55 searching for changes
55 searching for changes
56 adding changesets
56 adding changesets
57 adding manifests
57 adding manifests
58 adding file changes
58 adding file changes
59 added 2 changesets with 2 changes to 2 files
59 added 2 changesets with 2 changes to 2 files
60 Attempt to commit or push text file(s) using CRLF line endings
60 attempt to commit or push text file(s) using CRLF line endings
61 in bc2d09796734: g
61 in bc2d09796734: g
62 in b1aa5cde7ff4: f
62 in b1aa5cde7ff4: f
63
63
64 To prevent this mistake in your local repository,
64 To prevent this mistake in your local repository,
65 add to Mercurial.ini or .hg/hgrc:
65 add to Mercurial.ini or .hg/hgrc:
66
66
67 [hooks]
67 [hooks]
68 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
68 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
69
69
70 and also consider adding:
70 and also consider adding:
71
71
72 [extensions]
72 [extensions]
73 win32text =
73 win32text =
74 [encode]
74 [encode]
75 ** = cleverencode:
75 ** = cleverencode:
76 [decode]
76 [decode]
77 ** = cleverdecode:
77 ** = cleverdecode:
78 transaction abort!
78 transaction abort!
79 rollback completed
79 rollback completed
80 abort: pretxnchangegroup.crlf hook failed
80 abort: pretxnchangegroup.crlf hook failed
81 [255]
81 [255]
82
82
83 $ mv .hg/hgrc.bak .hg/hgrc
83 $ mv .hg/hgrc.bak .hg/hgrc
84 $ echo hello > f
84 $ echo hello > f
85 $ hg rm g
85 $ hg rm g
86
86
87 commit should succeed
87 commit should succeed
88
88
89 $ hg ci -m 2.3
89 $ hg ci -m 2.3
90
90
91 push should succeed
91 push should succeed
92
92
93 $ hg push ../zoz
93 $ hg push ../zoz
94 pushing to ../zoz
94 pushing to ../zoz
95 searching for changes
95 searching for changes
96 adding changesets
96 adding changesets
97 adding manifests
97 adding manifests
98 adding file changes
98 adding file changes
99 added 3 changesets with 3 changes to 2 files
99 added 3 changesets with 3 changes to 2 files
100
100
101 and now for something completely different
101 and now for something completely different
102
102
103 $ mkdir d
103 $ mkdir d
104 $ echo hello > d/f2
104 $ echo hello > d/f2
105 $ python unix2dos.py d/f2
105 $ python unix2dos.py d/f2
106 $ hg add d/f2
106 $ hg add d/f2
107 $ hg ci -m 3
107 $ hg ci -m 3
108 Attempt to commit or push text file(s) using CRLF line endings
108 attempt to commit or push text file(s) using CRLF line endings
109 in 053ba1a3035a: d/f2
109 in 053ba1a3035a: d/f2
110 transaction abort!
110 transaction abort!
111 rollback completed
111 rollback completed
112 abort: pretxncommit.crlf hook failed
112 abort: pretxncommit.crlf hook failed
113 [255]
113 [255]
114 $ hg revert -a
114 $ hg revert -a
115 forgetting d/f2 (glob)
115 forgetting d/f2 (glob)
116 $ rm d/f2
116 $ rm d/f2
117
117
118 $ hg rem f
118 $ hg rem f
119 $ hg ci -m 4
119 $ hg ci -m 4
120
120
121 $ python -c 'file("bin", "wb").write("hello\x00\x0D\x0A")'
121 $ python -c 'file("bin", "wb").write("hello\x00\x0D\x0A")'
122 $ hg add bin
122 $ hg add bin
123 $ hg ci -m 5
123 $ hg ci -m 5
124 $ hg log -v
124 $ hg log -v
125 changeset: 5:f0b1c8d75fce
125 changeset: 5:f0b1c8d75fce
126 tag: tip
126 tag: tip
127 user: test
127 user: test
128 date: Thu Jan 01 00:00:00 1970 +0000
128 date: Thu Jan 01 00:00:00 1970 +0000
129 files: bin
129 files: bin
130 description:
130 description:
131 5
131 5
132
132
133
133
134 changeset: 4:77796dbcd4ad
134 changeset: 4:77796dbcd4ad
135 user: test
135 user: test
136 date: Thu Jan 01 00:00:00 1970 +0000
136 date: Thu Jan 01 00:00:00 1970 +0000
137 files: f
137 files: f
138 description:
138 description:
139 4
139 4
140
140
141
141
142 changeset: 3:7c1b5430b350
142 changeset: 3:7c1b5430b350
143 user: test
143 user: test
144 date: Thu Jan 01 00:00:00 1970 +0000
144 date: Thu Jan 01 00:00:00 1970 +0000
145 files: f g
145 files: f g
146 description:
146 description:
147 2.3
147 2.3
148
148
149
149
150 changeset: 2:bc2d09796734
150 changeset: 2:bc2d09796734
151 user: test
151 user: test
152 date: Thu Jan 01 00:00:00 1970 +0000
152 date: Thu Jan 01 00:00:00 1970 +0000
153 files: g
153 files: g
154 description:
154 description:
155 2.2
155 2.2
156
156
157
157
158 changeset: 1:b1aa5cde7ff4
158 changeset: 1:b1aa5cde7ff4
159 user: test
159 user: test
160 date: Thu Jan 01 00:00:00 1970 +0000
160 date: Thu Jan 01 00:00:00 1970 +0000
161 files: f
161 files: f
162 description:
162 description:
163 2
163 2
164
164
165
165
166 changeset: 0:fcf06d5c4e1d
166 changeset: 0:fcf06d5c4e1d
167 user: test
167 user: test
168 date: Thu Jan 01 00:00:00 1970 +0000
168 date: Thu Jan 01 00:00:00 1970 +0000
169 files: f
169 files: f
170 description:
170 description:
171 1
171 1
172
172
173
173
174 $ hg clone . dupe
174 $ hg clone . dupe
175 updating to branch default
175 updating to branch default
176 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
176 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
177
177
178 $ for x in a b c d; do echo content > dupe/$x; done
178 $ for x in a b c d; do echo content > dupe/$x; done
179 $ hg -R dupe add
179 $ hg -R dupe add
180 adding dupe/a (glob)
180 adding dupe/a (glob)
181 adding dupe/b (glob)
181 adding dupe/b (glob)
182 adding dupe/c (glob)
182 adding dupe/c (glob)
183 adding dupe/d (glob)
183 adding dupe/d (glob)
184 $ python unix2dos.py dupe/b dupe/c dupe/d
184 $ python unix2dos.py dupe/b dupe/c dupe/d
185 $ hg -R dupe ci -m a dupe/a
185 $ hg -R dupe ci -m a dupe/a
186 $ hg -R dupe ci -m b/c dupe/[bc]
186 $ hg -R dupe ci -m b/c dupe/[bc]
187 $ hg -R dupe ci -m d dupe/d
187 $ hg -R dupe ci -m d dupe/d
188 $ hg -R dupe log -v
188 $ hg -R dupe log -v
189 changeset: 8:67ac5962ab43
189 changeset: 8:67ac5962ab43
190 tag: tip
190 tag: tip
191 user: test
191 user: test
192 date: Thu Jan 01 00:00:00 1970 +0000
192 date: Thu Jan 01 00:00:00 1970 +0000
193 files: d
193 files: d
194 description:
194 description:
195 d
195 d
196
196
197
197
198 changeset: 7:68c127d1834e
198 changeset: 7:68c127d1834e
199 user: test
199 user: test
200 date: Thu Jan 01 00:00:00 1970 +0000
200 date: Thu Jan 01 00:00:00 1970 +0000
201 files: b c
201 files: b c
202 description:
202 description:
203 b/c
203 b/c
204
204
205
205
206 changeset: 6:adbf8bf7f31d
206 changeset: 6:adbf8bf7f31d
207 user: test
207 user: test
208 date: Thu Jan 01 00:00:00 1970 +0000
208 date: Thu Jan 01 00:00:00 1970 +0000
209 files: a
209 files: a
210 description:
210 description:
211 a
211 a
212
212
213
213
214 changeset: 5:f0b1c8d75fce
214 changeset: 5:f0b1c8d75fce
215 user: test
215 user: test
216 date: Thu Jan 01 00:00:00 1970 +0000
216 date: Thu Jan 01 00:00:00 1970 +0000
217 files: bin
217 files: bin
218 description:
218 description:
219 5
219 5
220
220
221
221
222 changeset: 4:77796dbcd4ad
222 changeset: 4:77796dbcd4ad
223 user: test
223 user: test
224 date: Thu Jan 01 00:00:00 1970 +0000
224 date: Thu Jan 01 00:00:00 1970 +0000
225 files: f
225 files: f
226 description:
226 description:
227 4
227 4
228
228
229
229
230 changeset: 3:7c1b5430b350
230 changeset: 3:7c1b5430b350
231 user: test
231 user: test
232 date: Thu Jan 01 00:00:00 1970 +0000
232 date: Thu Jan 01 00:00:00 1970 +0000
233 files: f g
233 files: f g
234 description:
234 description:
235 2.3
235 2.3
236
236
237
237
238 changeset: 2:bc2d09796734
238 changeset: 2:bc2d09796734
239 user: test
239 user: test
240 date: Thu Jan 01 00:00:00 1970 +0000
240 date: Thu Jan 01 00:00:00 1970 +0000
241 files: g
241 files: g
242 description:
242 description:
243 2.2
243 2.2
244
244
245
245
246 changeset: 1:b1aa5cde7ff4
246 changeset: 1:b1aa5cde7ff4
247 user: test
247 user: test
248 date: Thu Jan 01 00:00:00 1970 +0000
248 date: Thu Jan 01 00:00:00 1970 +0000
249 files: f
249 files: f
250 description:
250 description:
251 2
251 2
252
252
253
253
254 changeset: 0:fcf06d5c4e1d
254 changeset: 0:fcf06d5c4e1d
255 user: test
255 user: test
256 date: Thu Jan 01 00:00:00 1970 +0000
256 date: Thu Jan 01 00:00:00 1970 +0000
257 files: f
257 files: f
258 description:
258 description:
259 1
259 1
260
260
261
261
262 $ hg pull dupe
262 $ hg pull dupe
263 pulling from dupe
263 pulling from dupe
264 searching for changes
264 searching for changes
265 adding changesets
265 adding changesets
266 adding manifests
266 adding manifests
267 adding file changes
267 adding file changes
268 added 3 changesets with 4 changes to 4 files
268 added 3 changesets with 4 changes to 4 files
269 Attempt to commit or push text file(s) using CRLF line endings
269 attempt to commit or push text file(s) using CRLF line endings
270 in 67ac5962ab43: d
270 in 67ac5962ab43: d
271 in 68c127d1834e: b
271 in 68c127d1834e: b
272 in 68c127d1834e: c
272 in 68c127d1834e: c
273
273
274 To prevent this mistake in your local repository,
274 To prevent this mistake in your local repository,
275 add to Mercurial.ini or .hg/hgrc:
275 add to Mercurial.ini or .hg/hgrc:
276
276
277 [hooks]
277 [hooks]
278 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
278 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
279
279
280 and also consider adding:
280 and also consider adding:
281
281
282 [extensions]
282 [extensions]
283 win32text =
283 win32text =
284 [encode]
284 [encode]
285 ** = cleverencode:
285 ** = cleverencode:
286 [decode]
286 [decode]
287 ** = cleverdecode:
287 ** = cleverdecode:
288 transaction abort!
288 transaction abort!
289 rollback completed
289 rollback completed
290 abort: pretxnchangegroup.crlf hook failed
290 abort: pretxnchangegroup.crlf hook failed
291 [255]
291 [255]
292
292
293 $ hg log -v
293 $ hg log -v
294 changeset: 5:f0b1c8d75fce
294 changeset: 5:f0b1c8d75fce
295 tag: tip
295 tag: tip
296 user: test
296 user: test
297 date: Thu Jan 01 00:00:00 1970 +0000
297 date: Thu Jan 01 00:00:00 1970 +0000
298 files: bin
298 files: bin
299 description:
299 description:
300 5
300 5
301
301
302
302
303 changeset: 4:77796dbcd4ad
303 changeset: 4:77796dbcd4ad
304 user: test
304 user: test
305 date: Thu Jan 01 00:00:00 1970 +0000
305 date: Thu Jan 01 00:00:00 1970 +0000
306 files: f
306 files: f
307 description:
307 description:
308 4
308 4
309
309
310
310
311 changeset: 3:7c1b5430b350
311 changeset: 3:7c1b5430b350
312 user: test
312 user: test
313 date: Thu Jan 01 00:00:00 1970 +0000
313 date: Thu Jan 01 00:00:00 1970 +0000
314 files: f g
314 files: f g
315 description:
315 description:
316 2.3
316 2.3
317
317
318
318
319 changeset: 2:bc2d09796734
319 changeset: 2:bc2d09796734
320 user: test
320 user: test
321 date: Thu Jan 01 00:00:00 1970 +0000
321 date: Thu Jan 01 00:00:00 1970 +0000
322 files: g
322 files: g
323 description:
323 description:
324 2.2
324 2.2
325
325
326
326
327 changeset: 1:b1aa5cde7ff4
327 changeset: 1:b1aa5cde7ff4
328 user: test
328 user: test
329 date: Thu Jan 01 00:00:00 1970 +0000
329 date: Thu Jan 01 00:00:00 1970 +0000
330 files: f
330 files: f
331 description:
331 description:
332 2
332 2
333
333
334
334
335 changeset: 0:fcf06d5c4e1d
335 changeset: 0:fcf06d5c4e1d
336 user: test
336 user: test
337 date: Thu Jan 01 00:00:00 1970 +0000
337 date: Thu Jan 01 00:00:00 1970 +0000
338 files: f
338 files: f
339 description:
339 description:
340 1
340 1
341
341
342
342
343 $ rm .hg/hgrc
343 $ rm .hg/hgrc
344 $ (echo some; echo text) > f3
344 $ (echo some; echo text) > f3
345 $ python -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")'
345 $ python -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")'
346 $ hg add f3 f4.bat
346 $ hg add f3 f4.bat
347 $ hg ci -m 6
347 $ hg ci -m 6
348 $ cat bin
348 $ cat bin
349 hello\x00\r (esc)
349 hello\x00\r (esc)
350 $ cat f3
350 $ cat f3
351 some
351 some
352 text
352 text
353 $ cat f4.bat
353 $ cat f4.bat
354 rem empty\r (esc)
354 rem empty\r (esc)
355
355
356 $ echo '[extensions]' >> .hg/hgrc
356 $ echo '[extensions]' >> .hg/hgrc
357 $ echo 'win32text = ' >> .hg/hgrc
357 $ echo 'win32text = ' >> .hg/hgrc
358 $ echo '[decode]' >> .hg/hgrc
358 $ echo '[decode]' >> .hg/hgrc
359 $ echo '** = cleverdecode:' >> .hg/hgrc
359 $ echo '** = cleverdecode:' >> .hg/hgrc
360 $ echo '[encode]' >> .hg/hgrc
360 $ echo '[encode]' >> .hg/hgrc
361 $ echo '** = cleverencode:' >> .hg/hgrc
361 $ echo '** = cleverencode:' >> .hg/hgrc
362 $ cat .hg/hgrc
362 $ cat .hg/hgrc
363 [extensions]
363 [extensions]
364 win32text =
364 win32text =
365 [decode]
365 [decode]
366 ** = cleverdecode:
366 ** = cleverdecode:
367 [encode]
367 [encode]
368 ** = cleverencode:
368 ** = cleverencode:
369
369
370 Trigger deprecation warning:
370 Trigger deprecation warning:
371
371
372 $ hg id -t
372 $ hg id -t
373 win32text is deprecated: http://mercurial.selenic.com/wiki/Win32TextExtension
373 win32text is deprecated: http://mercurial.selenic.com/wiki/Win32TextExtension
374 tip
374 tip
375
375
376 Disable warning:
376 Disable warning:
377
377
378 $ echo '[win32text]' >> .hg/hgrc
378 $ echo '[win32text]' >> .hg/hgrc
379 $ echo 'warn = no' >> .hg/hgrc
379 $ echo 'warn = no' >> .hg/hgrc
380 $ hg id -t
380 $ hg id -t
381 tip
381 tip
382
382
383 $ rm f3 f4.bat bin
383 $ rm f3 f4.bat bin
384 $ hg co -C
384 $ hg co -C
385 WARNING: f4.bat already has CRLF line endings
385 WARNING: f4.bat already has CRLF line endings
386 and does not need EOL conversion by the win32text plugin.
386 and does not need EOL conversion by the win32text plugin.
387 Before your next commit, please reconsider your encode/decode settings in
387 Before your next commit, please reconsider your encode/decode settings in
388 Mercurial.ini or $TESTTMP/t/.hg/hgrc. (glob)
388 Mercurial.ini or $TESTTMP/t/.hg/hgrc. (glob)
389 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
389 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
390 $ cat bin
390 $ cat bin
391 hello\x00\r (esc)
391 hello\x00\r (esc)
392 $ cat f3
392 $ cat f3
393 some\r (esc)
393 some\r (esc)
394 text\r (esc)
394 text\r (esc)
395 $ cat f4.bat
395 $ cat f4.bat
396 rem empty\r (esc)
396 rem empty\r (esc)
397
397
398 $ python -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")'
398 $ python -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")'
399 $ hg add f5.sh
399 $ hg add f5.sh
400 $ hg ci -m 7
400 $ hg ci -m 7
401 $ cat f5.sh
401 $ cat f5.sh
402 # empty\r (esc)
402 # empty\r (esc)
403 $ hg cat f5.sh
403 $ hg cat f5.sh
404 # empty
404 # empty
405 $ echo '% just linefeed' > linefeed
405 $ echo '% just linefeed' > linefeed
406 $ hg ci -qAm 8 linefeed
406 $ hg ci -qAm 8 linefeed
407 $ cat linefeed
407 $ cat linefeed
408 % just linefeed
408 % just linefeed
409 $ hg cat linefeed
409 $ hg cat linefeed
410 % just linefeed
410 % just linefeed
411 $ hg st -q
411 $ hg st -q
412 $ hg revert -a linefeed
412 $ hg revert -a linefeed
413 no changes needed to linefeed
413 no changes needed to linefeed
414 $ cat linefeed
414 $ cat linefeed
415 % just linefeed
415 % just linefeed
416 $ hg st -q
416 $ hg st -q
417 $ echo modified >> linefeed
417 $ echo modified >> linefeed
418 $ hg st -q
418 $ hg st -q
419 M linefeed
419 M linefeed
420 $ hg revert -a
420 $ hg revert -a
421 reverting linefeed
421 reverting linefeed
422 $ hg st -q
422 $ hg st -q
423 $ cat linefeed
423 $ cat linefeed
424 % just linefeed\r (esc)
424 % just linefeed\r (esc)
425
425
426 $ cd ..
426 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now