Show More
@@ -59,6 +59,29 b' def _picktool(repo, ui, path, binary, sy' | |||
|
59 | 59 | if _findtool(ui, t) and check(t, None, symlink, binary): |
|
60 | 60 | return t |
|
61 | 61 | |
|
62 | def _eoltype(data): | |
|
63 | "Guess the EOL type of a file" | |
|
64 | if '\0' in data: # binary | |
|
65 | return None | |
|
66 | if '\r\n' in data: # Windows | |
|
67 | return '\r\n' | |
|
68 | if '\r' in data: # Old Mac | |
|
69 | return '\r' | |
|
70 | if '\n' in data: # UNIX | |
|
71 | return '\n' | |
|
72 | return None # unknown | |
|
73 | ||
|
74 | def _matcheol(file, origfile): | |
|
75 | "Convert EOL markers in a file to match origfile" | |
|
76 | tostyle = _eoltype(open(origfile, "rb").read()) | |
|
77 | if tostyle: | |
|
78 | data = open(file, "rb").read() | |
|
79 | style = _eoltype(data) | |
|
80 | if style: | |
|
81 | newdata = data.replace(style, tostyle) | |
|
82 | if newdata != data: | |
|
83 | open(file, "wb").write(newdata) | |
|
84 | ||
|
62 | 85 | def filemerge(repo, fw, fd, fo, wctx, mctx): |
|
63 | 86 | """perform a 3-way merge in the working directory |
|
64 | 87 | |
@@ -158,6 +181,9 b' def filemerge(repo, fw, fd, fo, wctx, mc' | |||
|
158 | 181 | if re.match("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcm.data()): |
|
159 | 182 | r = 1 |
|
160 | 183 | |
|
184 | if _toolbool(ui, tool, "fixeol"): | |
|
185 | _matcheol(repo.join(fd), back) | |
|
186 | ||
|
161 | 187 | if r: |
|
162 | 188 | repo.ui.warn(_("merging %s failed!\n") % fd) |
|
163 | 189 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now