Mercurial > hg
changeset 14784:b64fd91adec5
merge with i18n
author | Wagner Bruna <wbruna@softwareexpress.com.br> |
---|---|
date | Mon, 27 Jun 2011 13:24:28 -0300 |
parents | 130113308856 (diff) a8663a3b72a0 (current diff) |
children | fc3a7a53e7b5 |
files | |
diffstat | 15 files changed, 141 insertions(+), 169 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/casesmash.py Mon Jun 27 13:24:28 2011 -0300 @@ -0,0 +1,34 @@ +import sys, os, __builtin__ +from mercurial import util + +def lowerwrap(scope, funcname): + f = getattr(scope, funcname) + def wrap(fname, *args, **kwargs): + d, base = os.path.split(fname) + try: + files = os.listdir(d or '.') + except OSError, inst: + files = [] + if base in files: + return f(fname, *args, **kwargs) + for fn in files: + if fn.lower() == base.lower(): + return f(os.path.join(d, fn), *args, **kwargs) + return f(fname, *args, **kwargs) + scope.__dict__[funcname] = wrap + +def normcase(path): + return path.lower() + +os.path.normcase = normcase + +for f in 'file open'.split(): + lowerwrap(__builtin__, f) + +for f in "chmod chown open lstat stat remove unlink".split(): + lowerwrap(os, f) + +for f in "exists lexists".split(): + lowerwrap(os.path, f) + +lowerwrap(util, 'posixfile')
--- a/hgext/mq.py Thu Jun 23 10:41:33 2011 +0400 +++ b/hgext/mq.py Mon Jun 27 13:24:28 2011 -0300 @@ -1134,6 +1134,8 @@ if start == len(self.series): self.ui.warn(_('patch series already fully applied\n')) return 1 + if not force: + self.checklocalchanges(repo, refresh=self.applied) if exact: if move: @@ -1172,19 +1174,6 @@ end = self.series.index(patch, start) + 1 s = self.series[start:end] - - if not force: - mm, aa, rr, dd = repo.status()[:4] - wcfiles = set(mm + aa + rr + dd) - if wcfiles: - for patchname in s: - pf = os.path.join(self.path, patchname) - patchfiles = patchmod.changedfiles(self.ui, repo, pf) - if wcfiles.intersection(patchfiles): - self.localchangesfound(self.applied) - elif mergeq: - self.checklocalchanges(refresh=self.applied) - all_files = set() try: if mergeq: @@ -1265,6 +1254,9 @@ break update = needupdate + if not force and update: + self.checklocalchanges(repo) + self.applieddirty = 1 end = len(self.applied) rev = self.applied[start].node @@ -1287,12 +1279,6 @@ qp = self.qparents(repo, rev) ctx = repo[qp] m, a, r, d = repo.status(qp, top)[:4] - parentfiles = set(m + a + r + d) - if not force and parentfiles: - mm, aa, rr, dd = repo.status()[:4] - wcfiles = set(mm + aa + rr + dd) - if wcfiles.intersection(parentfiles): - self.localchangesfound() if d: raise util.Abort(_("deletions found between repo revs")) for f in a:
--- a/mercurial/commands.py Thu Jun 23 10:41:33 2011 +0400 +++ b/mercurial/commands.py Mon Jun 27 13:24:28 2011 -0300 @@ -4179,13 +4179,24 @@ opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) parent, p2 = repo.dirstate.parents() + ctx = scmutil.revsingle(repo, opts.get('rev')) + node = ctx.node() if not pats and not opts.get('all'): - raise util.Abort(_('no files or directories specified'), - hint=_('use --all to revert all files')) - - ctx = scmutil.revsingle(repo, opts.get('rev')) - node = ctx.node() + 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") + elif node != parent: + if util.any(repo.status()): + hint = _("uncommitted changes, use --all to discard all" + " changes, or 'hg update %s' to update") % ctx.rev() + else: + hint = _("use --all to revert all files," + " or 'hg update %s' to update") % ctx.rev() + raise util.Abort(msg, hint=hint) + mf = ctx.manifest() if node == parent: pmf = mf @@ -5047,6 +5058,9 @@ found, the working directory is updated to the specified changeset. + Update sets the working directory's parent revison to the specified + changeset (see :hg:`help parents`). + The following rules apply when the working directory contains uncommitted changes: @@ -5068,8 +5082,8 @@ Use null as the changeset to remove the working directory (like :hg:`clone -U`). - If you want to update just one file to an older changeset, use - :hg:`revert`. + If you want to revert just one file to an older revision, use + :hg:`revert [-r REV] NAME`. See :hg:`help dates` for a list of formats valid for -d/--date.
--- a/mercurial/commandserver.py Thu Jun 23 10:41:33 2011 +0400 +++ b/mercurial/commandserver.py Mon Jun 27 13:24:28 2011 -0300 @@ -73,8 +73,8 @@ s = self._read(size, self.channel) buf = s while s: + s = self._read(size, self.channel) buf += s - s = self._read(size, self.channel) return buf else: @@ -104,8 +104,8 @@ # keep asking for more until there's either no more or # we got a full line while s and s[-1] != '\n': + s = self._read(size, 'L') buf += s - s = self._read(size, 'L') return buf else: @@ -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():
--- a/mercurial/dispatch.py Thu Jun 23 10:41:33 2011 +0400 +++ b/mercurial/dispatch.py Mon Jun 27 13:24:28 2011 -0300 @@ -654,7 +654,7 @@ return runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions) finally: - if repo: + if repo and repo != req.repo: repo.close() def _runcommand(ui, options, cmd, cmdfunc):
--- a/mercurial/fileset.py Thu Jun 23 10:41:33 2011 +0400 +++ b/mercurial/fileset.py Mon Jun 27 13:24:28 2011 -0300 @@ -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()
--- a/mercurial/hook.py Thu Jun 23 10:41:33 2011 +0400 +++ b/mercurial/hook.py Mon Jun 27 13:24:28 2011 -0300 @@ -107,7 +107,7 @@ if 'HG_URL' in env and env['HG_URL'].startswith('remote:http'): r = util.system(cmd, environ=env, cwd=cwd, out=ui) else: - r = util.system(cmd, environ=env, cwd=cwd) + r = util.system(cmd, environ=env, cwd=cwd, out=ui.fout) if r: desc, r = util.explainexit(r) if throw:
--- a/mercurial/match.py Thu Jun 23 10:41:33 2011 +0400 +++ b/mercurial/match.py Mon Jun 27 13:24:28 2011 -0300 @@ -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:
--- a/mercurial/revset.py Thu Jun 23 10:41:33 2011 +0400 +++ b/mercurial/revset.py Mon Jun 27 13:24:28 2011 -0300 @@ -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
--- a/mercurial/scmutil.py Thu Jun 23 10:41:33 2011 +0400 +++ b/mercurial/scmutil.py Mon Jun 27 13:24:28 2011 -0300 @@ -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)
--- a/tests/test-confused-revert.t Thu Jun 23 10:41:33 2011 +0400 +++ b/tests/test-confused-revert.t Mon Jun 27 13:24:28 2011 -0300 @@ -60,7 +60,7 @@ $ hg revert abort: no files or directories specified - (use --all to revert all files) + (uncommitted merge, use --all to discard all changes, or 'hg update -C .' to abort the merge) [255] Revert should be ok now:
--- a/tests/test-mq-qpush-exact.t Thu Jun 23 10:41:33 2011 +0400 +++ b/tests/test-mq-qpush-exact.t Mon Jun 27 13:24:28 2011 -0300 @@ -163,12 +163,8 @@ $ hg update 1 -q $ echo c0 >> f0 $ hg qpush -e - applying p0 - now at: p0 - $ cat f0 - c0 - $ hg qpop -aq - patch queue now empty + abort: local changes found + [255] $ hg qpush -ef applying p0 now at: p0 @@ -182,13 +178,8 @@ $ hg update 1 -q $ echo c0 >> f0 $ hg qpush -e p1 - applying p0 - applying p1 - now at: p1 - $ cat f0 - c0 - $ hg qpop -aq - patch queue now empty + abort: local changes found + [255] $ hg qpush -e p1 -f applying p0 applying p1
--- a/tests/test-mq.t Thu Jun 23 10:41:33 2011 +0400 +++ b/tests/test-mq.t Mon Jun 27 13:24:28 2011 -0300 @@ -1259,65 +1259,6 @@ now at: changea $ cd .. -test qpop with local changes, issue2780 - - $ hg init forcepop - $ cd forcepop - $ echo 1 > 1 - $ hg ci -Am 1 - adding 1 - $ hg qnew foo - $ echo 2 > 2 - $ hg add - adding 2 - -unrelated changes - - $ hg qpop - popping foo - patch queue now empty - -related changes - - $ hg forget 2 - $ rm 2 - $ hg qpush - applying foo - patch foo is empty - now at: foo - $ echo 2 >> 1 - $ hg qrefresh - $ echo 2 >> 1 - $ hg qpop - abort: local changes found, refresh first - [255] - $ hg st - M 1 - -related changes with force - $ hg qpop --force - popping foo - patch queue now empty - $ hg st - -related renamed source without change - $ hg qpush - applying foo - now at: foo - $ echo 1 > 1 - $ hg mv 1 2 - $ hg qref --git - $ hg qpop - popping foo - patch queue now empty - $ echo 3 > 1 - $ hg st - M 1 - $ hg qpush - abort: local changes found - [255] - $ cd .. - test qpush with --force, issue1087 $ hg init forcepush @@ -1334,9 +1275,16 @@ $ echo world >> hello.txt -apply, should not discard changes with empty patch +qpush should fail, local changes $ hg qpush + abort: local changes found + [255] + + +apply force, should not discard changes with empty patch + + $ hg qpush -f applying empty patch empty is empty now at: empty
--- a/tests/test-revert.t Thu Jun 23 10:41:33 2011 +0400 +++ b/tests/test-revert.t Mon Jun 27 13:24:28 2011 -0300 @@ -186,7 +186,7 @@ $ hg revert -rtip abort: no files or directories specified - (use --all to revert all files) + (use --all to revert all files, or 'hg update 1' to update) [255] should succeed
--- a/tests/test-revset.t Thu Jun 23 10:41:33 2011 +0400 +++ b/tests/test-revset.t Mon Jun 27 13:24:28 2011 -0300 @@ -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