185 was changed in a revision, even if there was no change. This method |
185 was changed in a revision, even if there was no change. This method |
186 tells the destination that we're using a filemap and that it should |
186 tells the destination that we're using a filemap and that it should |
187 filter empty revisions. |
187 filter empty revisions. |
188 """ |
188 """ |
189 pass |
189 pass |
|
190 |
|
191 def before(self): |
|
192 pass |
|
193 |
|
194 def after(self): |
|
195 pass |
|
196 |
|
197 |
|
198 class commandline(object): |
|
199 def __init__(self, ui, command): |
|
200 self.ui = ui |
|
201 self.command = command |
|
202 |
|
203 def prerun(self): |
|
204 pass |
|
205 |
|
206 def postrun(self): |
|
207 pass |
|
208 |
|
209 def _run(self, cmd, *args, **kwargs): |
|
210 cmdline = [self.command, cmd] + list(args) |
|
211 for k, v in kwargs.iteritems(): |
|
212 if len(k) == 1: |
|
213 cmdline.append('-' + k) |
|
214 else: |
|
215 cmdline.append('--' + k.replace('_', '-')) |
|
216 try: |
|
217 if len(k) == 1: |
|
218 cmdline.append('' + v) |
|
219 else: |
|
220 cmdline[-1] += '=' + v |
|
221 except TypeError: |
|
222 pass |
|
223 cmdline = [util.shellquote(arg) for arg in cmdline] |
|
224 cmdline += ['<', util.nulldev] |
|
225 cmdline = util.quotecommand(' '.join(cmdline)) |
|
226 self.ui.debug(cmdline, '\n') |
|
227 |
|
228 self.prerun() |
|
229 try: |
|
230 return util.popen(cmdline) |
|
231 finally: |
|
232 self.postrun() |
|
233 |
|
234 def run(self, cmd, *args, **kwargs): |
|
235 fp = self._run(cmd, *args, **kwargs) |
|
236 output = fp.read() |
|
237 self.ui.debug(output) |
|
238 return output, fp.close() |
|
239 |
|
240 def checkexit(self, status, output=''): |
|
241 if status: |
|
242 if output: |
|
243 self.ui.warn(_('%s error:\n') % self.command) |
|
244 self.ui.warn(output) |
|
245 msg = util.explain_exit(status)[0] |
|
246 raise util.Abort(_('%s %s') % (self.command, msg)) |
|
247 |
|
248 def run0(self, cmd, *args, **kwargs): |
|
249 output, status = self.run(cmd, *args, **kwargs) |
|
250 self.checkexit(status, output) |
|
251 return output |
190 |
252 |
191 |
253 |
192 class mapfile(dict): |
254 class mapfile(dict): |
193 def __init__(self, ui, path): |
255 def __init__(self, ui, path): |
194 super(mapfile, self).__init__() |
256 super(mapfile, self).__init__() |