equal
deleted
inserted
replaced
75 else: |
75 else: |
76 u = u[:a] |
76 u = u[:a] |
77 return u.encode(_encoding, _encodingmode) |
77 return u.encode(_encoding, _encodingmode) |
78 except UnicodeDecodeError, inst: |
78 except UnicodeDecodeError, inst: |
79 sub = s[max(0, inst.start-10), inst.start+10] |
79 sub = s[max(0, inst.start-10), inst.start+10] |
80 raise Abort(_("decoding near '%s': %s!\n") % (sub, inst)) |
80 raise Abort(_("decoding near '%s': %s!") % (sub, inst)) |
81 |
81 |
82 # used by parsedate |
82 # used by parsedate |
83 defaultdateformats = ( |
83 defaultdateformats = ( |
84 '%Y-%m-%d %H:%M:%S', |
84 '%Y-%m-%d %H:%M:%S', |
85 '%Y-%m-%d %I:%M:%S%p', |
85 '%Y-%m-%d %I:%M:%S%p', |
648 def audit_path(path): |
648 def audit_path(path): |
649 """Abort if path contains dangerous components""" |
649 """Abort if path contains dangerous components""" |
650 parts = os.path.normcase(path).split(os.sep) |
650 parts = os.path.normcase(path).split(os.sep) |
651 if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '') |
651 if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '') |
652 or os.pardir in parts): |
652 or os.pardir in parts): |
653 raise Abort(_("path contains illegal component: %s\n") % path) |
653 raise Abort(_("path contains illegal component: %s") % path) |
654 |
654 |
655 def _makelock_file(info, pathname): |
655 def _makelock_file(info, pathname): |
656 ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL) |
656 ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL) |
657 os.write(ld, info) |
657 os.write(ld, info) |
658 os.close(ld) |
658 os.close(ld) |