Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/util.py @ 4720:72fb6f10fac1
OpenVMS patches
author | Jean-Francois PIERONNE <jf.pieronne@laposte.net> |
---|---|
date | Fri, 08 Jun 2007 16:24:43 +0200 |
parents | 01f9ee4de1ad |
children | 7549cd526b7f |
comparison
equal
deleted
inserted
replaced
4719:1069205a8894 | 4720:72fb6f10fac1 |
---|---|
200 outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-') | 200 outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-') |
201 os.close(outfd) | 201 os.close(outfd) |
202 cmd = cmd.replace('INFILE', inname) | 202 cmd = cmd.replace('INFILE', inname) |
203 cmd = cmd.replace('OUTFILE', outname) | 203 cmd = cmd.replace('OUTFILE', outname) |
204 code = os.system(cmd) | 204 code = os.system(cmd) |
205 if sys.platform == 'OpenVMS' and code & 1: | |
206 code = 0 | |
205 if code: raise Abort(_("command '%s' failed: %s") % | 207 if code: raise Abort(_("command '%s' failed: %s") % |
206 (cmd, explain_exit(code))) | 208 (cmd, explain_exit(code))) |
207 return open(outname, 'rb').read() | 209 return open(outname, 'rb').read() |
208 finally: | 210 finally: |
209 try: | 211 try: |
577 if 'HG' not in os.environ: | 579 if 'HG' not in os.environ: |
578 os.environ['HG'] = _hgexecutable | 580 os.environ['HG'] = _hgexecutable |
579 if cwd is not None and oldcwd != cwd: | 581 if cwd is not None and oldcwd != cwd: |
580 os.chdir(cwd) | 582 os.chdir(cwd) |
581 rc = os.system(cmd) | 583 rc = os.system(cmd) |
584 if sys.platform == 'OpenVMS' and rc & 1: | |
585 rc = 0 | |
582 if rc and onerr: | 586 if rc and onerr: |
583 errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]), | 587 errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]), |
584 explain_exit(rc)[0]) | 588 explain_exit(rc)[0]) |
585 if errprefix: | 589 if errprefix: |
586 errmsg = '%s: %s' % (errprefix, errmsg) | 590 errmsg = '%s: %s' % (errprefix, errmsg) |
998 return [os.path.expanduser('~/.hgrc')] | 1002 return [os.path.expanduser('~/.hgrc')] |
999 | 1003 |
1000 def parse_patch_output(output_line): | 1004 def parse_patch_output(output_line): |
1001 """parses the output produced by patch and returns the file name""" | 1005 """parses the output produced by patch and returns the file name""" |
1002 pf = output_line[14:] | 1006 pf = output_line[14:] |
1003 if pf.startswith("'") and pf.endswith("'") and " " in pf: | 1007 if os.sys.platform == 'OpenVMS': |
1004 pf = pf[1:-1] # Remove the quotes | 1008 if pf[0] == '`': |
1009 pf = pf[1:-1] # Remove the quotes | |
1010 else: | |
1011 if pf.startswith("'") and pf.endswith("'") and " " in pf: | |
1012 pf = pf[1:-1] # Remove the quotes | |
1005 return pf | 1013 return pf |
1006 | 1014 |
1007 def is_exec(f): | 1015 def is_exec(f): |
1008 """check whether a file is executable""" | 1016 """check whether a file is executable""" |
1009 return (os.lstat(f).st_mode & 0100 != 0) | 1017 return (os.lstat(f).st_mode & 0100 != 0) |
1062 | 1070 |
1063 def readlock(pathname): | 1071 def readlock(pathname): |
1064 try: | 1072 try: |
1065 return os.readlink(pathname) | 1073 return os.readlink(pathname) |
1066 except OSError, why: | 1074 except OSError, why: |
1067 if why.errno == errno.EINVAL: | 1075 if why.errno in (errno.EINVAL, errno.ENOSYS): |
1068 return _readlock_file(pathname) | 1076 return _readlock_file(pathname) |
1069 else: | 1077 else: |
1070 raise | 1078 raise |
1071 | 1079 |
1072 def shellquote(s): | 1080 def shellquote(s): |
1073 return "'%s'" % s.replace("'", "'\\''") | 1081 if os.sys.platform == 'OpenVMS': |
1082 return '"%s"' % s | |
1083 else: | |
1084 return "'%s'" % s.replace("'", "'\\''") | |
1074 | 1085 |
1075 def testpid(pid): | 1086 def testpid(pid): |
1076 '''return False if pid dead, True if running or not sure''' | 1087 '''return False if pid dead, True if running or not sure''' |
1088 if os.sys.platform == 'OpenVMS': | |
1089 return True | |
1077 try: | 1090 try: |
1078 os.kill(pid, 0) | 1091 os.kill(pid, 0) |
1079 return True | 1092 return True |
1080 except OSError, inst: | 1093 except OSError, inst: |
1081 return inst.errno != errno.ESRCH | 1094 return inst.errno != errno.ESRCH |
1120 def find_exe(name, default=None): | 1133 def find_exe(name, default=None): |
1121 '''find path of an executable. | 1134 '''find path of an executable. |
1122 if name contains a path component, return it as is. otherwise, | 1135 if name contains a path component, return it as is. otherwise, |
1123 use normal executable search path.''' | 1136 use normal executable search path.''' |
1124 | 1137 |
1125 if os.sep in name: | 1138 if os.sep in name or sys.platform == 'OpenVMS': |
1126 # don't check the executable bit. if the file isn't | 1139 # don't check the executable bit. if the file isn't |
1127 # executable, whoever tries to actually run it will give a | 1140 # executable, whoever tries to actually run it will give a |
1128 # much more useful error message. | 1141 # much more useful error message. |
1129 return name | 1142 return name |
1130 return find_in_path(name, os.environ.get('PATH', ''), default=default) | 1143 return find_in_path(name, os.environ.get('PATH', ''), default=default) |
1225 def o(path, mode="r", text=False, atomictemp=False): | 1238 def o(path, mode="r", text=False, atomictemp=False): |
1226 if audit: | 1239 if audit: |
1227 audit_path(path) | 1240 audit_path(path) |
1228 f = os.path.join(base, path) | 1241 f = os.path.join(base, path) |
1229 | 1242 |
1230 if not text: | 1243 if not text and "b" not in mode: |
1231 mode += "b" # for that other OS | 1244 mode += "b" # for that other OS |
1232 | 1245 |
1233 if mode[0] != "r": | 1246 if mode[0] != "r": |
1234 try: | 1247 try: |
1235 nlink = nlinks(f) | 1248 nlink = nlinks(f) |