##// END OF EJS Templates
eol: make the hook check all new heads, not only tip (issue2666)...
Patrick Mezard -
r13616:e6f93ca9 default
parent child Browse files
Show More
@@ -202,13 +202,20 b' def parseeol(ui, repo, nodes):'
202
202
203 def hook(ui, repo, node, hooktype, **kwargs):
203 def hook(ui, repo, node, hooktype, **kwargs):
204 """verify that files have expected EOLs"""
204 """verify that files have expected EOLs"""
205 # Extract heads and get touched files set at the same time
205 files = set()
206 files = set()
207 heads = set()
206 for rev in xrange(repo[node].rev(), len(repo)):
208 for rev in xrange(repo[node].rev(), len(repo)):
207 files.update(repo[rev].files())
209 ctx = repo[rev]
208 tip = repo['tip']
210 files.update(ctx.files())
209 eol = parseeol(ui, repo, [tip.node()])
211 heads.add(rev)
210 if eol:
212 for pctx in ctx.parents():
211 eol.checkrev(repo, tip, files)
213 heads.discard(pctx.rev())
214 for rev in heads:
215 ctx = repo[rev]
216 eol = parseeol(ui, repo, [ctx.node()])
217 if eol:
218 eol.checkrev(repo, ctx, files)
212
219
213 def preupdate(ui, repo, hooktype, parent1, parent2):
220 def preupdate(ui, repo, hooktype, parent1, parent2):
214 #print "preupdate for %s: %s -> %s" % (repo.root, parent1, parent2)
221 #print "preupdate for %s: %s -> %s" % (repo.root, parent1, parent2)
@@ -81,3 +81,38 b' Create repo'
81 adding manifests
81 adding manifests
82 adding file changes
82 adding file changes
83 added 2 changesets with 2 changes to 1 files
83 added 2 changesets with 2 changes to 1 files
84
85 $ printf "first\r\nsecond" > b.txt
86 $ hg add b.txt
87 $ hg commit -m 'CRLF b.txt'
88 $ hg push ../main
89 pushing to ../main
90 searching for changes
91 adding changesets
92 adding manifests
93 adding file changes
94 added 1 changesets with 1 changes to 1 files
95 error: pretxnchangegroup hook failed: b.txt should not have CRLF line endings
96 transaction abort!
97 rollback completed
98 abort: b.txt should not have CRLF line endings
99 [255]
100
101 $ hg up -r -2
102 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
103 $ printf "some\nother\nfile" > c.txt
104 $ hg add c.txt
105 $ hg commit -m "LF c.txt, b.txt doesn't exist here"
106 created new head
107 $ hg push -f ../main
108 pushing to ../main
109 searching for changes
110 adding changesets
111 adding manifests
112 adding file changes
113 added 2 changesets with 2 changes to 2 files (+1 heads)
114 error: pretxnchangegroup hook failed: b.txt should not have CRLF line endings
115 transaction abort!
116 rollback completed
117 abort: b.txt should not have CRLF line endings
118 [255]
General Comments 0
You need to be logged in to leave comments. Login now