##// END OF EJS Templates
patch.py: fix some incorrect uses of _() for i18n
Bryan O'Sullivan -
r4898:bc905a6c default
parent child Browse files
Show More
@@ -222,7 +222,8 b' def patch(patchname, ui, strip=1, cwd=No'
222 os.chdir(cwd)
222 os.chdir(cwd)
223 try:
223 try:
224 ret = applydiff(ui, fp, files, strip=strip)
224 ret = applydiff(ui, fp, files, strip=strip)
225 except PatchError:
225 except PatchError, err:
226 ui.debug(err)
226 raise util.Abort(_("patch failed to apply"))
227 raise util.Abort(_("patch failed to apply"))
227 if cwd:
228 if cwd:
228 os.chdir(curdir)
229 os.chdir(curdir)
@@ -269,7 +270,7 b' class patchfile:'
269 return
270 return
270 if warn or self.ui.verbose:
271 if warn or self.ui.verbose:
271 self.fileprinted = True
272 self.fileprinted = True
272 s = _("patching file %s\n" % self.fname)
273 s = _("patching file %s\n") % self.fname
273 if warn:
274 if warn:
274 self.ui.warn(s)
275 self.ui.warn(s)
275 else:
276 else:
@@ -316,8 +317,8 b' class patchfile:'
316
317
317 fname = self.fname + ".rej"
318 fname = self.fname + ".rej"
318 self.ui.warn(
319 self.ui.warn(
319 _("%d out of %d hunk%s FAILED -- saving rejects to file %s\n" %
320 _("%d out of %d hunk%s FAILED -- saving rejects to file %s\n") %
320 (len(self.rej), self.hunks, hunkstr, fname)))
321 (len(self.rej), self.hunks, hunkstr, fname))
321 try: os.unlink(fname)
322 try: os.unlink(fname)
322 except:
323 except:
323 pass
324 pass
@@ -352,7 +353,7 b' class patchfile:'
352
353
353 def apply(self, h, reverse):
354 def apply(self, h, reverse):
354 if not h.complete():
355 if not h.complete():
355 raise PatchError("bad hunk #%d %s (%d %d %d %d)" %
356 raise PatchError(_("bad hunk #%d %s (%d %d %d %d)") %
356 (h.number, h.desc, len(h.a), h.lena, len(h.b),
357 (h.number, h.desc, len(h.a), h.lena, len(h.b),
357 h.lenb))
358 h.lenb))
358
359
@@ -361,7 +362,7 b' class patchfile:'
361 h.reverse()
362 h.reverse()
362
363
363 if self.exists and h.createfile():
364 if self.exists and h.createfile():
364 self.ui.warn(_("file %s already exists\n" % self.fname))
365 self.ui.warn(_("file %s already exists\n") % self.fname)
365 self.rej.append(h)
366 self.rej.append(h)
366 return -1
367 return -1
367
368
@@ -423,11 +424,11 b' class patchfile:'
423 linestr = "line"
424 linestr = "line"
424 else:
425 else:
425 linestr = "lines"
426 linestr = "lines"
426 f(_("Hunk #%d succeeded at %d %s(offset %d %s).\n" %
427 f(_("Hunk #%d succeeded at %d %s(offset %d %s).\n") %
427 (h.number, l+1, fuzzstr, offset, linestr)))
428 (h.number, l+1, fuzzstr, offset, linestr))
428 return fuzzlen
429 return fuzzlen
429 self.printfile(True)
430 self.printfile(True)
430 self.ui.warn(_("Hunk #%d FAILED at %d\n" % (h.number, orig_start)))
431 self.ui.warn(_("Hunk #%d FAILED at %d\n") % (h.number, orig_start))
431 self.rej.append(h)
432 self.rej.append(h)
432 return -1
433 return -1
433
434
@@ -446,7 +447,7 b' class hunk:'
446 def read_unified_hunk(self, lr):
447 def read_unified_hunk(self, lr):
447 m = unidesc.match(self.desc)
448 m = unidesc.match(self.desc)
448 if not m:
449 if not m:
449 raise PatchError("bad hunk #%d" % self.number)
450 raise PatchError(_("bad hunk #%d") % self.number)
450 self.starta, foo, self.lena, self.startb, foo2, self.lenb = m.groups()
451 self.starta, foo, self.lena, self.startb, foo2, self.lenb = m.groups()
451 if self.lena == None:
452 if self.lena == None:
452 self.lena = 1
453 self.lena = 1
@@ -472,7 +473,7 b' class hunk:'
472 self.desc = lr.readline()
473 self.desc = lr.readline()
473 m = contextdesc.match(self.desc)
474 m = contextdesc.match(self.desc)
474 if not m:
475 if not m:
475 raise PatchError("bad hunk #%d" % self.number)
476 raise PatchError(_("bad hunk #%d") % self.number)
476 foo, self.starta, foo2, aend, foo3 = m.groups()
477 foo, self.starta, foo2, aend, foo3 = m.groups()
477 self.starta = int(self.starta)
478 self.starta = int(self.starta)
478 if aend == None:
479 if aend == None:
@@ -491,7 +492,8 b' class hunk:'
491 elif l.startswith(' '):
492 elif l.startswith(' '):
492 u = ' ' + s
493 u = ' ' + s
493 else:
494 else:
494 raise PatchError("bad hunk #%d old text line %d" % (self.number, x))
495 raise PatchError(_("bad hunk #%d old text line %d") %
496 (self.number, x))
495 self.a.append(u)
497 self.a.append(u)
496 self.hunk.append(u)
498 self.hunk.append(u)
497
499
@@ -503,7 +505,7 b' class hunk:'
503 l = lr.readline()
505 l = lr.readline()
504 m = contextdesc.match(l)
506 m = contextdesc.match(l)
505 if not m:
507 if not m:
506 raise PatchError("bad hunk #%d" % self.number)
508 raise PatchError(_("bad hunk #%d") % self.number)
507 foo, self.startb, foo2, bend, foo3 = m.groups()
509 foo, self.startb, foo2, bend, foo3 = m.groups()
508 self.startb = int(self.startb)
510 self.startb = int(self.startb)
509 if bend == None:
511 if bend == None:
@@ -532,7 +534,8 b' class hunk:'
532 lr.push(l)
534 lr.push(l)
533 break
535 break
534 else:
536 else:
535 raise PatchError("bad hunk #%d old text line %d" % (self.number, x))
537 raise PatchError(_("bad hunk #%d old text line %d") %
538 (self.number, x))
536 self.b.append(s)
539 self.b.append(s)
537 while True:
540 while True:
538 if hunki >= len(self.hunk):
541 if hunki >= len(self.hunk):
@@ -676,7 +679,7 b' class binhunk:'
676 line = fp.readline()
679 line = fp.readline()
677 self.hunk.append(line)
680 self.hunk.append(line)
678 if not line:
681 if not line:
679 raise PatchError('could not extract binary patch')
682 raise PatchError(_('could not extract binary patch'))
680 size = int(line[8:].rstrip())
683 size = int(line[8:].rstrip())
681 dec = []
684 dec = []
682 line = fp.readline()
685 line = fp.readline()
@@ -692,7 +695,7 b' class binhunk:'
692 self.hunk.append(line)
695 self.hunk.append(line)
693 text = zlib.decompress(''.join(dec))
696 text = zlib.decompress(''.join(dec))
694 if len(text) != size:
697 if len(text) != size:
695 raise PatchError('binary patch is %d bytes, not %d' %
698 raise PatchError(_('binary patch is %d bytes, not %d') %
696 len(text), size)
699 len(text), size)
697 self.text = text
700 self.text = text
698
701
@@ -715,7 +718,7 b' def selectfile(afile_orig, bfile_orig, h'
715 while count > 0:
718 while count > 0:
716 i = path.find(os.sep, i)
719 i = path.find(os.sep, i)
717 if i == -1:
720 if i == -1:
718 raise PatchError("Unable to strip away %d dirs from %s" %
721 raise PatchError(_("unable to strip away %d dirs from %s") %
719 (count, path))
722 (count, path))
720 i += 1
723 i += 1
721 # consume '//' in the path
724 # consume '//' in the path
@@ -737,8 +740,8 b' def selectfile(afile_orig, bfile_orig, h'
737 if reverse:
740 if reverse:
738 createfunc = hunk.rmfile
741 createfunc = hunk.rmfile
739 if not goodb and not gooda and not createfunc():
742 if not goodb and not gooda and not createfunc():
740 raise PatchError(_("Unable to find %s or %s for patching\n" %
743 raise PatchError(_("unable to find %s or %s for patching") %
741 (afile, bfile)))
744 (afile, bfile))
742 if gooda and goodb:
745 if gooda and goodb:
743 fname = bfile
746 fname = bfile
744 if afile in bfile:
747 if afile in bfile:
@@ -835,7 +838,8 b' def applydiff(ui, fp, changed, strip=1, '
835 if context == None and x.startswith('***************'):
838 if context == None and x.startswith('***************'):
836 context = True
839 context = True
837 current_hunk = hunk(x, hunknum + 1, lr, context)
840 current_hunk = hunk(x, hunknum + 1, lr, context)
838 except PatchError:
841 except PatchError, err:
842 ui.debug(err)
839 current_hunk = None
843 current_hunk = None
840 continue
844 continue
841 hunknum += 1
845 hunknum += 1
@@ -917,7 +921,7 b' def applydiff(ui, fp, changed, strip=1, '
917 err = 1
921 err = 1
918 else:
922 else:
919 fname = current_file and current_file.fname or None
923 fname = current_file and current_file.fname or None
920 raise PatchError("malformed patch %s %s" % (fname,
924 raise PatchError(_("malformed patch %s %s") % (fname,
921 current_hunk.desc))
925 current_hunk.desc))
922 if current_file:
926 if current_file:
923 current_file.close()
927 current_file.close()
@@ -929,7 +933,7 b' def applydiff(ui, fp, changed, strip=1, '
929 if rejects:
933 if rejects:
930 return -1
934 return -1
931 if hunknum == 0 and dopatch and not gitworkdone:
935 if hunknum == 0 and dopatch and not gitworkdone:
932 raise PatchError("No valid hunks found")
936 raise PatchError(_("no valid hunks found"))
933 return err
937 return err
934
938
935 def diffopts(ui, opts={}, untrusted=False):
939 def diffopts(ui, opts={}, untrusted=False):
General Comments 0
You need to be logged in to leave comments. Login now