##// END OF EJS Templates
simplemerge: let extension check for binary inputs (unless `--text`)...
Martin von Zweigbergk -
r49596:109fec7b default
parent child Browse files
Show More
@@ -64,6 +64,17 b' def showhelp():'
64 procutil.stdout.write(b' %-*s %s\n' % (opts_len, first, second))
64 procutil.stdout.write(b' %-*s %s\n' % (opts_len, first, second))
65
65
66
66
67 def _verifytext(input, ui, quiet=False, allow_binary=False):
68 """verifies that text is non-binary (unless opts[text] is passed,
69 then we just warn)"""
70 if stringutil.binary(input.text()):
71 msg = _(b"%s looks like a binary file.") % input.fctx.path()
72 if not quiet:
73 ui.warn(_(b'warning: %s\n') % msg)
74 if not allow_binary:
75 sys.exit(1)
76
77
67 try:
78 try:
68 for fp in (sys.stdin, procutil.stdout, sys.stderr):
79 for fp in (sys.stdin, procutil.stdout, sys.stderr):
69 procutil.setbinary(fp)
80 procutil.setbinary(fp)
@@ -97,15 +108,23 b' try:'
97 base_input = simplemerge.MergeInput(
108 base_input = simplemerge.MergeInput(
98 context.arbitraryfilectx(base), labels[2]
109 context.arbitraryfilectx(base), labels[2]
99 )
110 )
111
112 quiet = opts.get(b'quiet')
113 allow_binary = opts.get(b'text')
114 ui = uimod.ui.load()
115 _verifytext(local_input, ui, quiet=quiet, allow_binary=allow_binary)
116 _verifytext(base_input, ui, quiet=quiet, allow_binary=allow_binary)
117 _verifytext(other_input, ui, quiet=quiet, allow_binary=allow_binary)
118
100 sys.exit(
119 sys.exit(
101 simplemerge.simplemerge(
120 simplemerge.simplemerge(
102 uimod.ui.load(),
121 ui,
103 local_input,
122 local_input,
104 base_input,
123 base_input,
105 other_input,
124 other_input,
106 mode,
125 mode,
107 quiet=opts.get(b'quiet'),
126 quiet=True,
108 allow_binary=opts.get(b'text'),
127 allow_binary=allow_binary,
109 print_result=opts.get(b'print'),
128 print_result=opts.get(b'print'),
110 )
129 )
111 )
130 )
General Comments 0
You need to be logged in to leave comments. Login now