diff --git a/contrib/dumprevlog b/contrib/dumprevlog --- a/contrib/dumprevlog +++ b/contrib/dumprevlog @@ -6,7 +6,7 @@ import sys from mercurial import revlog, node, util for fp in (sys.stdin, sys.stdout, sys.stderr): - util.set_binary(fp) + util.setbinary(fp) for f in sys.argv[1:]: binopen = lambda fn: open(fn, 'rb') diff --git a/contrib/shrink-revlog.py b/contrib/shrink-revlog.py --- a/contrib/shrink-revlog.py +++ b/contrib/shrink-revlog.py @@ -251,8 +251,8 @@ def shrink(ui, repo, **opts): if not opts.get('dry_run'): # racy, both files cannot be renamed atomically # copy files - util.os_link(indexfn, oldindexfn) - ignoremissing(util.os_link)(datafn, olddatafn) + util.oslink(indexfn, oldindexfn) + ignoremissing(util.oslink)(datafn, olddatafn) # rename util.rename(tmpindexfn, indexfn) diff --git a/contrib/simplemerge b/contrib/simplemerge --- a/contrib/simplemerge +++ b/contrib/simplemerge @@ -43,7 +43,7 @@ def showhelp(): try: for fp in (sys.stdin, sys.stdout, sys.stderr): - util.set_binary(fp) + util.setbinary(fp) opts = {} try: diff --git a/contrib/undumprevlog b/contrib/undumprevlog --- a/contrib/undumprevlog +++ b/contrib/undumprevlog @@ -7,7 +7,7 @@ import sys from mercurial import revlog, node, scmutil, util, transaction for fp in (sys.stdin, sys.stdout, sys.stderr): - util.set_binary(fp) + util.setbinary(fp) opener = scmutil.opener('.', False) tr = transaction.transaction(sys.stderr.write, opener, "undump.journal") diff --git a/hg b/hg --- a/hg +++ b/hg @@ -33,6 +33,6 @@ import mercurial.util import mercurial.dispatch for fp in (sys.stdin, sys.stdout, sys.stderr): - mercurial.util.set_binary(fp) + mercurial.util.setbinary(fp) mercurial.dispatch.run() diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py --- a/hgext/bugzilla.py +++ b/hgext/bugzilla.py @@ -394,7 +394,7 @@ class bzmysql(bzaccess): if ret: self.ui.warn(out) raise util.Abort(_('bugzilla notify command %s') % - util.explain_exit(ret)[0]) + util.explainexit(ret)[0]) self.ui.status(_('done\n')) def get_user_id(self, user): diff --git a/hgext/convert/common.py b/hgext/convert/common.py --- a/hgext/convert/common.py +++ b/hgext/convert/common.py @@ -308,7 +308,7 @@ class commandline(object): if output: self.ui.warn(_('%s error:\n') % self.command) self.ui.warn(output) - msg = util.explain_exit(status)[0] + msg = util.explainexit(status)[0] raise util.Abort('%s %s' % (self.command, msg)) def run0(self, cmd, *args, **kwargs): diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -112,8 +112,8 @@ def debugsvnlog(ui, **opts): """Fetch SVN log in a subprocess and channel them back to parent to avoid memory collection issues. """ - util.set_binary(sys.stdin) - util.set_binary(sys.stdout) + util.setbinary(sys.stdin) + util.setbinary(sys.stdout) args = decodeargs(sys.stdin.read()) get_log_child(sys.stdout, *args) @@ -1011,7 +1011,7 @@ class svn_sink(converter_sink, commandli fp = open(hook, 'w') fp.write(pre_revprop_change) fp.close() - util.set_flags(hook, False, True) + util.setflags(hook, False, True) output = self.run0('info') self.uuid = self.uuid_re.search(output).group(1).strip() @@ -1038,7 +1038,7 @@ class svn_sink(converter_sink, commandli # systematically is just as expensive and much simpler. was_exec = 'x' not in flags - util.set_flags(self.wjoin(filename), False, 'x' in flags) + util.setflags(self.wjoin(filename), False, 'x' in flags) if was_exec: if 'x' not in flags: self.delexec.append(filename) diff --git a/hgext/extdiff.py b/hgext/extdiff.py --- a/hgext/extdiff.py +++ b/hgext/extdiff.py @@ -99,7 +99,7 @@ def snapshot(ui, repo, files, node, tmpr else: wopener.write(wfn, data) if 'x' in fctx.flags(): - util.set_flags(dest, False, True) + util.setflags(dest, False, True) if node is None: fns_and_mtime.append((dest, repo.wjoin(fn), os.lstat(dest).st_mtime)) diff --git a/hgext/relink.py b/hgext/relink.py --- a/hgext/relink.py +++ b/hgext/relink.py @@ -132,7 +132,7 @@ def do_relink(src, dst, files, ui): bak = dst + '.bak' os.rename(dst, bak) try: - util.os_link(src, dst) + util.oslink(src, dst) except OSError: os.rename(bak, dst) raise diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -369,7 +369,7 @@ def updatedir(ui, repo, patches, similar if gp.op == 'ADD' and not os.path.lexists(dst): flags = (isexec and 'x' or '') + (islink and 'l' or '') repo.wwrite(gp.path, '', flags) - util.set_flags(dst, islink, isexec) + util.setflags(dst, islink, isexec) addremove(repo, cfiles, similarity=similarity) files = patches.keys() files.extend([r for r in removes if r not in files]) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3758,7 +3758,7 @@ def serve(ui, repo, **opts): class service(object): def init(self): - util.set_signal_handler() + util.setsignalhandler() self.httpd = hgweb.server.create_server(ui, app) if opts['port'] and not ui.verbose: diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -29,7 +29,7 @@ def _findtool(ui, tool): k = _toolstr(ui, tool, kn) if not k: continue - p = util.lookup_reg(k, _toolstr(ui, tool, "regname")) + p = util.lookupreg(k, _toolstr(ui, tool, "regname")) if p: p = util.find_exe(p + _toolstr(ui, tool, "regappend")) if p: diff --git a/mercurial/hgweb/wsgicgi.py b/mercurial/hgweb/wsgicgi.py --- a/mercurial/hgweb/wsgicgi.py +++ b/mercurial/hgweb/wsgicgi.py @@ -13,8 +13,8 @@ from mercurial import util from mercurial.hgweb import common def launch(application): - util.set_binary(sys.stdin) - util.set_binary(sys.stdout) + util.setbinary(sys.stdin) + util.setbinary(sys.stdout) environ = dict(os.environ.iteritems()) environ.setdefault('PATH_INFO', '') diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -109,7 +109,7 @@ def _exthook(ui, repo, name, cmd, args, else: r = util.system(cmd, environ=env, cwd=cwd) if r: - desc, r = util.explain_exit(r) + desc, r = util.explainexit(r) if throw: raise util.Abort(_('%s hook %s') % (name, desc)) ui.warn(_('warning: %s hook %s\n') % (name, desc)) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -659,7 +659,7 @@ class localrepository(repo.repository): else: self.wopener.write(filename, data) if 'x' in flags: - util.set_flags(self.wjoin(filename), False, True) + util.setflags(self.wjoin(filename), False, True) def wwritedata(self, filename, data): return self._filter(self._decodefilterpats, filename, data) diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -91,7 +91,7 @@ def _sendmail(ui, sender, recipients, ms if ret: raise util.Abort('%s %s' % ( os.path.basename(program.split(None, 1)[0]), - util.explain_exit(ret)[0])) + util.explainexit(ret)[0])) def connect(ui): '''make a mail connection. return a function to send mail. diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -336,7 +336,7 @@ def applyupdates(repo, action, wctx, mct updated += 1 else: merged += 1 - util.set_flags(repo.wjoin(fd), 'l' in flags, 'x' in flags) + util.setflags(repo.wjoin(fd), 'l' in flags, 'x' in flags) if (move and repo.dirstate.normalize(fd) != f and os.path.lexists(repo.wjoin(f))): repo.ui.debug("removing %s\n" % f) @@ -370,7 +370,7 @@ def applyupdates(repo, action, wctx, mct repo.ui.warn(" %s\n" % nf) elif m == "e": # exec flags = a[2] - util.set_flags(repo.wjoin(f), 'l' in flags, 'x' in flags) + util.setflags(repo.wjoin(f), 'l' in flags, 'x' in flags) ms.commit() u.progress(_('updating'), None, total=numupdates, unit=_('files')) diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1172,7 +1172,7 @@ def _externalpatch(patcher, patchname, u line = line.rstrip() ui.note(line + '\n') if line.startswith('patching file '): - pf = util.parse_patch_output(line) + pf = util.parsepatchoutput(line) printed_file = False files.setdefault(pf, None) elif line.find('with fuzz') >= 0: @@ -1191,7 +1191,7 @@ def _externalpatch(patcher, patchname, u code = fp.close() if code: raise PatchError(_("patch command failed: %s") % - util.explain_exit(code)[0]) + util.explainexit(code)[0]) return fuzz def internalpatch(patchobj, ui, strip, cwd, files=None, eolmode='strict'): diff --git a/mercurial/posix.py b/mercurial/posix.py --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -12,7 +12,7 @@ posixfile = open nulldev = '/dev/null' normpath = os.path.normpath samestat = os.path.samestat -os_link = os.link +oslink = os.link unlink = os.unlink rename = os.rename expandglobs = False @@ -28,7 +28,7 @@ def nlinks(name): '''return number of hardlinks for the given file''' return os.lstat(name).st_nlink -def parse_patch_output(output_line): +def parsepatchoutput(output_line): """parses the output produced by patch and returns the filename""" pf = output_line[14:] if os.sys.platform == 'OpenVMS': @@ -48,7 +48,7 @@ def is_exec(f): """check whether a file is executable""" return (os.lstat(f).st_mode & 0100 != 0) -def set_flags(f, l, x): +def setflags(f, l, x): s = os.lstat(f).st_mode if l: if not stat.S_ISLNK(s): @@ -128,7 +128,7 @@ def checkosfilename(path): Returns None if the path is ok, or a UI string describing the problem.''' pass # on posix platforms, every path is ok -def set_binary(fd): +def setbinary(fd): pass def pconvert(path): @@ -210,7 +210,7 @@ def testpid(pid): except OSError, inst: return inst.errno != errno.ESRCH -def explain_exit(code): +def explainexit(code): """return a 2-tuple (desc, code) describing a subprocess status (codes from kill are negative - not os.system/wait encoding)""" if code >= 0: @@ -244,7 +244,7 @@ def find_exe(command): return executable return None -def set_signal_handler(): +def setsignalhandler(): pass def statfiles(files): diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -319,7 +319,7 @@ def walkrepos(path, followsym=False, see if err.filename == path: raise err if followsym and hasattr(os.path, 'samestat'): - def _add_dir_if_not_there(dirlst, dirname): + def adddir(dirlst, dirname): match = False samestat = os.path.samestat dirstat = os.stat(dirname) @@ -335,7 +335,7 @@ def walkrepos(path, followsym=False, see if (seen_dirs is None) and followsym: seen_dirs = [] - _add_dir_if_not_there(seen_dirs, path) + adddir(seen_dirs, path) for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler): dirs.sort() if '.hg' in dirs: @@ -352,7 +352,7 @@ def walkrepos(path, followsym=False, see newdirs = [] for d in dirs: fname = os.path.join(root, d) - if _add_dir_if_not_there(seen_dirs, fname): + if adddir(seen_dirs, fname): if os.path.islink(fname): for hgname in walkrepos(fname, True, seen_dirs): yield hgname @@ -360,10 +360,10 @@ def walkrepos(path, followsym=False, see newdirs.append(d) dirs[:] = newdirs -def os_rcpath(): +def osrcpath(): '''return default os-specific hgrc search path''' - path = system_rcpath() - path.extend(user_rcpath()) + path = systemrcpath() + path.extend(userrcpath()) path = [os.path.normpath(f) for f in path] return path @@ -390,7 +390,7 @@ def rcpath(): else: _rcpath.append(p) else: - _rcpath = os_rcpath() + _rcpath = osrcpath() return _rcpath if os.name != 'nt': @@ -406,7 +406,7 @@ if os.name != 'nt': pass return rcs - def system_rcpath(): + def systemrcpath(): path = [] # old mod_python does not set sys.argv if len(getattr(sys, 'argv', [])) > 0: @@ -415,17 +415,17 @@ if os.name != 'nt': path.extend(rcfiles('/etc/mercurial')) return path - def user_rcpath(): + def userrcpath(): return [os.path.expanduser('~/.hgrc')] else: _HKEY_LOCAL_MACHINE = 0x80000002L - def system_rcpath(): + def systemrcpath(): '''return default os-specific hgrc search path''' rcpath = [] - filename = util.executable_path() + filename = util.executablepath() # Use mercurial.ini found in directory with hg.exe progrc = os.path.join(os.path.dirname(filename), 'mercurial.ini') if os.path.isfile(progrc): @@ -439,8 +439,8 @@ else: rcpath.append(os.path.join(progrcd, f)) return rcpath # else look for a system rcpath in the registry - value = util.lookup_reg('SOFTWARE\\Mercurial', None, - _HKEY_LOCAL_MACHINE) + value = util.lookupreg('SOFTWARE\\Mercurial', None, + _HKEY_LOCAL_MACHINE) if not isinstance(value, str) or not value: return rcpath value = value.replace('/', os.sep) @@ -453,7 +453,7 @@ else: rcpath.append(os.path.join(p, f)) return rcpath - def user_rcpath(): + def userrcpath(): '''return os-specific hgrc search path to the user dir''' home = os.path.expanduser('~') path = [os.path.join(home, 'mercurial.ini'), diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py --- a/mercurial/sshserver.py +++ b/mercurial/sshserver.py @@ -21,8 +21,8 @@ class sshserver(object): sys.stdout = sys.stderr # Prevent insertion/deletion of CRs - util.set_binary(self.fin) - util.set_binary(self.fout) + util.setbinary(self.fin) + util.setbinary(self.fout) def getargs(self, args): data = {} diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -197,7 +197,7 @@ def tempfilter(s, cmd): code = 0 if code: raise Abort(_("command '%s' failed: %s") % - (cmd, explain_exit(code))) + (cmd, explainexit(code))) fp = open(outname, 'rb') r = fp.read() fp.close() @@ -297,7 +297,7 @@ def pathto(root, n1, n2): _hgexecutable = None -def main_is_frozen(): +def mainfrozen(): """return True if we are a frozen executable. The code supports py2exe (most common, Windows only) and tools/freeze @@ -315,15 +315,15 @@ def hgexecutable(): if _hgexecutable is None: hg = os.environ.get('HG') if hg: - set_hgexecutable(hg) - elif main_is_frozen(): - set_hgexecutable(sys.executable) + _sethgexecutable(hg) + elif mainfrozen(): + _sethgexecutable(sys.executable) else: exe = find_exe('hg') or os.path.basename(sys.argv[0]) - set_hgexecutable(exe) + _sethgexecutable(exe) return _hgexecutable -def set_hgexecutable(path): +def _sethgexecutable(path): """set location of the 'hg' executable""" global _hgexecutable _hgexecutable = path @@ -369,7 +369,7 @@ def system(cmd, environ={}, cwd=None, on rc = 0 if rc and onerr: errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]), - explain_exit(rc)[0]) + explainexit(rc)[0]) if errprefix: errmsg = '%s: %s' % (errprefix, errmsg) try: @@ -435,7 +435,7 @@ def copyfiles(src, dst, hardlink=None): else: if hardlink: try: - os_link(src, dst) + oslink(src, dst) except (IOError, OSError): hardlink = False shutil.copy(src, dst) @@ -487,7 +487,7 @@ def checkwinfilename(path): return _("filename ends with '%s', which is not allowed " "on Windows") % t -def lookup_reg(key, name=None, scope=None): +def lookupreg(key, name=None, scope=None): return None def hidewindow(): @@ -624,7 +624,7 @@ def checknlink(testfile): fd = None try: try: - os_link(f1, f2) + oslink(f1, f2) except OSError: return False @@ -1199,7 +1199,7 @@ def hgcmd(): to avoid things opening new shell windows like batch files, so we get either the python call or current executable. """ - if main_is_frozen(): + if mainfrozen(): return [sys.executable] return gethgcmd() diff --git a/mercurial/win32.py b/mercurial/win32.py --- a/mercurial/win32.py +++ b/mercurial/win32.py @@ -140,7 +140,7 @@ def _getfileinfo(name): finally: _kernel32.CloseHandle(fh) -def os_link(src, dst): +def oslink(src, dst): try: if not _kernel32.CreateHardLinkA(dst, src, None): _raiseoserror(src) @@ -180,7 +180,7 @@ def testpid(pid): _kernel32.CloseHandle(h) return _kernel32.GetLastError() != _ERROR_INVALID_PARAMETER -def lookup_reg(key, valname=None, scope=None): +def lookupreg(key, valname=None, scope=None): ''' Look up a key/value name in the Windows registry. valname: value name. If unspecified, the default value for the key @@ -218,7 +218,7 @@ def lookup_reg(key, valname=None, scope= finally: adv.RegCloseKey(kh.value) -def executable_path(): +def executablepath(): '''return full path of hg.exe''' size = 600 buf = ctypes.create_string_buffer(size + 1) @@ -239,9 +239,9 @@ def getuser(): return buf.value _SIGNAL_HANDLER = ctypes.WINFUNCTYPE(_BOOL, _DWORD) -_signal_handler = [] +_signalhandler = [] -def set_signal_handler(): +def setsignalhandler(): '''Register a termination handler for console events including CTRL+C. python signal handlers do not work well with socket operations. @@ -249,10 +249,10 @@ def set_signal_handler(): def handler(event): _kernel32.ExitProcess(1) - if _signal_handler: + if _signalhandler: return # already registered h = _SIGNAL_HANDLER(handler) - _signal_handler.append(h) # needed to prevent garbage collection + _signalhandler.append(h) # needed to prevent garbage collection if not _kernel32.SetConsoleCtrlHandler(h, True): raise ctypes.WinError() diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -74,7 +74,7 @@ def _is_win_9x(): def openhardlinks(): return not _is_win_9x() -def parse_patch_output(output_line): +def parsepatchoutput(output_line): """parses the output produced by patch and returns the filename""" pf = output_line[14:] if pf[0] == '`': @@ -87,7 +87,7 @@ def sshargs(sshcmd, host, user, port): args = user and ("%s@%s" % (user, host)) or host return port and ("%s %s %s" % (args, pflag, port)) or args -def set_flags(f, l, x): +def setflags(f, l, x): pass def checkexec(path): @@ -96,7 +96,7 @@ def checkexec(path): def checklink(path): return False -def set_binary(fd): +def setbinary(fd): # When run without console, pipes may expose invalid # fileno(), usually set to -1. if hasattr(fd, 'fileno') and fd.fileno() >= 0: @@ -155,7 +155,7 @@ def popen(command, mode='r'): command += " 2> %s" % nulldev return os.popen(quotecommand(command), mode) -def explain_exit(code): +def explainexit(code): return _("exited with status %d") % code, code # if you change this stub into a real check, please try to implement the