Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 1402:9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Tue, 18 Oct 2005 18:38:39 -0700 |
parents | cf9a1233738a |
children | 1c64c628d15f |
comparison
equal
deleted
inserted
replaced
1401:fbf2b10011aa | 1402:9d2c2e6b32b5 |
---|---|
45 outfd, outname = tempfile.mkstemp(prefix='hgfout') | 45 outfd, outname = tempfile.mkstemp(prefix='hgfout') |
46 os.close(outfd) | 46 os.close(outfd) |
47 cmd = cmd.replace('INFILE', inname) | 47 cmd = cmd.replace('INFILE', inname) |
48 cmd = cmd.replace('OUTFILE', outname) | 48 cmd = cmd.replace('OUTFILE', outname) |
49 code = os.system(cmd) | 49 code = os.system(cmd) |
50 if code: raise Abort("command '%s' failed: %s" % | 50 if code: raise Abort(_("command '%s' failed: %s") % |
51 (cmd, explain_exit(code))) | 51 (cmd, explain_exit(code))) |
52 return open(outname, 'rb').read() | 52 return open(outname, 'rb').read() |
53 finally: | 53 finally: |
54 try: | 54 try: |
55 if inname: os.unlink(inname) | 55 if inname: os.unlink(inname) |
81 if line.startswith('patching file '): | 81 if line.startswith('patching file '): |
82 pf = parse_patch_output(line) | 82 pf = parse_patch_output(line) |
83 files.setdefault(pf, 1) | 83 files.setdefault(pf, 1) |
84 code = fp.close() | 84 code = fp.close() |
85 if code: | 85 if code: |
86 raise Abort("patch command failed: %s" % explain_exit(code)[0]) | 86 raise Abort(_("patch command failed: %s") % explain_exit(code)[0]) |
87 return files.keys() | 87 return files.keys() |
88 | 88 |
89 def binary(s): | 89 def binary(s): |
90 """return true if a string is binary data using diff's heuristic""" | 90 """return true if a string is binary data using diff's heuristic""" |
91 if s and '\0' in s[:4096]: | 91 if s and '\0' in s[:4096]: |
364 | 364 |
365 if hasattr(os, 'link'): | 365 if hasattr(os, 'link'): |
366 os_link = os.link | 366 os_link = os.link |
367 else: | 367 else: |
368 def os_link(src, dst): | 368 def os_link(src, dst): |
369 raise OSError(0, "Hardlinks not supported") | 369 raise OSError(0, _("Hardlinks not supported")) |
370 | 370 |
371 # Platform specific variants | 371 # Platform specific variants |
372 if os.name == 'nt': | 372 if os.name == 'nt': |
373 nulldev = 'NUL:' | 373 nulldev = 'NUL:' |
374 | 374 |
429 | 429 |
430 makelock = _makelock_file | 430 makelock = _makelock_file |
431 readlock = _readlock_file | 431 readlock = _readlock_file |
432 | 432 |
433 def explain_exit(code): | 433 def explain_exit(code): |
434 return "exited with status %d" % code, code | 434 return _("exited with status %d") % code, code |
435 | 435 |
436 else: | 436 else: |
437 nulldev = '/dev/null' | 437 nulldev = '/dev/null' |
438 | 438 |
439 hgrcd = '/etc/mercurial/hgrc.d' | 439 hgrcd = '/etc/mercurial/hgrc.d' |
492 | 492 |
493 def explain_exit(code): | 493 def explain_exit(code): |
494 """return a 2-tuple (desc, code) describing a process's status""" | 494 """return a 2-tuple (desc, code) describing a process's status""" |
495 if os.WIFEXITED(code): | 495 if os.WIFEXITED(code): |
496 val = os.WEXITSTATUS(code) | 496 val = os.WEXITSTATUS(code) |
497 return "exited with status %d" % val, val | 497 return _("exited with status %d") % val, val |
498 elif os.WIFSIGNALED(code): | 498 elif os.WIFSIGNALED(code): |
499 val = os.WTERMSIG(code) | 499 val = os.WTERMSIG(code) |
500 return "killed by signal %d" % val, val | 500 return _("killed by signal %d") % val, val |
501 elif os.WIFSTOPPED(code): | 501 elif os.WIFSTOPPED(code): |
502 val = os.WSTOPSIG(code) | 502 val = os.WSTOPSIG(code) |
503 return "stopped by signal %d" % val, val | 503 return _("stopped by signal %d") % val, val |
504 raise ValueError("invalid exit code") | 504 raise ValueError(_("invalid exit code")) |
505 | 505 |
506 class chunkbuffer(object): | 506 class chunkbuffer(object): |
507 """Allow arbitrary sized chunks of data to be efficiently read from an | 507 """Allow arbitrary sized chunks of data to be efficiently read from an |
508 iterator over chunks of arbitrary size.""" | 508 iterator over chunks of arbitrary size.""" |
509 | 509 |
512 targetsize is how big a buffer to try to maintain.""" | 512 targetsize is how big a buffer to try to maintain.""" |
513 self.in_iter = iter(in_iter) | 513 self.in_iter = iter(in_iter) |
514 self.buf = '' | 514 self.buf = '' |
515 self.targetsize = int(targetsize) | 515 self.targetsize = int(targetsize) |
516 if self.targetsize <= 0: | 516 if self.targetsize <= 0: |
517 raise ValueError("targetsize must be greater than 0, was %d" % | 517 raise ValueError(_("targetsize must be greater than 0, was %d") % |
518 targetsize) | 518 targetsize) |
519 self.iterempty = False | 519 self.iterempty = False |
520 | 520 |
521 def fillbuf(self): | 521 def fillbuf(self): |
522 """Ignore target size; read every chunk from iterator until empty.""" | 522 """Ignore target size; read every chunk from iterator until empty.""" |