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