Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/mq.py @ 2907:b70740aefa4d
Unify mq and hg patch invocation.
This makes patch a little less verbose by default, so the tests
had to be updated.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Tue, 15 Aug 2006 11:28:50 -0700 |
parents | 790fd342b6c7 |
children | ef8ee4477019 addb58e3b41c |
comparison
equal
deleted
inserted
replaced
2906:68cea0b8f992 | 2907:b70740aefa4d |
---|---|
398 | 398 |
399 def patch(self, repo, patchfile): | 399 def patch(self, repo, patchfile): |
400 '''Apply patchfile to the working directory. | 400 '''Apply patchfile to the working directory. |
401 patchfile: file name of patch''' | 401 patchfile: file name of patch''' |
402 try: | 402 try: |
403 pp = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch') | 403 (files, fuzz) = patch.patch(patchfile, self.ui, strip=1, |
404 f = os.popen("%s -d %s -p1 --no-backup-if-mismatch < %s" % | 404 cwd=repo.root) |
405 (pp, util.shellquote(repo.root), util.shellquote(patchfile))) | 405 except Exception, inst: |
406 except: | 406 self.ui.note(str(inst) + '\n') |
407 self.ui.warn("patch failed, unable to continue (try -v)\n") | 407 if not self.ui.verbose: |
408 return (None, [], False) | 408 self.ui.warn("patch failed, unable to continue (try -v)\n") |
409 files = [] | 409 return (False, [], False) |
410 fuzz = False | 410 |
411 for l in f: | 411 return (True, files.keys(), fuzz) |
412 l = l.rstrip('\r\n'); | |
413 if self.ui.verbose: | |
414 self.ui.warn(l + "\n") | |
415 if l[:14] == 'patching file ': | |
416 pf = os.path.normpath(util.parse_patch_output(l)) | |
417 if pf not in files: | |
418 files.append(pf) | |
419 printed_file = False | |
420 file_str = l | |
421 elif l.find('with fuzz') >= 0: | |
422 if not printed_file: | |
423 self.ui.warn(file_str + '\n') | |
424 printed_file = True | |
425 self.ui.warn(l + '\n') | |
426 fuzz = True | |
427 elif l.find('saving rejects to file') >= 0: | |
428 self.ui.warn(l + '\n') | |
429 elif l.find('FAILED') >= 0: | |
430 if not printed_file: | |
431 self.ui.warn(file_str + '\n') | |
432 printed_file = True | |
433 self.ui.warn(l + '\n') | |
434 | |
435 return (not f.close(), files, fuzz) | |
436 | 412 |
437 def apply(self, repo, series, list=False, update_status=True, | 413 def apply(self, repo, series, list=False, update_status=True, |
438 strict=False, patchdir=None, merge=None, wlock=None): | 414 strict=False, patchdir=None, merge=None, wlock=None): |
439 # TODO unify with commands.py | 415 # TODO unify with commands.py |
440 if not patchdir: | 416 if not patchdir: |