##// END OF EJS Templates
merge with crew
Patrick Mezard -
r13652:0652b2da merge default
parent child Browse files
Show More
@@ -169,7 +169,8 b' class eolfile(object):'
169 169 % (style, self.cfg.source('patterns', pattern)))
170 170
171 171 def checkrev(self, repo, ctx, files):
172 for f in files:
172 failed = []
173 for f in (files or ctx.files()):
173 174 if f not in ctx:
174 175 continue
175 176 for pattern, style in self.cfg.items('patterns'):
@@ -177,14 +178,11 b' class eolfile(object):'
177 178 continue
178 179 target = self._encode[style.upper()]
179 180 data = ctx[f].data()
180 if target == "to-lf" and "\r\n" in data:
181 raise util.Abort(_("%s should not have CRLF line endings")
182 % f)
183 elif target == "to-crlf" and singlelf.search(data):
184 raise util.Abort(_("%s should not have LF line endings")
185 % f)
186 # Ignore other rules for this file
181 if (target == "to-lf" and "\r\n" in data
182 or target == "to-crlf" and singlelf.search(data)):
183 failed.append((str(ctx), target, f))
187 184 break
185 return failed
188 186
189 187 def parseeol(ui, repo, nodes):
190 188 try:
@@ -209,17 +207,26 b' def _checkhook(ui, repo, node, headsonly'
209 207 files = set()
210 208 revs = set()
211 209 for rev in xrange(repo[node].rev(), len(repo)):
212 ctx = repo[rev]
213 files.update(ctx.files())
214 210 revs.add(rev)
215 211 if headsonly:
212 ctx = repo[rev]
213 files.update(ctx.files())
216 214 for pctx in ctx.parents():
217 215 revs.discard(pctx.rev())
216 failed = []
218 217 for rev in revs:
219 218 ctx = repo[rev]
220 219 eol = parseeol(ui, repo, [ctx.node()])
221 220 if eol:
222 eol.checkrev(repo, ctx, files)
221 failed.extend(eol.checkrev(repo, ctx, files))
222
223 if failed:
224 eols = {'to-lf': 'CRLF', 'to-crlf': 'LF'}
225 msgs = []
226 for node, target, f in failed:
227 msgs.append(_(" %s in %s should not have %s line endings") %
228 (f, node, eols[target]))
229 raise util.Abort(_("end-of-line check failed:\n") + "\n".join(msgs))
223 230
224 231 def checkallhook(ui, repo, node, hooktype, **kwargs):
225 232 """verify that files have expected EOLs"""
@@ -40,10 +40,12 b' Create repo'
40 40 adding manifests
41 41 adding file changes
42 42 added 1 changesets with 1 changes to 1 files
43 error: pretxnchangegroup hook failed: a.txt should not have CRLF line endings
43 error: pretxnchangegroup hook failed: end-of-line check failed:
44 a.txt in a8ee6548cd86 should not have CRLF line endings
44 45 transaction abort!
45 46 rollback completed
46 abort: a.txt should not have CRLF line endings
47 abort: end-of-line check failed:
48 a.txt in a8ee6548cd86 should not have CRLF line endings
47 49 [255]
48 50
49 51 $ printf "first\nsecond\nthird\n" > a.txt
@@ -66,10 +68,12 b' Create repo'
66 68 adding manifests
67 69 adding file changes
68 70 added 1 changesets with 1 changes to 1 files
69 error: pretxnchangegroup hook failed: crlf.txt should not have LF line endings
71 error: pretxnchangegroup hook failed: end-of-line check failed:
72 crlf.txt in 004ba2132725 should not have LF line endings
70 73 transaction abort!
71 74 rollback completed
72 abort: crlf.txt should not have LF line endings
75 abort: end-of-line check failed:
76 crlf.txt in 004ba2132725 should not have LF line endings
73 77 [255]
74 78
75 79 $ printf "first\r\nsecond\r\nthird\r\n" > crlf.txt
@@ -92,10 +96,12 b' Create repo'
92 96 adding manifests
93 97 adding file changes
94 98 added 1 changesets with 1 changes to 1 files
95 error: pretxnchangegroup hook failed: b.txt should not have CRLF line endings
99 error: pretxnchangegroup hook failed: end-of-line check failed:
100 b.txt in fbcf9b1025f5 should not have CRLF line endings
96 101 transaction abort!
97 102 rollback completed
98 abort: b.txt should not have CRLF line endings
103 abort: end-of-line check failed:
104 b.txt in fbcf9b1025f5 should not have CRLF line endings
99 105 [255]
100 106
101 107 $ hg up -r -2
@@ -111,10 +117,12 b' Create repo'
111 117 adding manifests
112 118 adding file changes
113 119 added 2 changesets with 2 changes to 2 files (+1 heads)
114 error: pretxnchangegroup hook failed: b.txt should not have CRLF line endings
120 error: pretxnchangegroup hook failed: end-of-line check failed:
121 b.txt in fbcf9b1025f5 should not have CRLF line endings
115 122 transaction abort!
116 123 rollback completed
117 abort: b.txt should not have CRLF line endings
124 abort: end-of-line check failed:
125 b.txt in fbcf9b1025f5 should not have CRLF line endings
118 126 [255]
119 127
120 128 Test checkheadshook alias
@@ -130,10 +138,12 b' Test checkheadshook alias'
130 138 adding manifests
131 139 adding file changes
132 140 added 2 changesets with 2 changes to 2 files (+1 heads)
133 error: pretxnchangegroup hook failed: b.txt should not have CRLF line endings
141 error: pretxnchangegroup hook failed: end-of-line check failed:
142 b.txt in fbcf9b1025f5 should not have CRLF line endings
134 143 transaction abort!
135 144 rollback completed
136 abort: b.txt should not have CRLF line endings
145 abort: end-of-line check failed:
146 b.txt in fbcf9b1025f5 should not have CRLF line endings
137 147 [255]
138 148
139 149 We can fix the head and push again
@@ -166,10 +176,12 b' Test it still fails with checkallhook'
166 176 adding manifests
167 177 adding file changes
168 178 added 3 changesets with 3 changes to 2 files (+1 heads)
169 error: pretxnchangegroup hook failed: b.txt should not have CRLF line endings
179 error: pretxnchangegroup hook failed: end-of-line check failed:
180 b.txt in fbcf9b1025f5 should not have CRLF line endings
170 181 transaction abort!
171 182 rollback completed
172 abort: b.txt should not have CRLF line endings
183 abort: end-of-line check failed:
184 b.txt in fbcf9b1025f5 should not have CRLF line endings
173 185 [255]
174 186
175 187 But we can push the clean head
@@ -182,3 +194,24 b' But we can push the clean head'
182 194 adding file changes
183 195 added 1 changesets with 1 changes to 1 files
184 196
197 Test multiple files/revisions output
198
199 $ printf "another\r\nbad\r\none" > d.txt
200 $ hg add d.txt
201 $ hg ci -m "add d.txt"
202 $ hg push -f ../main
203 pushing to ../main
204 searching for changes
205 adding changesets
206 adding manifests
207 adding file changes
208 added 3 changesets with 3 changes to 2 files (+1 heads)
209 error: pretxnchangegroup hook failed: end-of-line check failed:
210 d.txt in a7040e68714f should not have CRLF line endings
211 b.txt in fbcf9b1025f5 should not have CRLF line endings
212 transaction abort!
213 rollback completed
214 abort: end-of-line check failed:
215 d.txt in a7040e68714f should not have CRLF line endings
216 b.txt in fbcf9b1025f5 should not have CRLF line endings
217 [255]
General Comments 0
You need to be logged in to leave comments. Login now