# HG changeset patch # User Matt Mackall # Date 1309381541 18000 # Node ID 7ba7459875cb139ab996412b99d4a6c9dec0041f # Parent 2dbce40fcaea4ee4a004ff4f969208bde6f8fc59# Parent 68a697421a57d12ae667263afab11a6812ed4527 merge with i18n diff -r 68a697421a57 -r 7ba7459875cb contrib/check-code.py --- a/contrib/check-code.py Thu Jun 30 01:55:14 2011 +0900 +++ b/contrib/check-code.py Wed Jun 29 16:05:41 2011 -0500 @@ -128,7 +128,9 @@ # (r'\w*[a-z][A-Z]\w*\s*=', "don't use camelcase in identifiers"), (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+', "linebreak after :"), - (r'class\s[^(]:', "old-style class, use class foo(object)"), + (r'class\s[^( ]+:', "old-style class, use class foo(object)"), + (r'class\s[^( ]+\(\):', + "class foo() not available in Python 2.4, use class foo(object)"), (r'\b(%s)\(' % '|'.join(keyword.kwlist), "Python keyword is not a function"), (r',]', "unneeded trailing ',' in list"), diff -r 68a697421a57 -r 7ba7459875cb contrib/wix/guids.wxi --- a/contrib/wix/guids.wxi Thu Jun 30 01:55:14 2011 +0900 +++ b/contrib/wix/guids.wxi Wed Jun 29 16:05:41 2011 -0500 @@ -29,7 +29,7 @@ - + diff -r 68a697421a57 -r 7ba7459875cb contrib/wix/templates.wxs --- a/contrib/wix/templates.wxs Thu Jun 30 01:55:14 2011 +0900 +++ b/contrib/wix/templates.wxs Wed Jun 29 16:05:41 2011 -0500 @@ -114,6 +114,7 @@ + diff -r 68a697421a57 -r 7ba7459875cb doc/hgmanpage.py --- a/doc/hgmanpage.py Thu Jun 30 01:55:14 2011 +0900 +++ b/doc/hgmanpage.py Wed Jun 29 16:05:41 2011 -0500 @@ -104,7 +104,7 @@ self.output = visitor.astext() -class Table: +class Table(object): def __init__(self): self._rows = [] self._options = ['center'] @@ -300,7 +300,7 @@ pass def list_start(self, node): - class enum_char: + class enum_char(object): enum_style = { 'bullet' : '\\(bu', 'emdash' : '\\(em', diff -r 68a697421a57 -r 7ba7459875cb hgext/color.py --- a/hgext/color.py Thu Jun 30 01:55:14 2011 +0900 +++ b/hgext/color.py Wed Jun 29 16:05:41 2011 -0500 @@ -75,6 +75,14 @@ Some may not be available for a given terminal type, and will be silently ignored. +Note that on some systems, terminfo mode may cause problems when using +color with the pager extension and less -R. less with the -R option +will only display ECMA-48 color codes, and terminfo mode may sometimes +emit codes that less doesn't understand. You can work around this by +either using ansi mode (or auto mode), or by using less -r (which will +pass through all terminal control codes, not just color control +codes). + Because there are only eight standard colors, this module allows you to define color names for other color slots which might be available for your terminal type, assuming terminfo mode. For instance:: @@ -89,15 +97,15 @@ defined colors may then be used as any of the pre-defined eight, including appending '_background' to set the background to that color. -The color extension will try to detect whether to use terminfo, ANSI -codes or Win32 console APIs, unless it is made explicit; e.g.:: +By default, the color extension will use ANSI mode (or win32 mode on +Windows) if it detects a terminal. To override auto mode (to enable +terminfo mode, for example), set the following configuration option:: [color] - mode = ansi + mode = terminfo Any value other than 'ansi', 'win32', 'terminfo', or 'auto' will disable color. - ''' import os @@ -168,15 +176,14 @@ if os.name == 'nt' and 'TERM' not in os.environ: # looks line a cmd.exe console, use win32 API or nothing realmode = 'win32' - elif not formatted: + else: realmode = 'ansi' - else: - realmode = 'terminfo' if realmode == 'win32': - if not w32effects and mode == 'win32': - # only warn if color.mode is explicitly set to win32 - ui.warn(_('warning: failed to set color mode to %s\n') % mode) + if not w32effects: + if mode == 'win32': + # only warn if color.mode is explicitly set to win32 + ui.warn(_('warning: failed to set color mode to %s\n') % mode) return None _effects.update(w32effects) elif realmode == 'ansi': diff -r 68a697421a57 -r 7ba7459875cb mercurial/byterange.py --- a/mercurial/byterange.py Thu Jun 30 01:55:14 2011 +0900 +++ b/mercurial/byterange.py Wed Jun 29 16:05:41 2011 -0500 @@ -64,7 +64,7 @@ # HTTP's Range Not Satisfiable error raise RangeError('Requested Range Not Satisfiable') -class RangeableFileObject: +class RangeableFileObject(object): """File object wrapper to enable raw range handling. This was implemented primarilary for handling range specifications for file:// urls. This object effectively makes diff -r 68a697421a57 -r 7ba7459875cb mercurial/dispatch.py --- a/mercurial/dispatch.py Thu Jun 30 01:55:14 2011 +0900 +++ b/mercurial/dispatch.py Wed Jun 29 16:05:41 2011 -0500 @@ -125,6 +125,8 @@ commands.help_(ui, 'shortlist') except error.RepoError, inst: ui.warn(_("abort: %s!\n") % inst) + if inst.hint: + ui.warn(_("(%s)\n") % inst.hint) except error.ResponseError, inst: ui.warn(_("abort: %s") % inst.args[0]) if not isinstance(inst.args[1], basestring): diff -r 68a697421a57 -r 7ba7459875cb mercurial/error.py --- a/mercurial/error.py Thu Jun 30 01:55:14 2011 +0900 +++ b/mercurial/error.py Wed Jun 29 16:05:41 2011 -0500 @@ -43,7 +43,9 @@ 'Exception raised when parsing config files (msg[, pos])' class RepoError(Exception): - pass + def __init__(self, *args, **kw): + Exception.__init__(self, *args) + self.hint = kw.get('hint') class RepoLookupError(RepoError): pass diff -r 68a697421a57 -r 7ba7459875cb mercurial/hgweb/server.py --- a/mercurial/hgweb/server.py Thu Jun 30 01:55:14 2011 +0900 +++ b/mercurial/hgweb/server.py Wed Jun 29 16:05:41 2011 -0500 @@ -251,7 +251,7 @@ if hasattr(os, "fork"): _mixin = SocketServer.ForkingMixIn else: - class _mixin: + class _mixin(object): pass def openlog(opt, default): diff -r 68a697421a57 -r 7ba7459875cb mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Thu Jun 30 01:55:14 2011 +0900 +++ b/mercurial/hgweb/webcommands.py Wed Jun 29 16:05:41 2011 -0500 @@ -432,10 +432,10 @@ if limit > 0 and count >= limit: return count += 1 - if ctx.node() not in heads: + if not web.repo.branchheads(ctx.branch()): + status = 'closed' + elif ctx.node() not in heads: status = 'inactive' - elif not web.repo.branchheads(ctx.branch()): - status = 'closed' else: status = 'open' yield {'parity': parity.next(), diff -r 68a697421a57 -r 7ba7459875cb mercurial/keepalive.py --- a/mercurial/keepalive.py Thu Jun 30 01:55:14 2011 +0900 +++ b/mercurial/keepalive.py Wed Jun 29 16:05:41 2011 -0500 @@ -124,7 +124,7 @@ HANDLE_ERRORS = 1 else: HANDLE_ERRORS = 0 -class ConnectionManager: +class ConnectionManager(object): """ The connection manager must be able to: * keep track of all existing @@ -187,7 +187,7 @@ else: return dict(self._hostmap) -class KeepAliveHandler: +class KeepAliveHandler(object): def __init__(self): self._cm = ConnectionManager() @@ -705,7 +705,7 @@ def test_timeout(url): global DEBUG dbbackup = DEBUG - class FakeLogger: + class FakeLogger(object): def debug(self, msg, *args): print msg % args info = warning = error = debug diff -r 68a697421a57 -r 7ba7459875cb mercurial/patch.py --- a/mercurial/patch.py Thu Jun 30 01:55:14 2011 +0900 +++ b/mercurial/patch.py Wed Jun 29 16:05:41 2011 -0500 @@ -1009,7 +1009,7 @@ def new(self, fuzz=0, toponly=False): return self.fuzzit(self.b, fuzz, toponly) -class binhunk: +class binhunk(object): 'A binary patch file. Only understands literals so far.' def __init__(self, lr): self.text = None diff -r 68a697421a57 -r 7ba7459875cb mercurial/subrepo.py --- a/mercurial/subrepo.py Thu Jun 30 01:55:14 2011 +0900 +++ b/mercurial/subrepo.py Wed Jun 29 16:05:41 2011 -0500 @@ -198,9 +198,9 @@ or on the top repo config. Abort or return None if no source found.""" if hasattr(repo, '_subparent'): source = util.url(repo._subsource) + if source.isabs(): + return str(source) source.path = posixpath.normpath(source.path) - if posixpath.isabs(source.path) or source.scheme: - return str(source) parent = _abssource(repo._subparent, push, abort=False) if parent: parent = util.url(parent) diff -r 68a697421a57 -r 7ba7459875cb mercurial/util.py --- a/mercurial/util.py Thu Jun 30 01:55:14 2011 +0900 +++ b/mercurial/util.py Wed Jun 29 16:05:41 2011 -0500 @@ -1555,6 +1555,17 @@ return (s, (None, (str(self), self.host), self.user, self.passwd or '')) + def isabs(self): + if self.scheme and self.scheme != 'file': + return True # remote URL + if hasdriveletter(self.path): + return True # absolute for our purposes - can't be joined() + if self.path.startswith(r'\\'): + return True # Windows UNC path + if self.path.startswith('/'): + return True # POSIX-style + return False + def localpath(self): if self.scheme == 'file' or self.scheme == 'bundle': path = self.path or '/' diff -r 68a697421a57 -r 7ba7459875cb tests/test-batching.py --- a/tests/test-batching.py Thu Jun 30 01:55:14 2011 +0900 +++ b/tests/test-batching.py Wed Jun 29 16:05:41 2011 -0500 @@ -85,7 +85,7 @@ # server side # equivalent of wireproto's global functions -class server: +class server(object): def __init__(self, local): self.local = local def _call(self, name, args): diff -r 68a697421a57 -r 7ba7459875cb tests/test-check-code.t --- a/tests/test-check-code.t Thu Jun 30 01:55:14 2011 +0900 +++ b/tests/test-check-code.t Wed Jun 29 16:05:41 2011 -0500 @@ -27,8 +27,21 @@ > def any(x): > pass > EOF + $ cat > classstyle.py < class newstyle_class(object): + > pass + > + > class oldstyle_class: + > pass + > + > class empty(): + > pass + > + > no_class = 1: + > pass + > EOF $ check_code="$TESTDIR"/../contrib/check-code.py - $ "$check_code" ./wrong.py ./correct.py ./quote.py ./non-py24.py + $ "$check_code" ./wrong.py ./correct.py ./quote.py ./non-py24.py ./classstyle.py ./wrong.py:1: > def toto( arg1, arg2): gratuitous whitespace in () or [] @@ -51,6 +64,12 @@ ./non-py24.py:4: > y = format(x) any/all/format not available in Python 2.4 + ./classstyle.py:4: + > class oldstyle_class: + old-style class, use class foo(object) + ./classstyle.py:7: + > class empty(): + class foo() not available in Python 2.4, use class foo(object) [1] $ cat > is-op.py <I', len(data))) + server.stdin.write(data) + server.stdin.flush() + +def readchannel(server): + data = server.stdout.read(5) + if not data: + raise EOFError() + channel, length = struct.unpack('>cI', data) + if channel in 'IL': + return channel, length + else: + return channel, server.stdout.read(length) + +def runcommand(server, args, output=sys.stdout, error=sys.stderr, input=None): + server.stdin.write('runcommand\n') + writeblock(server, '\0'.join(args)) + + if not input: + input = cStringIO.StringIO() + + while True: + ch, data = readchannel(server) + if ch == 'o': + output.write(data) + output.flush() + elif ch == 'e': + error.write(data) + error.flush() + elif ch == 'I': + writeblock(server, input.read(data)) + elif ch == 'L': + writeblock(server, input.readline(data)) + elif ch == 'r': + return struct.unpack('>i', data)[0] + else: + print "unexpected channel %c: %r" % (ch, data) + if ch.isupper(): + return + +def check(func, repopath=None): + server = connect(repopath) + try: + return func(server) + finally: + server.stdin.close() + server.wait() + +def unknowncommand(server): + server.stdin.write('unknowncommand\n') + +def hellomessage(server): + ch, data = readchannel(server) + # escaping python tests output not supported + print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', 'encoding: ***', data)) + + # run an arbitrary command to make sure the next thing the server sends + # isn't part of the hello message + runcommand(server, ['id']) + +def checkruncommand(server): + # hello block + readchannel(server) + + # no args + runcommand(server, []) + + # global options + runcommand(server, ['id', '--quiet']) + + # make sure global options don't stick through requests + runcommand(server, ['id']) + + # --config + runcommand(server, ['id', '--config', 'ui.quiet=True']) + + # make sure --config doesn't stick + runcommand(server, ['id']) + +def inputeof(server): + readchannel(server) + server.stdin.write('runcommand\n') + # close stdin while server is waiting for input + server.stdin.close() + + # server exits with 1 if the pipe closed while reading the command + print 'server exit code =', server.wait() + +def serverinput(server): + readchannel(server) + + patch = """ +# HG changeset patch +# User test +# Date 0 0 +# Node ID c103a3dec114d882c98382d684d8af798d09d857 +# Parent 0000000000000000000000000000000000000000 +1 + +diff -r 000000000000 -r c103a3dec114 a +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/a Thu Jan 01 00:00:00 1970 +0000 +@@ -0,0 +1,1 @@ ++1 +""" + + runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch)) + runcommand(server, ['log']) + +if __name__ == '__main__': + os.system('hg init') + + check(hellomessage) + check(unknowncommand) + check(checkruncommand) + check(inputeof) + check(serverinput) diff -r 68a697421a57 -r 7ba7459875cb tests/test-commandserver.py.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-commandserver.py.out Wed Jun 29 16:05:41 2011 -0500 @@ -0,0 +1,38 @@ +o, 'capabilities: getencoding runcommand\nencoding: ***' +000000000000 tip +abort: unknown command unknowncommand +Mercurial Distributed SCM + +basic commands: + + add add the specified files on the next commit + annotate show changeset information by line for each file + clone make a copy of an existing repository + commit commit the specified files or all outstanding changes + diff diff repository (or selected files) + export dump the header and diffs for one or more changesets + forget forget the specified files on the next commit + init create a new repository in the given directory + log show revision history of entire repository or files + merge merge working directory with another revision + pull pull changes from the specified source + push push changes to the specified destination + remove remove the specified files on the next commit + serve start stand-alone webserver + status show changed files in the working directory + summary summarize working directory state + update update working directory (or switch revisions) + +use "hg help" for the full list of commands or "hg -v" for details +000000000000 +000000000000 tip +000000000000 +000000000000 tip +server exit code = 1 +applying patch from stdin +changeset: 0:eff892de26ec +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +summary: 1 + diff -r 68a697421a57 -r 7ba7459875cb tests/test-duplicateoptions.py --- a/tests/test-duplicateoptions.py Thu Jun 30 01:55:14 2011 +0900 +++ b/tests/test-duplicateoptions.py Wed Jun 29 16:05:41 2011 -0500 @@ -1,7 +1,7 @@ import os from mercurial import ui, commands, extensions -ignore = set(['highlight', 'win32text']) +ignore = set(['highlight', 'inotify', 'win32text']) if os.name != 'nt': ignore.add('win32mbcs') diff -r 68a697421a57 -r 7ba7459875cb tests/test-revert.t --- a/tests/test-revert.t Thu Jun 30 01:55:14 2011 +0900 +++ b/tests/test-revert.t Wed Jun 29 16:05:41 2011 -0500 @@ -12,6 +12,7 @@ abort: no files or directories specified (use --all to revert all files) [255] + $ hg revert --all $ echo 123 > b diff -r 68a697421a57 -r 7ba7459875cb tests/test-wireproto.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-wireproto.py Wed Jun 29 16:05:41 2011 -0500 @@ -0,0 +1,45 @@ +from mercurial import wireproto + +class proto(object): + def __init__(self, args): + self.args = args + def getargs(self, spec): + args = self.args + args.setdefault('*', {}) + names = spec.split() + return [args[n] for n in names] + +class clientrepo(wireproto.wirerepository): + def __init__(self, serverrepo): + self.serverrepo = serverrepo + def _call(self, cmd, **args): + return wireproto.dispatch(self.serverrepo, proto(args), cmd) + + @wireproto.batchable + def greet(self, name): + f = wireproto.future() + yield wireproto.todict(name=mangle(name)), f + yield unmangle(f.value) + +class serverrepo(object): + def greet(self, name): + return "Hello, " + name + +def mangle(s): + return ''.join(chr(ord(c) + 1) for c in s) +def unmangle(s): + return ''.join(chr(ord(c) - 1) for c in s) + +def greet(repo, proto, name): + return mangle(repo.greet(unmangle(name))) + +wireproto.commands['greet'] = (greet, 'name',) + +srv = serverrepo() +clt = clientrepo(srv) + +print clt.greet("Foobar") +b = clt.batch() +fs = [b.greet(s) for s in ["Fo, =;o", "Bar"]] +b.submit() +print [f.value for f in fs] diff -r 68a697421a57 -r 7ba7459875cb tests/test-wireproto.py.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-wireproto.py.out Wed Jun 29 16:05:41 2011 -0500 @@ -0,0 +1,2 @@ +Hello, Foobar +['Hello, Fo, =;o', 'Hello, Bar'] diff -r 68a697421a57 -r 7ba7459875cb tests/test-wireprotocol.py --- a/tests/test-wireprotocol.py Thu Jun 30 01:55:14 2011 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -from mercurial import wireproto - -class proto(): - def __init__(self, args): - self.args = args - def getargs(self, spec): - args = self.args - args.setdefault('*', {}) - names = spec.split() - return [args[n] for n in names] - -class clientrepo(wireproto.wirerepository): - def __init__(self, serverrepo): - self.serverrepo = serverrepo - def _call(self, cmd, **args): - return wireproto.dispatch(self.serverrepo, proto(args), cmd) - - @wireproto.batchable - def greet(self, name): - f = wireproto.future() - yield wireproto.todict(name=mangle(name)), f - yield unmangle(f.value) - -class serverrepo(): - def greet(self, name): - return "Hello, " + name - -def mangle(s): - return ''.join(chr(ord(c) + 1) for c in s) -def unmangle(s): - return ''.join(chr(ord(c) - 1) for c in s) - -def greet(repo, proto, name): - return mangle(repo.greet(unmangle(name))) - -wireproto.commands['greet'] = (greet, 'name',) - -srv = serverrepo() -clt = clientrepo(srv) - -print clt.greet("Foobar") -b = clt.batch() -fs = [b.greet(s) for s in ["Fo, =;o", "Bar"]] -b.submit() -print [f.value for f in fs] diff -r 68a697421a57 -r 7ba7459875cb tests/test-wireprotocol.py.out --- a/tests/test-wireprotocol.py.out Thu Jun 30 01:55:14 2011 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -Hello, Foobar -['Hello, Fo, =;o', 'Hello, Bar']