Show More
@@ -6,7 +6,7 b' import sys' | |||||
6 | from mercurial import revlog, node, util |
|
6 | from mercurial import revlog, node, util | |
7 |
|
7 | |||
8 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
8 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |
9 |
util.set |
|
9 | util.setbinary(fp) | |
10 |
|
10 | |||
11 | for f in sys.argv[1:]: |
|
11 | for f in sys.argv[1:]: | |
12 | binopen = lambda fn: open(fn, 'rb') |
|
12 | binopen = lambda fn: open(fn, 'rb') |
@@ -251,8 +251,8 b' def shrink(ui, repo, **opts):' | |||||
251 | if not opts.get('dry_run'): |
|
251 | if not opts.get('dry_run'): | |
252 | # racy, both files cannot be renamed atomically |
|
252 | # racy, both files cannot be renamed atomically | |
253 | # copy files |
|
253 | # copy files | |
254 |
util.os |
|
254 | util.oslink(indexfn, oldindexfn) | |
255 |
ignoremissing(util.os |
|
255 | ignoremissing(util.oslink)(datafn, olddatafn) | |
256 |
|
256 | |||
257 | # rename |
|
257 | # rename | |
258 | util.rename(tmpindexfn, indexfn) |
|
258 | util.rename(tmpindexfn, indexfn) |
@@ -43,7 +43,7 b' def showhelp():' | |||||
43 |
|
43 | |||
44 | try: |
|
44 | try: | |
45 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
45 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |
46 |
util.set |
|
46 | util.setbinary(fp) | |
47 |
|
47 | |||
48 | opts = {} |
|
48 | opts = {} | |
49 | try: |
|
49 | try: |
@@ -7,7 +7,7 b' import sys' | |||||
7 | from mercurial import revlog, node, scmutil, util, transaction |
|
7 | from mercurial import revlog, node, scmutil, util, transaction | |
8 |
|
8 | |||
9 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
9 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |
10 |
util.set |
|
10 | util.setbinary(fp) | |
11 |
|
11 | |||
12 | opener = scmutil.opener('.', False) |
|
12 | opener = scmutil.opener('.', False) | |
13 | tr = transaction.transaction(sys.stderr.write, opener, "undump.journal") |
|
13 | tr = transaction.transaction(sys.stderr.write, opener, "undump.journal") |
@@ -33,6 +33,6 b' import mercurial.util' | |||||
33 | import mercurial.dispatch |
|
33 | import mercurial.dispatch | |
34 |
|
34 | |||
35 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
35 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |
36 |
mercurial.util.set |
|
36 | mercurial.util.setbinary(fp) | |
37 |
|
37 | |||
38 | mercurial.dispatch.run() |
|
38 | mercurial.dispatch.run() |
@@ -394,7 +394,7 b' class bzmysql(bzaccess):' | |||||
394 | if ret: |
|
394 | if ret: | |
395 | self.ui.warn(out) |
|
395 | self.ui.warn(out) | |
396 | raise util.Abort(_('bugzilla notify command %s') % |
|
396 | raise util.Abort(_('bugzilla notify command %s') % | |
397 |
util.explain |
|
397 | util.explainexit(ret)[0]) | |
398 | self.ui.status(_('done\n')) |
|
398 | self.ui.status(_('done\n')) | |
399 |
|
399 | |||
400 | def get_user_id(self, user): |
|
400 | def get_user_id(self, user): |
@@ -308,7 +308,7 b' class commandline(object):' | |||||
308 | if output: |
|
308 | if output: | |
309 | self.ui.warn(_('%s error:\n') % self.command) |
|
309 | self.ui.warn(_('%s error:\n') % self.command) | |
310 | self.ui.warn(output) |
|
310 | self.ui.warn(output) | |
311 |
msg = util.explain |
|
311 | msg = util.explainexit(status)[0] | |
312 | raise util.Abort('%s %s' % (self.command, msg)) |
|
312 | raise util.Abort('%s %s' % (self.command, msg)) | |
313 |
|
313 | |||
314 | def run0(self, cmd, *args, **kwargs): |
|
314 | def run0(self, cmd, *args, **kwargs): |
@@ -112,8 +112,8 b' def debugsvnlog(ui, **opts):' | |||||
112 | """Fetch SVN log in a subprocess and channel them back to parent to |
|
112 | """Fetch SVN log in a subprocess and channel them back to parent to | |
113 | avoid memory collection issues. |
|
113 | avoid memory collection issues. | |
114 | """ |
|
114 | """ | |
115 |
util.set |
|
115 | util.setbinary(sys.stdin) | |
116 |
util.set |
|
116 | util.setbinary(sys.stdout) | |
117 | args = decodeargs(sys.stdin.read()) |
|
117 | args = decodeargs(sys.stdin.read()) | |
118 | get_log_child(sys.stdout, *args) |
|
118 | get_log_child(sys.stdout, *args) | |
119 |
|
119 | |||
@@ -1011,7 +1011,7 b' class svn_sink(converter_sink, commandli' | |||||
1011 | fp = open(hook, 'w') |
|
1011 | fp = open(hook, 'w') | |
1012 | fp.write(pre_revprop_change) |
|
1012 | fp.write(pre_revprop_change) | |
1013 | fp.close() |
|
1013 | fp.close() | |
1014 |
util.set |
|
1014 | util.setflags(hook, False, True) | |
1015 |
|
1015 | |||
1016 | output = self.run0('info') |
|
1016 | output = self.run0('info') | |
1017 | self.uuid = self.uuid_re.search(output).group(1).strip() |
|
1017 | self.uuid = self.uuid_re.search(output).group(1).strip() | |
@@ -1038,7 +1038,7 b' class svn_sink(converter_sink, commandli' | |||||
1038 | # systematically is just as expensive and much simpler. |
|
1038 | # systematically is just as expensive and much simpler. | |
1039 | was_exec = 'x' not in flags |
|
1039 | was_exec = 'x' not in flags | |
1040 |
|
1040 | |||
1041 |
util.set |
|
1041 | util.setflags(self.wjoin(filename), False, 'x' in flags) | |
1042 | if was_exec: |
|
1042 | if was_exec: | |
1043 | if 'x' not in flags: |
|
1043 | if 'x' not in flags: | |
1044 | self.delexec.append(filename) |
|
1044 | self.delexec.append(filename) |
@@ -99,7 +99,7 b' def snapshot(ui, repo, files, node, tmpr' | |||||
99 | else: |
|
99 | else: | |
100 | wopener.write(wfn, data) |
|
100 | wopener.write(wfn, data) | |
101 | if 'x' in fctx.flags(): |
|
101 | if 'x' in fctx.flags(): | |
102 |
util.set |
|
102 | util.setflags(dest, False, True) | |
103 | if node is None: |
|
103 | if node is None: | |
104 | fns_and_mtime.append((dest, repo.wjoin(fn), |
|
104 | fns_and_mtime.append((dest, repo.wjoin(fn), | |
105 | os.lstat(dest).st_mtime)) |
|
105 | os.lstat(dest).st_mtime)) |
@@ -132,7 +132,7 b' def do_relink(src, dst, files, ui):' | |||||
132 | bak = dst + '.bak' |
|
132 | bak = dst + '.bak' | |
133 | os.rename(dst, bak) |
|
133 | os.rename(dst, bak) | |
134 | try: |
|
134 | try: | |
135 |
util.os |
|
135 | util.oslink(src, dst) | |
136 | except OSError: |
|
136 | except OSError: | |
137 | os.rename(bak, dst) |
|
137 | os.rename(bak, dst) | |
138 | raise |
|
138 | raise |
@@ -369,7 +369,7 b' def updatedir(ui, repo, patches, similar' | |||||
369 | if gp.op == 'ADD' and not os.path.lexists(dst): |
|
369 | if gp.op == 'ADD' and not os.path.lexists(dst): | |
370 | flags = (isexec and 'x' or '') + (islink and 'l' or '') |
|
370 | flags = (isexec and 'x' or '') + (islink and 'l' or '') | |
371 | repo.wwrite(gp.path, '', flags) |
|
371 | repo.wwrite(gp.path, '', flags) | |
372 |
util.set |
|
372 | util.setflags(dst, islink, isexec) | |
373 | addremove(repo, cfiles, similarity=similarity) |
|
373 | addremove(repo, cfiles, similarity=similarity) | |
374 | files = patches.keys() |
|
374 | files = patches.keys() | |
375 | files.extend([r for r in removes if r not in files]) |
|
375 | files.extend([r for r in removes if r not in files]) |
@@ -3758,7 +3758,7 b' def serve(ui, repo, **opts):' | |||||
3758 |
|
3758 | |||
3759 | class service(object): |
|
3759 | class service(object): | |
3760 | def init(self): |
|
3760 | def init(self): | |
3761 |
util.set |
|
3761 | util.setsignalhandler() | |
3762 | self.httpd = hgweb.server.create_server(ui, app) |
|
3762 | self.httpd = hgweb.server.create_server(ui, app) | |
3763 |
|
3763 | |||
3764 | if opts['port'] and not ui.verbose: |
|
3764 | if opts['port'] and not ui.verbose: |
@@ -29,7 +29,7 b' def _findtool(ui, tool):' | |||||
29 | k = _toolstr(ui, tool, kn) |
|
29 | k = _toolstr(ui, tool, kn) | |
30 | if not k: |
|
30 | if not k: | |
31 | continue |
|
31 | continue | |
32 |
p = util.lookup |
|
32 | p = util.lookupreg(k, _toolstr(ui, tool, "regname")) | |
33 | if p: |
|
33 | if p: | |
34 | p = util.find_exe(p + _toolstr(ui, tool, "regappend")) |
|
34 | p = util.find_exe(p + _toolstr(ui, tool, "regappend")) | |
35 | if p: |
|
35 | if p: |
@@ -13,8 +13,8 b' from mercurial import util' | |||||
13 | from mercurial.hgweb import common |
|
13 | from mercurial.hgweb import common | |
14 |
|
14 | |||
15 | def launch(application): |
|
15 | def launch(application): | |
16 |
util.set |
|
16 | util.setbinary(sys.stdin) | |
17 |
util.set |
|
17 | util.setbinary(sys.stdout) | |
18 |
|
18 | |||
19 | environ = dict(os.environ.iteritems()) |
|
19 | environ = dict(os.environ.iteritems()) | |
20 | environ.setdefault('PATH_INFO', '') |
|
20 | environ.setdefault('PATH_INFO', '') |
@@ -109,7 +109,7 b' def _exthook(ui, repo, name, cmd, args, ' | |||||
109 | else: |
|
109 | else: | |
110 | r = util.system(cmd, environ=env, cwd=cwd) |
|
110 | r = util.system(cmd, environ=env, cwd=cwd) | |
111 | if r: |
|
111 | if r: | |
112 |
desc, r = util.explain |
|
112 | desc, r = util.explainexit(r) | |
113 | if throw: |
|
113 | if throw: | |
114 | raise util.Abort(_('%s hook %s') % (name, desc)) |
|
114 | raise util.Abort(_('%s hook %s') % (name, desc)) | |
115 | ui.warn(_('warning: %s hook %s\n') % (name, desc)) |
|
115 | ui.warn(_('warning: %s hook %s\n') % (name, desc)) |
@@ -659,7 +659,7 b' class localrepository(repo.repository):' | |||||
659 | else: |
|
659 | else: | |
660 | self.wopener.write(filename, data) |
|
660 | self.wopener.write(filename, data) | |
661 | if 'x' in flags: |
|
661 | if 'x' in flags: | |
662 |
util.set |
|
662 | util.setflags(self.wjoin(filename), False, True) | |
663 |
|
663 | |||
664 | def wwritedata(self, filename, data): |
|
664 | def wwritedata(self, filename, data): | |
665 | return self._filter(self._decodefilterpats, filename, data) |
|
665 | return self._filter(self._decodefilterpats, filename, data) |
@@ -91,7 +91,7 b' def _sendmail(ui, sender, recipients, ms' | |||||
91 | if ret: |
|
91 | if ret: | |
92 | raise util.Abort('%s %s' % ( |
|
92 | raise util.Abort('%s %s' % ( | |
93 | os.path.basename(program.split(None, 1)[0]), |
|
93 | os.path.basename(program.split(None, 1)[0]), | |
94 |
util.explain |
|
94 | util.explainexit(ret)[0])) | |
95 |
|
95 | |||
96 | def connect(ui): |
|
96 | def connect(ui): | |
97 | '''make a mail connection. return a function to send mail. |
|
97 | '''make a mail connection. return a function to send mail. |
@@ -336,7 +336,7 b' def applyupdates(repo, action, wctx, mct' | |||||
336 | updated += 1 |
|
336 | updated += 1 | |
337 | else: |
|
337 | else: | |
338 | merged += 1 |
|
338 | merged += 1 | |
339 |
util.set |
|
339 | util.setflags(repo.wjoin(fd), 'l' in flags, 'x' in flags) | |
340 | if (move and repo.dirstate.normalize(fd) != f |
|
340 | if (move and repo.dirstate.normalize(fd) != f | |
341 | and os.path.lexists(repo.wjoin(f))): |
|
341 | and os.path.lexists(repo.wjoin(f))): | |
342 | repo.ui.debug("removing %s\n" % f) |
|
342 | repo.ui.debug("removing %s\n" % f) | |
@@ -370,7 +370,7 b' def applyupdates(repo, action, wctx, mct' | |||||
370 | repo.ui.warn(" %s\n" % nf) |
|
370 | repo.ui.warn(" %s\n" % nf) | |
371 | elif m == "e": # exec |
|
371 | elif m == "e": # exec | |
372 | flags = a[2] |
|
372 | flags = a[2] | |
373 |
util.set |
|
373 | util.setflags(repo.wjoin(f), 'l' in flags, 'x' in flags) | |
374 | ms.commit() |
|
374 | ms.commit() | |
375 | u.progress(_('updating'), None, total=numupdates, unit=_('files')) |
|
375 | u.progress(_('updating'), None, total=numupdates, unit=_('files')) | |
376 |
|
376 |
@@ -1172,7 +1172,7 b' def _externalpatch(patcher, patchname, u' | |||||
1172 | line = line.rstrip() |
|
1172 | line = line.rstrip() | |
1173 | ui.note(line + '\n') |
|
1173 | ui.note(line + '\n') | |
1174 | if line.startswith('patching file '): |
|
1174 | if line.startswith('patching file '): | |
1175 |
pf = util.parse |
|
1175 | pf = util.parsepatchoutput(line) | |
1176 | printed_file = False |
|
1176 | printed_file = False | |
1177 | files.setdefault(pf, None) |
|
1177 | files.setdefault(pf, None) | |
1178 | elif line.find('with fuzz') >= 0: |
|
1178 | elif line.find('with fuzz') >= 0: | |
@@ -1191,7 +1191,7 b' def _externalpatch(patcher, patchname, u' | |||||
1191 | code = fp.close() |
|
1191 | code = fp.close() | |
1192 | if code: |
|
1192 | if code: | |
1193 | raise PatchError(_("patch command failed: %s") % |
|
1193 | raise PatchError(_("patch command failed: %s") % | |
1194 |
util.explain |
|
1194 | util.explainexit(code)[0]) | |
1195 | return fuzz |
|
1195 | return fuzz | |
1196 |
|
1196 | |||
1197 | def internalpatch(patchobj, ui, strip, cwd, files=None, eolmode='strict'): |
|
1197 | def internalpatch(patchobj, ui, strip, cwd, files=None, eolmode='strict'): |
@@ -12,7 +12,7 b' posixfile = open' | |||||
12 | nulldev = '/dev/null' |
|
12 | nulldev = '/dev/null' | |
13 | normpath = os.path.normpath |
|
13 | normpath = os.path.normpath | |
14 | samestat = os.path.samestat |
|
14 | samestat = os.path.samestat | |
15 |
os |
|
15 | oslink = os.link | |
16 | unlink = os.unlink |
|
16 | unlink = os.unlink | |
17 | rename = os.rename |
|
17 | rename = os.rename | |
18 | expandglobs = False |
|
18 | expandglobs = False | |
@@ -28,7 +28,7 b' def nlinks(name):' | |||||
28 | '''return number of hardlinks for the given file''' |
|
28 | '''return number of hardlinks for the given file''' | |
29 | return os.lstat(name).st_nlink |
|
29 | return os.lstat(name).st_nlink | |
30 |
|
30 | |||
31 |
def parse |
|
31 | def parsepatchoutput(output_line): | |
32 | """parses the output produced by patch and returns the filename""" |
|
32 | """parses the output produced by patch and returns the filename""" | |
33 | pf = output_line[14:] |
|
33 | pf = output_line[14:] | |
34 | if os.sys.platform == 'OpenVMS': |
|
34 | if os.sys.platform == 'OpenVMS': | |
@@ -48,7 +48,7 b' def is_exec(f):' | |||||
48 | """check whether a file is executable""" |
|
48 | """check whether a file is executable""" | |
49 | return (os.lstat(f).st_mode & 0100 != 0) |
|
49 | return (os.lstat(f).st_mode & 0100 != 0) | |
50 |
|
50 | |||
51 |
def set |
|
51 | def setflags(f, l, x): | |
52 | s = os.lstat(f).st_mode |
|
52 | s = os.lstat(f).st_mode | |
53 | if l: |
|
53 | if l: | |
54 | if not stat.S_ISLNK(s): |
|
54 | if not stat.S_ISLNK(s): | |
@@ -128,7 +128,7 b' def checkosfilename(path):' | |||||
128 | Returns None if the path is ok, or a UI string describing the problem.''' |
|
128 | Returns None if the path is ok, or a UI string describing the problem.''' | |
129 | pass # on posix platforms, every path is ok |
|
129 | pass # on posix platforms, every path is ok | |
130 |
|
130 | |||
131 |
def set |
|
131 | def setbinary(fd): | |
132 | pass |
|
132 | pass | |
133 |
|
133 | |||
134 | def pconvert(path): |
|
134 | def pconvert(path): | |
@@ -210,7 +210,7 b' def testpid(pid):' | |||||
210 | except OSError, inst: |
|
210 | except OSError, inst: | |
211 | return inst.errno != errno.ESRCH |
|
211 | return inst.errno != errno.ESRCH | |
212 |
|
212 | |||
213 |
def explain |
|
213 | def explainexit(code): | |
214 | """return a 2-tuple (desc, code) describing a subprocess status |
|
214 | """return a 2-tuple (desc, code) describing a subprocess status | |
215 | (codes from kill are negative - not os.system/wait encoding)""" |
|
215 | (codes from kill are negative - not os.system/wait encoding)""" | |
216 | if code >= 0: |
|
216 | if code >= 0: | |
@@ -244,7 +244,7 b' def find_exe(command):' | |||||
244 | return executable |
|
244 | return executable | |
245 | return None |
|
245 | return None | |
246 |
|
246 | |||
247 |
def set |
|
247 | def setsignalhandler(): | |
248 | pass |
|
248 | pass | |
249 |
|
249 | |||
250 | def statfiles(files): |
|
250 | def statfiles(files): |
@@ -319,7 +319,7 b' def walkrepos(path, followsym=False, see' | |||||
319 | if err.filename == path: |
|
319 | if err.filename == path: | |
320 | raise err |
|
320 | raise err | |
321 | if followsym and hasattr(os.path, 'samestat'): |
|
321 | if followsym and hasattr(os.path, 'samestat'): | |
322 |
def |
|
322 | def adddir(dirlst, dirname): | |
323 | match = False |
|
323 | match = False | |
324 | samestat = os.path.samestat |
|
324 | samestat = os.path.samestat | |
325 | dirstat = os.stat(dirname) |
|
325 | dirstat = os.stat(dirname) | |
@@ -335,7 +335,7 b' def walkrepos(path, followsym=False, see' | |||||
335 |
|
335 | |||
336 | if (seen_dirs is None) and followsym: |
|
336 | if (seen_dirs is None) and followsym: | |
337 | seen_dirs = [] |
|
337 | seen_dirs = [] | |
338 |
|
|
338 | adddir(seen_dirs, path) | |
339 | for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler): |
|
339 | for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler): | |
340 | dirs.sort() |
|
340 | dirs.sort() | |
341 | if '.hg' in dirs: |
|
341 | if '.hg' in dirs: | |
@@ -352,7 +352,7 b' def walkrepos(path, followsym=False, see' | |||||
352 | newdirs = [] |
|
352 | newdirs = [] | |
353 | for d in dirs: |
|
353 | for d in dirs: | |
354 | fname = os.path.join(root, d) |
|
354 | fname = os.path.join(root, d) | |
355 |
if |
|
355 | if adddir(seen_dirs, fname): | |
356 | if os.path.islink(fname): |
|
356 | if os.path.islink(fname): | |
357 | for hgname in walkrepos(fname, True, seen_dirs): |
|
357 | for hgname in walkrepos(fname, True, seen_dirs): | |
358 | yield hgname |
|
358 | yield hgname | |
@@ -360,10 +360,10 b' def walkrepos(path, followsym=False, see' | |||||
360 | newdirs.append(d) |
|
360 | newdirs.append(d) | |
361 | dirs[:] = newdirs |
|
361 | dirs[:] = newdirs | |
362 |
|
362 | |||
363 |
def os |
|
363 | def osrcpath(): | |
364 | '''return default os-specific hgrc search path''' |
|
364 | '''return default os-specific hgrc search path''' | |
365 |
path = system |
|
365 | path = systemrcpath() | |
366 |
path.extend(user |
|
366 | path.extend(userrcpath()) | |
367 | path = [os.path.normpath(f) for f in path] |
|
367 | path = [os.path.normpath(f) for f in path] | |
368 | return path |
|
368 | return path | |
369 |
|
369 | |||
@@ -390,7 +390,7 b' def rcpath():' | |||||
390 | else: |
|
390 | else: | |
391 | _rcpath.append(p) |
|
391 | _rcpath.append(p) | |
392 | else: |
|
392 | else: | |
393 |
_rcpath = os |
|
393 | _rcpath = osrcpath() | |
394 | return _rcpath |
|
394 | return _rcpath | |
395 |
|
395 | |||
396 | if os.name != 'nt': |
|
396 | if os.name != 'nt': | |
@@ -406,7 +406,7 b" if os.name != 'nt':" | |||||
406 | pass |
|
406 | pass | |
407 | return rcs |
|
407 | return rcs | |
408 |
|
408 | |||
409 |
def system |
|
409 | def systemrcpath(): | |
410 | path = [] |
|
410 | path = [] | |
411 | # old mod_python does not set sys.argv |
|
411 | # old mod_python does not set sys.argv | |
412 | if len(getattr(sys, 'argv', [])) > 0: |
|
412 | if len(getattr(sys, 'argv', [])) > 0: | |
@@ -415,17 +415,17 b" if os.name != 'nt':" | |||||
415 | path.extend(rcfiles('/etc/mercurial')) |
|
415 | path.extend(rcfiles('/etc/mercurial')) | |
416 | return path |
|
416 | return path | |
417 |
|
417 | |||
418 |
def user |
|
418 | def userrcpath(): | |
419 | return [os.path.expanduser('~/.hgrc')] |
|
419 | return [os.path.expanduser('~/.hgrc')] | |
420 |
|
420 | |||
421 | else: |
|
421 | else: | |
422 |
|
422 | |||
423 | _HKEY_LOCAL_MACHINE = 0x80000002L |
|
423 | _HKEY_LOCAL_MACHINE = 0x80000002L | |
424 |
|
424 | |||
425 |
def system |
|
425 | def systemrcpath(): | |
426 | '''return default os-specific hgrc search path''' |
|
426 | '''return default os-specific hgrc search path''' | |
427 | rcpath = [] |
|
427 | rcpath = [] | |
428 |
filename = util.executable |
|
428 | filename = util.executablepath() | |
429 | # Use mercurial.ini found in directory with hg.exe |
|
429 | # Use mercurial.ini found in directory with hg.exe | |
430 | progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') |
|
430 | progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') | |
431 | if os.path.isfile(progrc): |
|
431 | if os.path.isfile(progrc): | |
@@ -439,8 +439,8 b' else:' | |||||
439 | rcpath.append(os.path.join(progrcd, f)) |
|
439 | rcpath.append(os.path.join(progrcd, f)) | |
440 | return rcpath |
|
440 | return rcpath | |
441 | # else look for a system rcpath in the registry |
|
441 | # else look for a system rcpath in the registry | |
442 |
value = util.lookup |
|
442 | value = util.lookupreg('SOFTWARE\\Mercurial', None, | |
443 |
|
|
443 | _HKEY_LOCAL_MACHINE) | |
444 | if not isinstance(value, str) or not value: |
|
444 | if not isinstance(value, str) or not value: | |
445 | return rcpath |
|
445 | return rcpath | |
446 | value = value.replace('/', os.sep) |
|
446 | value = value.replace('/', os.sep) | |
@@ -453,7 +453,7 b' else:' | |||||
453 | rcpath.append(os.path.join(p, f)) |
|
453 | rcpath.append(os.path.join(p, f)) | |
454 | return rcpath |
|
454 | return rcpath | |
455 |
|
455 | |||
456 |
def user |
|
456 | def userrcpath(): | |
457 | '''return os-specific hgrc search path to the user dir''' |
|
457 | '''return os-specific hgrc search path to the user dir''' | |
458 | home = os.path.expanduser('~') |
|
458 | home = os.path.expanduser('~') | |
459 | path = [os.path.join(home, 'mercurial.ini'), |
|
459 | path = [os.path.join(home, 'mercurial.ini'), |
@@ -21,8 +21,8 b' class sshserver(object):' | |||||
21 | sys.stdout = sys.stderr |
|
21 | sys.stdout = sys.stderr | |
22 |
|
22 | |||
23 | # Prevent insertion/deletion of CRs |
|
23 | # Prevent insertion/deletion of CRs | |
24 |
util.set |
|
24 | util.setbinary(self.fin) | |
25 |
util.set |
|
25 | util.setbinary(self.fout) | |
26 |
|
26 | |||
27 | def getargs(self, args): |
|
27 | def getargs(self, args): | |
28 | data = {} |
|
28 | data = {} |
@@ -197,7 +197,7 b' def tempfilter(s, cmd):' | |||||
197 | code = 0 |
|
197 | code = 0 | |
198 | if code: |
|
198 | if code: | |
199 | raise Abort(_("command '%s' failed: %s") % |
|
199 | raise Abort(_("command '%s' failed: %s") % | |
200 |
(cmd, explain |
|
200 | (cmd, explainexit(code))) | |
201 | fp = open(outname, 'rb') |
|
201 | fp = open(outname, 'rb') | |
202 | r = fp.read() |
|
202 | r = fp.read() | |
203 | fp.close() |
|
203 | fp.close() | |
@@ -297,7 +297,7 b' def pathto(root, n1, n2):' | |||||
297 |
|
297 | |||
298 | _hgexecutable = None |
|
298 | _hgexecutable = None | |
299 |
|
299 | |||
300 |
def main |
|
300 | def mainfrozen(): | |
301 | """return True if we are a frozen executable. |
|
301 | """return True if we are a frozen executable. | |
302 |
|
302 | |||
303 | The code supports py2exe (most common, Windows only) and tools/freeze |
|
303 | The code supports py2exe (most common, Windows only) and tools/freeze | |
@@ -315,15 +315,15 b' def hgexecutable():' | |||||
315 | if _hgexecutable is None: |
|
315 | if _hgexecutable is None: | |
316 | hg = os.environ.get('HG') |
|
316 | hg = os.environ.get('HG') | |
317 | if hg: |
|
317 | if hg: | |
318 |
set |
|
318 | _sethgexecutable(hg) | |
319 |
elif main |
|
319 | elif mainfrozen(): | |
320 |
set |
|
320 | _sethgexecutable(sys.executable) | |
321 | else: |
|
321 | else: | |
322 | exe = find_exe('hg') or os.path.basename(sys.argv[0]) |
|
322 | exe = find_exe('hg') or os.path.basename(sys.argv[0]) | |
323 |
set |
|
323 | _sethgexecutable(exe) | |
324 | return _hgexecutable |
|
324 | return _hgexecutable | |
325 |
|
325 | |||
326 |
def set |
|
326 | def _sethgexecutable(path): | |
327 | """set location of the 'hg' executable""" |
|
327 | """set location of the 'hg' executable""" | |
328 | global _hgexecutable |
|
328 | global _hgexecutable | |
329 | _hgexecutable = path |
|
329 | _hgexecutable = path | |
@@ -369,7 +369,7 b' def system(cmd, environ={}, cwd=None, on' | |||||
369 | rc = 0 |
|
369 | rc = 0 | |
370 | if rc and onerr: |
|
370 | if rc and onerr: | |
371 | errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]), |
|
371 | errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]), | |
372 |
explain |
|
372 | explainexit(rc)[0]) | |
373 | if errprefix: |
|
373 | if errprefix: | |
374 | errmsg = '%s: %s' % (errprefix, errmsg) |
|
374 | errmsg = '%s: %s' % (errprefix, errmsg) | |
375 | try: |
|
375 | try: | |
@@ -435,7 +435,7 b' def copyfiles(src, dst, hardlink=None):' | |||||
435 | else: |
|
435 | else: | |
436 | if hardlink: |
|
436 | if hardlink: | |
437 | try: |
|
437 | try: | |
438 |
os |
|
438 | oslink(src, dst) | |
439 | except (IOError, OSError): |
|
439 | except (IOError, OSError): | |
440 | hardlink = False |
|
440 | hardlink = False | |
441 | shutil.copy(src, dst) |
|
441 | shutil.copy(src, dst) | |
@@ -487,7 +487,7 b' def checkwinfilename(path):' | |||||
487 | return _("filename ends with '%s', which is not allowed " |
|
487 | return _("filename ends with '%s', which is not allowed " | |
488 | "on Windows") % t |
|
488 | "on Windows") % t | |
489 |
|
489 | |||
490 |
def lookup |
|
490 | def lookupreg(key, name=None, scope=None): | |
491 | return None |
|
491 | return None | |
492 |
|
492 | |||
493 | def hidewindow(): |
|
493 | def hidewindow(): | |
@@ -624,7 +624,7 b' def checknlink(testfile):' | |||||
624 | fd = None |
|
624 | fd = None | |
625 | try: |
|
625 | try: | |
626 | try: |
|
626 | try: | |
627 |
os |
|
627 | oslink(f1, f2) | |
628 | except OSError: |
|
628 | except OSError: | |
629 | return False |
|
629 | return False | |
630 |
|
630 | |||
@@ -1199,7 +1199,7 b' def hgcmd():' | |||||
1199 | to avoid things opening new shell windows like batch files, so we |
|
1199 | to avoid things opening new shell windows like batch files, so we | |
1200 | get either the python call or current executable. |
|
1200 | get either the python call or current executable. | |
1201 | """ |
|
1201 | """ | |
1202 |
if main |
|
1202 | if mainfrozen(): | |
1203 | return [sys.executable] |
|
1203 | return [sys.executable] | |
1204 | return gethgcmd() |
|
1204 | return gethgcmd() | |
1205 |
|
1205 |
@@ -140,7 +140,7 b' def _getfileinfo(name):' | |||||
140 | finally: |
|
140 | finally: | |
141 | _kernel32.CloseHandle(fh) |
|
141 | _kernel32.CloseHandle(fh) | |
142 |
|
142 | |||
143 |
def os |
|
143 | def oslink(src, dst): | |
144 | try: |
|
144 | try: | |
145 | if not _kernel32.CreateHardLinkA(dst, src, None): |
|
145 | if not _kernel32.CreateHardLinkA(dst, src, None): | |
146 | _raiseoserror(src) |
|
146 | _raiseoserror(src) | |
@@ -180,7 +180,7 b' def testpid(pid):' | |||||
180 | _kernel32.CloseHandle(h) |
|
180 | _kernel32.CloseHandle(h) | |
181 | return _kernel32.GetLastError() != _ERROR_INVALID_PARAMETER |
|
181 | return _kernel32.GetLastError() != _ERROR_INVALID_PARAMETER | |
182 |
|
182 | |||
183 |
def lookup |
|
183 | def lookupreg(key, valname=None, scope=None): | |
184 | ''' Look up a key/value name in the Windows registry. |
|
184 | ''' Look up a key/value name in the Windows registry. | |
185 |
|
185 | |||
186 | valname: value name. If unspecified, the default value for the key |
|
186 | valname: value name. If unspecified, the default value for the key | |
@@ -218,7 +218,7 b' def lookup_reg(key, valname=None, scope=' | |||||
218 | finally: |
|
218 | finally: | |
219 | adv.RegCloseKey(kh.value) |
|
219 | adv.RegCloseKey(kh.value) | |
220 |
|
220 | |||
221 |
def executable |
|
221 | def executablepath(): | |
222 | '''return full path of hg.exe''' |
|
222 | '''return full path of hg.exe''' | |
223 | size = 600 |
|
223 | size = 600 | |
224 | buf = ctypes.create_string_buffer(size + 1) |
|
224 | buf = ctypes.create_string_buffer(size + 1) | |
@@ -239,9 +239,9 b' def getuser():' | |||||
239 | return buf.value |
|
239 | return buf.value | |
240 |
|
240 | |||
241 | _SIGNAL_HANDLER = ctypes.WINFUNCTYPE(_BOOL, _DWORD) |
|
241 | _SIGNAL_HANDLER = ctypes.WINFUNCTYPE(_BOOL, _DWORD) | |
242 |
_signal |
|
242 | _signalhandler = [] | |
243 |
|
243 | |||
244 |
def set |
|
244 | def setsignalhandler(): | |
245 | '''Register a termination handler for console events including |
|
245 | '''Register a termination handler for console events including | |
246 | CTRL+C. python signal handlers do not work well with socket |
|
246 | CTRL+C. python signal handlers do not work well with socket | |
247 | operations. |
|
247 | operations. | |
@@ -249,10 +249,10 b' def set_signal_handler():' | |||||
249 | def handler(event): |
|
249 | def handler(event): | |
250 | _kernel32.ExitProcess(1) |
|
250 | _kernel32.ExitProcess(1) | |
251 |
|
251 | |||
252 |
if _signal |
|
252 | if _signalhandler: | |
253 | return # already registered |
|
253 | return # already registered | |
254 | h = _SIGNAL_HANDLER(handler) |
|
254 | h = _SIGNAL_HANDLER(handler) | |
255 |
_signal |
|
255 | _signalhandler.append(h) # needed to prevent garbage collection | |
256 | if not _kernel32.SetConsoleCtrlHandler(h, True): |
|
256 | if not _kernel32.SetConsoleCtrlHandler(h, True): | |
257 | raise ctypes.WinError() |
|
257 | raise ctypes.WinError() | |
258 |
|
258 |
@@ -74,7 +74,7 b' def _is_win_9x():' | |||||
74 | def openhardlinks(): |
|
74 | def openhardlinks(): | |
75 | return not _is_win_9x() |
|
75 | return not _is_win_9x() | |
76 |
|
76 | |||
77 |
def parse |
|
77 | def parsepatchoutput(output_line): | |
78 | """parses the output produced by patch and returns the filename""" |
|
78 | """parses the output produced by patch and returns the filename""" | |
79 | pf = output_line[14:] |
|
79 | pf = output_line[14:] | |
80 | if pf[0] == '`': |
|
80 | if pf[0] == '`': | |
@@ -87,7 +87,7 b' def sshargs(sshcmd, host, user, port):' | |||||
87 | args = user and ("%s@%s" % (user, host)) or host |
|
87 | args = user and ("%s@%s" % (user, host)) or host | |
88 | return port and ("%s %s %s" % (args, pflag, port)) or args |
|
88 | return port and ("%s %s %s" % (args, pflag, port)) or args | |
89 |
|
89 | |||
90 |
def set |
|
90 | def setflags(f, l, x): | |
91 | pass |
|
91 | pass | |
92 |
|
92 | |||
93 | def checkexec(path): |
|
93 | def checkexec(path): | |
@@ -96,7 +96,7 b' def checkexec(path):' | |||||
96 | def checklink(path): |
|
96 | def checklink(path): | |
97 | return False |
|
97 | return False | |
98 |
|
98 | |||
99 |
def set |
|
99 | def setbinary(fd): | |
100 | # When run without console, pipes may expose invalid |
|
100 | # When run without console, pipes may expose invalid | |
101 | # fileno(), usually set to -1. |
|
101 | # fileno(), usually set to -1. | |
102 | if hasattr(fd, 'fileno') and fd.fileno() >= 0: |
|
102 | if hasattr(fd, 'fileno') and fd.fileno() >= 0: | |
@@ -155,7 +155,7 b" def popen(command, mode='r'):" | |||||
155 | command += " 2> %s" % nulldev |
|
155 | command += " 2> %s" % nulldev | |
156 | return os.popen(quotecommand(command), mode) |
|
156 | return os.popen(quotecommand(command), mode) | |
157 |
|
157 | |||
158 |
def explain |
|
158 | def explainexit(code): | |
159 | return _("exited with status %d") % code, code |
|
159 | return _("exited with status %d") % code, code | |
160 |
|
160 | |||
161 | # if you change this stub into a real check, please try to implement the |
|
161 | # if you change this stub into a real check, please try to implement the |
General Comments 0
You need to be logged in to leave comments.
Login now