Show More
@@ -291,25 +291,28 b' def filterpatch(ui, chunks):' | |||||
291 | _('Record &all changes to all remaining files'), |
|
291 | _('Record &all changes to all remaining files'), | |
292 | _('&Quit, recording no changes'), |
|
292 | _('&Quit, recording no changes'), | |
293 | _('&?')) |
|
293 | _('&?')) | |
294 |
r = |
|
294 | r = ui.promptchoice("%s %s " % (query, resps), choices) | |
295 | or _('y')).lower() |
|
295 | if r == 7: # ? | |
296 | if r == _('?'): |
|
|||
297 | doc = gettext(record.__doc__) |
|
296 | doc = gettext(record.__doc__) | |
298 | c = doc.find(_('y - record this change')) |
|
297 | c = doc.find(_('y - record this change')) | |
299 | for l in doc[c:].splitlines(): |
|
298 | for l in doc[c:].splitlines(): | |
300 | if l: ui.write(l.strip(), '\n') |
|
299 | if l: ui.write(l.strip(), '\n') | |
301 | continue |
|
300 | continue | |
302 |
elif r == |
|
301 | elif r == 0: # yes | |
303 |
r |
|
302 | ret = 'y' | |
304 |
elif r == |
|
303 | elif r == 1: # no | |
305 |
r |
|
304 | ret = 'n' | |
306 |
elif r == |
|
305 | elif r == 2: # Skip | |
307 |
r = resp_ |
|
306 | ret = resp_file[0] = 'n' | |
308 |
elif r == |
|
307 | elif r == 3: # file (Record remaining) | |
309 |
r = resp_ |
|
308 | ret = resp_file[0] = 'y' | |
310 |
elif r == |
|
309 | elif r == 4: # done, skip remaining | |
|
310 | ret = resp_all[0] = 'n' | |||
|
311 | elif r == 5: # all | |||
|
312 | ret = resp_all[0] = 'y' | |||
|
313 | elif r == 6: # quit | |||
311 | raise util.Abort(_('user quit')) |
|
314 | raise util.Abort(_('user quit')) | |
312 | return r |
|
315 | return ret | |
313 | pos, total = 0, len(chunks) - 1 |
|
316 | pos, total = 0, len(chunks) - 1 | |
314 | while chunks: |
|
317 | while chunks: | |
315 | chunk = chunks.pop() |
|
318 | chunk = chunks.pop() |
@@ -145,9 +145,9 b' def filemerge(repo, mynode, orig, fcd, f' | |||||
145 |
|
145 | |||
146 | if not tool or tool == 'internal:prompt': |
|
146 | if not tool or tool == 'internal:prompt': | |
147 | tool = "internal:local" |
|
147 | tool = "internal:local" | |
148 | if ui.prompt(_(" no tool found to merge %s\n" |
|
148 | if ui.promptchoice(_(" no tool found to merge %s\n" | |
149 | "keep (l)ocal or take (o)ther?") % fd, |
|
149 | "keep (l)ocal or take (o)ther?") % fd, | |
150 |
(_("&Local"), _("&Other")), |
|
150 | (_("&Local"), _("&Other")), 0): | |
151 | tool = "internal:other" |
|
151 | tool = "internal:other" | |
152 | if tool == "internal:local": |
|
152 | if tool == "internal:local": | |
153 | return 0 |
|
153 | return 0 | |
@@ -213,9 +213,9 b' def filemerge(repo, mynode, orig, fcd, f' | |||||
213 |
|
213 | |||
214 | if not r and _toolbool(ui, tool, "checkchanged"): |
|
214 | if not r and _toolbool(ui, tool, "checkchanged"): | |
215 | if filecmp.cmp(repo.wjoin(fd), back): |
|
215 | if filecmp.cmp(repo.wjoin(fd), back): | |
216 | if ui.prompt(_(" output file %s appears unchanged\n" |
|
216 | if ui.promptchoice(_(" output file %s appears unchanged\n" | |
217 | "was merge successful (yn)?") % fd, |
|
217 | "was merge successful (yn)?") % fd, | |
218 |
(_("&Yes"), _("&No")), |
|
218 | (_("&Yes"), _("&No")), 1): | |
219 | r = 1 |
|
219 | r = 1 | |
220 |
|
220 | |||
221 | if _toolbool(ui, tool, "fixeol"): |
|
221 | if _toolbool(ui, tool, "fixeol"): |
@@ -131,11 +131,13 b' def manifestmerge(repo, p1, p2, pa, over' | |||||
131 | if m == n: # flags agree |
|
131 | if m == n: # flags agree | |
132 | return m # unchanged |
|
132 | return m # unchanged | |
133 | if m and n and not a: # flags set, don't agree, differ from parent |
|
133 | if m and n and not a: # flags set, don't agree, differ from parent | |
134 | r = repo.ui.prompt( |
|
134 | r = repo.ui.promptchoice( | |
135 | _(" conflicting flags for %s\n" |
|
135 | _(" conflicting flags for %s\n" | |
136 | "(n)one, e(x)ec or sym(l)ink?") % f, |
|
136 | "(n)one, e(x)ec or sym(l)ink?") % f, | |
137 |
(_("&None"), _("E&xec"), _("Sym&link")), |
|
137 | (_("&None"), _("E&xec"), _("Sym&link")), 0) | |
138 | return r != _("n") and r or '' |
|
138 | if r == 1: return "x" # Exec | |
|
139 | if r == 2: return "l" # Symlink | |||
|
140 | return "" | |||
139 | if m and m != a: # changed from a to m |
|
141 | if m and m != a: # changed from a to m | |
140 | return m |
|
142 | return m | |
141 | if n and n != a: # changed from a to n |
|
143 | if n and n != a: # changed from a to n | |
@@ -191,10 +193,10 b' def manifestmerge(repo, p1, p2, pa, over' | |||||
191 | f, f2, f, fmerge(f, f2, f2), False) |
|
193 | f, f2, f, fmerge(f, f2, f2), False) | |
192 | elif f in ma: # clean, a different, no remote |
|
194 | elif f in ma: # clean, a different, no remote | |
193 | if n != ma[f]: |
|
195 | if n != ma[f]: | |
194 | if repo.ui.prompt( |
|
196 | if repo.ui.promptchoice( | |
195 | _(" local changed %s which remote deleted\n" |
|
197 | _(" local changed %s which remote deleted\n" | |
196 | "use (c)hanged version or (d)elete?") % f, |
|
198 | "use (c)hanged version or (d)elete?") % f, | |
197 |
(_("&Changed"), _("&Delete")), |
|
199 | (_("&Changed"), _("&Delete")), 0): | |
198 | act("prompt delete", "r", f) |
|
200 | act("prompt delete", "r", f) | |
199 | else: |
|
201 | else: | |
200 | act("prompt keep", "a", f) |
|
202 | act("prompt keep", "a", f) | |
@@ -222,10 +224,10 b' def manifestmerge(repo, p1, p2, pa, over' | |||||
222 | elif f not in ma: |
|
224 | elif f not in ma: | |
223 | act("remote created", "g", f, m2.flags(f)) |
|
225 | act("remote created", "g", f, m2.flags(f)) | |
224 | elif n != ma[f]: |
|
226 | elif n != ma[f]: | |
225 | if repo.ui.prompt( |
|
227 | if repo.ui.promptchoice( | |
226 | _("remote changed %s which local deleted\n" |
|
228 | _("remote changed %s which local deleted\n" | |
227 | "use (c)hanged version or leave (d)eleted?") % f, |
|
229 | "use (c)hanged version or leave (d)eleted?") % f, | |
228 |
(_("&Changed"), _("&Deleted")), |
|
230 | (_("&Changed"), _("&Deleted")), 0) == 0: | |
229 | act("prompt recreating", "g", f, m2.flags(f)) |
|
231 | act("prompt recreating", "g", f, m2.flags(f)) | |
230 |
|
232 | |||
231 | return action |
|
233 | return action |
@@ -63,11 +63,11 b' def submerge(repo, wctx, mctx, actx):' | |||||
63 | wctx.sub(s).get(r) |
|
63 | wctx.sub(s).get(r) | |
64 | sm[s] = r |
|
64 | sm[s] = r | |
65 | elif l[0] != r[0]: # sources differ |
|
65 | elif l[0] != r[0]: # sources differ | |
66 | if repo.ui.prompt( |
|
66 | if repo.ui.promptchoice( | |
67 | _(' subrepository sources for %s differ\n' |
|
67 | _(' subrepository sources for %s differ\n' | |
68 | 'use (l)ocal source (%s) or (r)emote source (%s)?') |
|
68 | 'use (l)ocal source (%s) or (r)emote source (%s)?') | |
69 | % (s, l[0], r[0]), |
|
69 | % (s, l[0], r[0]), | |
70 |
(_('&Local'), _('&Remote')), |
|
70 | (_('&Local'), _('&Remote')), 0): | |
71 | wctx.sub(s).get(r) |
|
71 | wctx.sub(s).get(r) | |
72 | sm[s] = r |
|
72 | sm[s] = r | |
73 | elif l[1] == a[1]: # local side is unchanged |
|
73 | elif l[1] == a[1]: # local side is unchanged | |
@@ -79,10 +79,10 b' def submerge(repo, wctx, mctx, actx):' | |||||
79 | elif l == a: # remote removed, local unchanged |
|
79 | elif l == a: # remote removed, local unchanged | |
80 | wctx.sub(s).remove() |
|
80 | wctx.sub(s).remove() | |
81 | else: |
|
81 | else: | |
82 | if repo.ui.prompt( |
|
82 | if repo.ui.promptchoice( | |
83 | _(' local changed subrepository %s which remote removed\n' |
|
83 | _(' local changed subrepository %s which remote removed\n' | |
84 | 'use (c)hanged version or (d)elete?') % s, |
|
84 | 'use (c)hanged version or (d)elete?') % s, | |
85 |
(_('&Changed'), _('&Delete')), |
|
85 | (_('&Changed'), _('&Delete')), 0): | |
86 | wctx.sub(s).remove() |
|
86 | wctx.sub(s).remove() | |
87 |
|
87 | |||
88 | for s, r in s2.items(): |
|
88 | for s, r in s2.items(): | |
@@ -92,10 +92,10 b' def submerge(repo, wctx, mctx, actx):' | |||||
92 | wctx.sub(s).get(r) |
|
92 | wctx.sub(s).get(r) | |
93 | sm[s] = r |
|
93 | sm[s] = r | |
94 | elif r != sa[s]: |
|
94 | elif r != sa[s]: | |
95 | if repo.ui.prompt( |
|
95 | if repo.ui.promptchoice( | |
96 | _(' remote changed subrepository %s which local removed\n' |
|
96 | _(' remote changed subrepository %s which local removed\n' | |
97 | 'use (c)hanged version or (d)elete?') % s, |
|
97 | 'use (c)hanged version or (d)elete?') % s, | |
98 |
(_('&Changed'), _('&Delete')), |
|
98 | (_('&Changed'), _('&Delete')), 0) == 0: | |
99 | wctx.sub(s).get(r) |
|
99 | wctx.sub(s).get(r) | |
100 | sm[s] = r |
|
100 | sm[s] = r | |
101 |
|
101 |
@@ -269,30 +269,35 b' class ui(object):' | |||||
269 | line = line[:-1] |
|
269 | line = line[:-1] | |
270 | return line |
|
270 | return line | |
271 |
|
271 | |||
272 |
def prompt(self, msg, |
|
272 | def prompt(self, msg, default="y"): | |
273 |
"""Prompt user with msg, read response |
|
273 | """Prompt user with msg, read response. | |
274 | one of the provided choices. choices is a sequence of acceptable |
|
274 | If ui is not interactive, the default is returned. | |
275 | responses with the format: ('&None', 'E&xec', 'Sym&link') |
|
|||
276 | No sequence implies no response checking. Responses are case |
|
|||
277 | insensitive. If ui is not interactive, the default is returned. |
|
|||
278 | """ |
|
275 | """ | |
279 | if not self.interactive(): |
|
276 | if not self.interactive(): | |
280 | self.write(msg, ' ', default, "\n") |
|
277 | self.write(msg, ' ', default, "\n") | |
281 | return default |
|
278 | return default | |
|
279 | try: | |||
|
280 | r = self._readline(msg + ' ') | |||
|
281 | if not r: | |||
|
282 | return default | |||
|
283 | return r | |||
|
284 | except EOFError: | |||
|
285 | raise util.Abort(_('response expected')) | |||
|
286 | ||||
|
287 | def promptchoice(self, msg, choices, default=0): | |||
|
288 | """Prompt user with msg, read response, and ensure it matches | |||
|
289 | one of the provided choices. The index of the choice is returned. | |||
|
290 | choices is a sequence of acceptable responses with the format: | |||
|
291 | ('&None', 'E&xec', 'Sym&link') Responses are case insensitive. | |||
|
292 | If ui is not interactive, the default is returned. | |||
|
293 | """ | |||
|
294 | resps = [s[s.index('&')+1].lower() for s in choices] | |||
282 | while True: |
|
295 | while True: | |
283 | try: |
|
296 | r = self.prompt(msg, resps[default]) | |
284 | r = self._readline(msg + ' ') |
|
297 | if r.lower() in resps: | |
285 | if not r: |
|
298 | return resps.index(r.lower()) | |
286 | return default |
|
299 | self.write(_("unrecognized response\n")) | |
287 | if not choices: |
|
300 | ||
288 | return r |
|
|||
289 | resps = [s[s.index('&')+1].lower() for s in choices] |
|
|||
290 | if r.lower() in resps: |
|
|||
291 | return r.lower() |
|
|||
292 | else: |
|
|||
293 | self.write(_("unrecognized response\n")) |
|
|||
294 | except EOFError: |
|
|||
295 | raise util.Abort(_('response expected')) |
|
|||
296 |
|
301 | |||
297 | def getpass(self, prompt=None, default=None): |
|
302 | def getpass(self, prompt=None, default=None): | |
298 | if not self.interactive(): return default |
|
303 | if not self.interactive(): return default |
General Comments 0
You need to be logged in to leave comments.
Login now