Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 3677:1a0fa3914c46
Avoid looking up usernames if the current user owns the .hgrc file
Converting uids into usernames may be somewhat expensive when NIS
or LDAP is involved.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sat, 18 Nov 2006 23:51:14 -0200 |
parents | eb0b4a2d70a9 |
children | 98f2507c5551 |
comparison
equal
deleted
inserted
replaced
3676:d94664748bc1 | 3677:1a0fa3914c46 |
---|---|
652 return '"%s"' % s.replace('"', '\\"') | 652 return '"%s"' % s.replace('"', '\\"') |
653 | 653 |
654 def explain_exit(code): | 654 def explain_exit(code): |
655 return _("exited with status %d") % code, code | 655 return _("exited with status %d") % code, code |
656 | 656 |
657 # if you change this stub into a real check, please try to implement the | |
658 # username and groupname functions above, too. | |
659 def isowner(fp, st=None): | |
660 return True | |
661 | |
657 try: | 662 try: |
658 # override functions with win32 versions if possible | 663 # override functions with win32 versions if possible |
659 from util_win32 import * | 664 from util_win32 import * |
660 if not is_win_9x(): | 665 if not is_win_9x(): |
661 posixfile = posixfile_nt | 666 posixfile = posixfile_nt |
762 return _("killed by signal %d") % val, val | 767 return _("killed by signal %d") % val, val |
763 elif os.WIFSTOPPED(code): | 768 elif os.WIFSTOPPED(code): |
764 val = os.WSTOPSIG(code) | 769 val = os.WSTOPSIG(code) |
765 return _("stopped by signal %d") % val, val | 770 return _("stopped by signal %d") % val, val |
766 raise ValueError(_("invalid exit code")) | 771 raise ValueError(_("invalid exit code")) |
772 | |
773 def isowner(fp, st=None): | |
774 """Return True if the file object f belongs to the current user. | |
775 | |
776 The return value of a util.fstat(f) may be passed as the st argument. | |
777 """ | |
778 if st is None: | |
779 st = fstat(f) | |
780 return st.st_uid == os.getuid() | |
781 | |
767 | 782 |
768 def opener(base, audit=True): | 783 def opener(base, audit=True): |
769 """ | 784 """ |
770 return a function that opens files relative to base | 785 return a function that opens files relative to base |
771 | 786 |