# HG changeset patch # User Matt Mackall # Date 1308892860 18000 # Node ID b5c60df21b4b266eb553193ea0d45f883f86d0d1 # Parent 8deebb5777511369a852e5cb42e69844c40ebf7a# Parent b9faf94ee1969f41b89edfc4df809adad582ab4c merge with stable diff -r 8deebb577751 -r b5c60df21b4b mercurial/commands.py --- a/mercurial/commands.py Tue Jun 21 17:27:20 2011 -0500 +++ b/mercurial/commands.py Fri Jun 24 00:21:00 2011 -0500 @@ -4181,8 +4181,12 @@ parent, p2 = repo.dirstate.parents() if not pats and not opts.get('all'): - raise util.Abort(_('no files or directories specified'), - hint=_('use --all to discard all changes')) + msg = _("no files or directories specified") + hint = _("use --all to discard all changes") + if p2 != nullid: + hint = _("uncommitted merge, use --all to discard all changes," + " or 'hg update -C .' to abort the merge") + raise util.Abort(msg, hint=hint) ctx = scmutil.revsingle(repo, opts.get('rev')) node = ctx.node() diff -r 8deebb577751 -r b5c60df21b4b mercurial/commandserver.py --- a/mercurial/commandserver.py Tue Jun 21 17:27:20 2011 -0500 +++ b/mercurial/commandserver.py Fri Jun 24 00:21:00 2011 -0500 @@ -205,8 +205,12 @@ 'getencoding' : getencoding} def serve(self): - self.cout.write('capabilities: %s' % ' '.join(self.capabilities.keys())) - self.cout.write('encoding: %s' % encoding.encoding) + hellomsg = 'capabilities: ' + ' '.join(self.capabilities.keys()) + hellomsg += '\n' + hellomsg += 'encoding: ' + encoding.encoding + + # write the hello msg in -one- chunk + self.cout.write(hellomsg) try: while self.serveone(): diff -r 8deebb577751 -r b5c60df21b4b mercurial/fileset.py --- a/mercurial/fileset.py Tue Jun 21 17:27:20 2011 -0500 +++ b/mercurial/fileset.py Fri Jun 24 00:21:00 2011 -0500 @@ -254,8 +254,7 @@ return int(float(s[:-len(k)]) * v) return int(s) except ValueError: - raise - raise error.ParseError(_("couldn't parse size"), s) + raise error.ParseError(_("couldn't parse size: %s") % s) def _sizetomax(s): try: @@ -271,8 +270,7 @@ # no extension, this is a precise value return int(s) except ValueError: - raise - raise error.ParseError(_("couldn't parse size"), s) + raise error.ParseError(_("couldn't parse size: %s") % s) def size(mctx, x): """``size(expression)`` @@ -284,7 +282,7 @@ - 4k - 1MB (files from 4096 bytes to 1048576 bytes) """ - expr = getstring(x, _("grep requires a pattern")).strip() + expr = getstring(x, _("size requires an expression")).strip() if '-' in expr: # do we have a range? a, b = expr.split('-', 1) a = _sizetoint(a) @@ -307,7 +305,7 @@ b = _sizetomax(expr) m = lambda x: x >= a and x <= b else: - raise error.ParseError(_("couldn't parse size"), expr) + raise error.ParseError(_("couldn't parse size: %s") % expr) return [f for f in mctx.subset if m(mctx.ctx[f].size())] @@ -337,6 +335,7 @@ """``copied()`` File that is recorded as being copied. """ + getargs(x, 0, 0, _("copied takes no arguments")) s = [] for f in mctx.subset: p = mctx.ctx[f].parents() diff -r 8deebb577751 -r b5c60df21b4b mercurial/match.py --- a/mercurial/match.py Tue Jun 21 17:27:20 2011 -0500 +++ b/mercurial/match.py Fri Jun 24 00:21:00 2011 -0500 @@ -282,8 +282,8 @@ l = len(pats) if l < 2: raise - pata, a = _buildmatch(pats[:l//2], tail) - patb, b = _buildmatch(pats[l//2:], tail) + pata, a = _buildregexmatch(pats[:l//2], tail) + patb, b = _buildregexmatch(pats[l//2:], tail) return pat, lambda s: a(s) or b(s) except re.error: for k, p in pats: diff -r 8deebb577751 -r b5c60df21b4b mercurial/revset.py --- a/mercurial/revset.py Tue Jun 21 17:27:20 2011 -0500 +++ b/mercurial/revset.py Fri Jun 24 00:21:00 2011 -0500 @@ -417,7 +417,7 @@ l = getargs(x, 0, 1, _("follow takes no arguments or a filename")) p = repo['.'].rev() if l: - x = getstring(l[0], "follow expected a filename") + x = getstring(l[0], _("follow expected a filename")) s = set(ctx.rev() for ctx in repo['.'][x].ancestors()) else: s = set(repo.changelog.ancestors(p)) @@ -425,7 +425,7 @@ s |= set([p]) return [r for r in subset if r in s] -def followfile(repo, subset, f): +def followfile(repo, subset, x): """``follow()`` An alias for ``::.`` (ancestors of the working copy's first parent). """ @@ -604,7 +604,7 @@ """ import hg # avoid start-up nasties # i18n: "outgoing" is a keyword - l = getargs(x, 0, 1, _("outgoing requires a repository path")) + l = getargs(x, 0, 1, _("outgoing takes one or no arguments")) # i18n: "outgoing" is a keyword dest = l and getstring(l[0], _("outgoing requires a repository path")) or '' dest = repo.ui.expandpath(dest or 'default-push', dest or 'default') @@ -954,70 +954,46 @@ class revsetalias(object): funcre = re.compile('^([^(]+)\(([^)]+)\)$') - args = () + args = None - def __init__(self, token, value): + def __init__(self, name, value): '''Aliases like: h = heads(default) b($1) = ancestors($1) - ancestors(default) ''' - if isinstance(token, tuple): - self.type, self.name = token - else: - m = self.funcre.search(token) + if isinstance(name, tuple): # parameter substitution + self.tree = name + self.replacement = value + else: # alias definition + m = self.funcre.search(name) if m: - self.type = 'func' - self.name = m.group(1) + self.tree = ('func', ('symbol', m.group(1))) self.args = [x.strip() for x in m.group(2).split(',')] + for arg in self.args: + value = value.replace(arg, repr(arg)) else: - self.type = 'symbol' - self.name = token + self.tree = ('symbol', name) - if isinstance(value, str): - for arg in self.args: - value = value.replace(arg, repr(arg)) self.replacement, pos = parse(value) if pos != len(value): raise error.ParseError(_('invalid token'), pos) - else: - self.replacement = value - - def match(self, tree): - if not tree: - return False - if tree == (self.type, self.name): - return True - if tree[0] != self.type: - return False - if len(tree) > 1 and tree[1] != ('symbol', self.name): - return False - # 'func' + funcname + args - if ((self.args and len(tree) != 3) or - (len(self.args) == 1 and tree[2][0] == 'list') or - (len(self.args) > 1 and (tree[2][0] != 'list' or - len(tree[2]) - 1 != len(self.args)))): - raise error.ParseError(_('invalid amount of arguments'), - len(tree) - 2) - return True - - def replace(self, tree): - if tree == (self.type, self.name): - return self.replacement - result = self.replacement - def getsubtree(i): - if tree[2][0] == 'list': - return tree[2][i + 1] - return tree[i + 2] - for i, v in enumerate(self.args): - valalias = revsetalias(('string', v), getsubtree(i)) - result = valalias.process(result) - return result def process(self, tree): - if self.match(tree): - return self.replace(tree) if isinstance(tree, tuple): + if self.args is None: + if tree == self.tree: + return self.replacement + elif tree[:2] == self.tree: + l = getlist(tree[2]) + if len(l) != len(self.args): + raise error.ParseError( + _('invalid number of arguments: %s') % len(l)) + result = self.replacement + for a, v in zip(self.args, l): + valalias = revsetalias(('string', a), v) + result = valalias.process(result) + return result return tuple(map(self.process, tree)) return tree diff -r 8deebb577751 -r b5c60df21b4b mercurial/scmutil.py --- a/mercurial/scmutil.py Tue Jun 21 17:27:20 2011 -0500 +++ b/mercurial/scmutil.py Fri Jun 24 00:21:00 2011 -0500 @@ -169,6 +169,7 @@ ''' def __init__(self, base, audit=True): self.base = base + self._audit = audit if audit: self.auditor = pathauditor(base) else: @@ -186,9 +187,10 @@ os.chmod(name, self.createmode & 0666) def __call__(self, path, mode="r", text=False, atomictemp=False): - r = util.checkosfilename(path) - if r: - raise util.Abort("%s: %r" % (r, path)) + if self._audit: + r = util.checkosfilename(path) + if r: + raise util.Abort("%s: %r" % (r, path)) self.auditor(path) f = os.path.join(self.base, path) diff -r 8deebb577751 -r b5c60df21b4b tests/test-confused-revert.t --- a/tests/test-confused-revert.t Tue Jun 21 17:27:20 2011 -0500 +++ b/tests/test-confused-revert.t Fri Jun 24 00:21:00 2011 -0500 @@ -60,7 +60,7 @@ $ hg revert abort: no files or directories specified - (use --all to discard all changes) + (uncommitted merge, use --all to discard all changes, or 'hg update -C .' to abort the merge) [255] Revert should be ok now: diff -r 8deebb577751 -r b5c60df21b4b tests/test-revset.t --- a/tests/test-revset.t Tue Jun 21 17:27:20 2011 -0500 +++ b/tests/test-revset.t Fri Jun 24 00:21:00 2011 -0500 @@ -420,6 +420,7 @@ $ echo 'm = merge()' >> .hg/hgrc $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc + $ echo 'rs4(ARG1, ARGA, ARGB, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc $ try m ('symbol', 'm') @@ -437,6 +438,23 @@ ('func', ('symbol', 'reverse'), ('func', ('symbol', 'sort'), ('list', ('or', ('symbol', '2'), ('symbol', '3')), ('symbol', 'date')))) 3 2 + $ try 'rs()' + ('func', ('symbol', 'rs'), None) + hg: parse error: invalid number of arguments: 0 + [255] + $ try 'rs(2)' + ('func', ('symbol', 'rs'), ('symbol', '2')) + hg: parse error: invalid number of arguments: 1 + [255] + $ try 'rs(2, data, 7)' + ('func', ('symbol', 'rs'), ('list', ('list', ('symbol', '2'), ('symbol', 'data')), ('symbol', '7'))) + hg: parse error: invalid number of arguments: 3 + [255] + $ try 'rs4(2 or 3, x, x, date)' + ('func', ('symbol', 'rs4'), ('list', ('list', ('list', ('or', ('symbol', '2'), ('symbol', '3')), ('symbol', 'x')), ('symbol', 'x')), ('symbol', 'date'))) + ('func', ('symbol', 'reverse'), ('func', ('symbol', 'sort'), ('list', ('or', ('symbol', '2'), ('symbol', '3')), ('symbol', 'date')))) + 3 + 2 issue2549 - correct optimizations