equal
deleted
inserted
replaced
97 'macencode:': macencode, |
97 'macencode:': macencode, |
98 } |
98 } |
99 |
99 |
100 def forbidnewline(ui, repo, hooktype, node, newline, **kwargs): |
100 def forbidnewline(ui, repo, hooktype, node, newline, **kwargs): |
101 halt = False |
101 halt = False |
102 for rev in xrange(repo[node].rev(), len(repo)): |
102 seen = util.set() |
|
103 # we try to walk changesets in reverse order from newest to |
|
104 # oldest, so that if we see a file multiple times, we take the |
|
105 # newest version as canonical. this prevents us from blocking a |
|
106 # changegroup that contains an unacceptable commit followed later |
|
107 # by a commit that fixes the problem. |
|
108 tip = repo['tip'] |
|
109 for rev in xrange(len(repo)-1, repo[node].rev()-1, -1): |
103 c = repo[rev] |
110 c = repo[rev] |
104 for f in c.files(): |
111 for f in c.files(): |
105 if f not in c: |
112 if f in seen or f not in tip or f not in c: |
106 continue |
113 continue |
|
114 seen.add(f) |
107 data = c[f].data() |
115 data = c[f].data() |
108 if not util.binary(data) and newline in data: |
116 if not util.binary(data) and newline in data: |
109 if not halt: |
117 if not halt: |
110 ui.warn(_('Attempt to commit or push text file(s) ' |
118 ui.warn(_('Attempt to commit or push text file(s) ' |
111 'using %s line endings\n') % |
119 'using %s line endings\n') % |