Mercurial > hg
comparison hgext/patchbomb.py @ 4486:6b84c8d2f66f
patchbomb: Defer the import of readline.
If imported at the top of the module, the import appears to succeed,
but raw_input doesn't acquire magic editing fu. I suspect this has
something to do with the newish demandimport code, because the prior
code worked with demandload.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sun, 27 May 2007 13:41:35 -0700 |
parents | 82bc6aef8b43 |
children | a11e13d50645 |
comparison
equal
deleted
inserted
replaced
4485:82bc6aef8b43 | 4486:6b84c8d2f66f |
---|---|
68 import email.Utils, email.Encoders | 68 import email.Utils, email.Encoders |
69 from mercurial import cmdutil, commands, hg, mail, ui, patch, util | 69 from mercurial import cmdutil, commands, hg, mail, ui, patch, util |
70 from mercurial.i18n import _ | 70 from mercurial.i18n import _ |
71 from mercurial.node import * | 71 from mercurial.node import * |
72 | 72 |
73 try: | |
74 # readline gives raw_input editing capabilities, but is not | |
75 # present on windows | |
76 import readline | |
77 except ImportError: pass | |
78 | |
79 def patchbomb(ui, repo, *revs, **opts): | 73 def patchbomb(ui, repo, *revs, **opts): |
80 '''send changesets by email | 74 '''send changesets by email |
81 | 75 |
82 By default, diffs are sent in the format generated by hg export, | 76 By default, diffs are sent in the format generated by hg export, |
83 one per message. The series starts with a "[PATCH 0 of N]" | 77 one per message. The series starts with a "[PATCH 0 of N]" |
118 Before using this command, you will need to enable email in your hgrc. | 112 Before using this command, you will need to enable email in your hgrc. |
119 See the [email] section in hgrc(5) for details. | 113 See the [email] section in hgrc(5) for details. |
120 ''' | 114 ''' |
121 | 115 |
122 def prompt(prompt, default = None, rest = ': ', empty_ok = False): | 116 def prompt(prompt, default = None, rest = ': ', empty_ok = False): |
117 try: | |
118 # readline gives raw_input editing capabilities, but is not | |
119 # present on windows | |
120 import readline | |
121 except ImportError: pass | |
122 | |
123 if default: prompt += ' [%s]' % default | 123 if default: prompt += ' [%s]' % default |
124 prompt += rest | 124 prompt += rest |
125 while True: | 125 while True: |
126 r = raw_input(prompt) | 126 r = raw_input(prompt) |
127 if r: return r | 127 if r: return r |