Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 43155:a83c9c79b722
py3: only flush before prompting during interactive patch filtering
Follows up on c9093ae8d6c4. It's enough to flush just before each
prompt.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Thu, 10 Oct 2019 10:03:01 +0200 |
parents | c9093ae8d6c4 |
children | 0e6a7ce81dde |
comparison
equal
deleted
inserted
replaced
43154:f05d10ef42e3 | 43155:a83c9c79b722 |
---|---|
1181 if skipall is not None: | 1181 if skipall is not None: |
1182 return skipall, skipfile, skipall, newpatches | 1182 return skipall, skipfile, skipall, newpatches |
1183 if skipfile is not None: | 1183 if skipfile is not None: |
1184 return skipfile, skipfile, skipall, newpatches | 1184 return skipfile, skipfile, skipall, newpatches |
1185 while True: | 1185 while True: |
1186 ui.flush() | |
1186 resps = messages[b'help'][operation] | 1187 resps = messages[b'help'][operation] |
1187 # IMPORTANT: keep the last line of this prompt short (<40 english | 1188 # IMPORTANT: keep the last line of this prompt short (<40 english |
1188 # chars is a good target) because of issue6158. | 1189 # chars is a good target) because of issue6158. |
1189 r = ui.promptchoice(b"%s\n(enter ? for help) %s" % (query, resps)) | 1190 r = ui.promptchoice(b"%s\n(enter ? for help) %s" % (query, resps)) |
1190 ui.write(b"\n") | 1191 ui.write(b"\n") |
1191 ui.flush() | |
1192 if r == 8: # ? | 1192 if r == 8: # ? |
1193 for c, t in ui.extractchoices(resps)[1]: | 1193 for c, t in ui.extractchoices(resps)[1]: |
1194 ui.write(b'%s - %s\n' % (c, encoding.lower(t))) | 1194 ui.write(b'%s - %s\n' % (c, encoding.lower(t))) |
1195 ui.flush() | |
1196 continue | 1195 continue |
1197 elif r == 0: # yes | 1196 elif r == 0: # yes |
1198 ret = True | 1197 ret = True |
1199 elif r == 1: # no | 1198 elif r == 1: # no |
1200 ret = False | 1199 ret = False |
1201 elif r == 2: # Edit patch | 1200 elif r == 2: # Edit patch |
1202 if chunk is None: | 1201 if chunk is None: |
1203 ui.write(_(b'cannot edit patch for whole file')) | 1202 ui.write(_(b'cannot edit patch for whole file')) |
1204 ui.write(b"\n") | 1203 ui.write(b"\n") |
1205 ui.flush() | |
1206 continue | 1204 continue |
1207 if chunk.header.binary(): | 1205 if chunk.header.binary(): |
1208 ui.write(_(b'cannot edit patch for binary file')) | 1206 ui.write(_(b'cannot edit patch for binary file')) |
1209 ui.write(b"\n") | 1207 ui.write(b"\n") |
1210 ui.flush() | |
1211 continue | 1208 continue |
1212 # Patch comment based on the Git one (based on comment at end of | 1209 # Patch comment based on the Git one (based on comment at end of |
1213 # https://mercurial-scm.org/wiki/RecordExtension) | 1210 # https://mercurial-scm.org/wiki/RecordExtension) |
1214 phelp = b'---' + _( | 1211 phelp = b'---' + _( |
1215 """ | 1212 """ |
1306 applied[h.filename()] += h.hunks | 1303 applied[h.filename()] += h.hunks |
1307 continue | 1304 continue |
1308 for i, chunk in enumerate(h.hunks): | 1305 for i, chunk in enumerate(h.hunks): |
1309 if skipfile is None and skipall is None: | 1306 if skipfile is None and skipall is None: |
1310 chunk.pretty(ui) | 1307 chunk.pretty(ui) |
1311 ui.flush() | |
1312 if total == 1: | 1308 if total == 1: |
1313 msg = messages[b'single'][operation] % chunk.filename() | 1309 msg = messages[b'single'][operation] % chunk.filename() |
1314 else: | 1310 else: |
1315 idx = pos - len(h.hunks) + i | 1311 idx = pos - len(h.hunks) + i |
1316 msg = messages[b'multiple'][operation] % ( | 1312 msg = messages[b'multiple'][operation] % ( |