diff --git a/contrib/hg-ssh b/contrib/hg-ssh --- a/contrib/hg-ssh +++ b/contrib/hg-ssh @@ -40,8 +40,8 @@ orig_cmd = os.getenv('SSH_ORIGINAL_COMMA try: cmdargv = shlex.split(orig_cmd) except ValueError, e: - sys.stderr.write("Illegal command %r: %s\n" % (orig_cmd, e)) - sys.exit(-1) + sys.stderr.write('Illegal command "%s": %s\n' % (orig_cmd, e)) + sys.exit(255) if cmdargv[:2] == ['hg', '-R'] and cmdargv[3:] == ['serve', '--stdio']: path = cmdargv[2] @@ -49,9 +49,9 @@ if cmdargv[:2] == ['hg', '-R'] and cmdar if repo in allowed_paths: dispatch.dispatch(dispatch.request(['-R', repo, 'serve', '--stdio'])) else: - sys.stderr.write("Illegal repository %r\n" % repo) - sys.exit(-1) + sys.stderr.write('Illegal repository "%s"\n' % repo) + sys.exit(255) else: - sys.stderr.write("Illegal command %r\n" % orig_cmd) - sys.exit(-1) + sys.stderr.write('Illegal command "%s"\n' % orig_cmd) + sys.exit(255) diff --git a/doc/hgmanpage.py b/doc/hgmanpage.py --- a/doc/hgmanpage.py +++ b/doc/hgmanpage.py @@ -47,7 +47,10 @@ by the command whatis or apropos. import re from docutils import nodes, writers, languages -import roman +try: + import roman +except ImportError: + from docutils.utils import roman import inspect FIELD_LIST_INDENT = 7 diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -153,6 +153,7 @@ class changelog(revlog.revlog): r = revlog.revlog(self.opener, file) self.index = r.index self.nodemap = r.nodemap + self._nodecache = r._nodecache self._chunkcache = r._chunkcache def writepending(self): diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -243,6 +243,7 @@ class cmdalias(object): self.opts = [] self.help = '' self.norepo = True + self.optionalrepo = False self.badalias = False try: @@ -312,6 +313,8 @@ class cmdalias(object): self.args = aliasargs(self.fn, args) if cmd not in commands.norepo.split(' '): self.norepo = False + if cmd in commands.optionalrepo.split(' '): + self.optionalrepo = True if self.help.startswith("hg " + cmd): # drop prefix in old-style help lines so hg shows the alias self.help = self.help[4 + len(cmd):] @@ -370,6 +373,8 @@ def addaliases(ui, cmdtable): cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help) if aliasdef.norepo: commands.norepo += ' %s' % alias + if aliasdef.optionalrepo: + commands.optionalrepo += ' %s' % alias def _parse(ui, args): options = {} @@ -495,7 +500,6 @@ def _getlocal(ui, rpath): return path, lui def _checkshellalias(lui, ui, args): - norepo = commands.norepo options = {} try: @@ -506,6 +510,12 @@ def _checkshellalias(lui, ui, args): if not args: return + norepo = commands.norepo + optionalrepo = commands.optionalrepo + def restorecommands(): + commands.norepo = norepo + commands.optionalrepo = optionalrepo + cmdtable = commands.table.copy() addaliases(lui, cmdtable) @@ -514,7 +524,7 @@ def _checkshellalias(lui, ui, args): aliases, entry = cmdutil.findcmd(cmd, cmdtable, lui.configbool("ui", "strict")) except (error.AmbiguousCommand, error.UnknownCommand): - commands.norepo = norepo + restorecommands() return cmd = aliases[0] @@ -524,7 +534,7 @@ def _checkshellalias(lui, ui, args): d = lambda: fn(ui, *args[1:]) return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {}) - commands.norepo = norepo + restorecommands() _loaded = set() def _dispatch(req): diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -1113,7 +1113,6 @@ static PyTypeObject indexType = { 0, /* tp_dictoffset */ (initproc)index_init, /* tp_init */ 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ }; /* @@ -1171,6 +1170,7 @@ static PyMethodDef methods[] = { static void module_init(PyObject *mod) { + indexType.tp_new = PyType_GenericNew; if (PyType_Ready(&indexType) < 0) return; Py_INCREF(&indexType); diff --git a/tests/test-alias.t b/tests/test-alias.t --- a/tests/test-alias.t +++ b/tests/test-alias.t @@ -9,6 +9,7 @@ > # should clobber ci but not commit (issue2993) > ci = version > myinit = init + > optionalrepo = showconfig alias.myinit > cleanstatus = status -c > unknown = bargle > ambiguous = s @@ -108,8 +109,17 @@ invalid options $ hg help no--repository error in definition for alias 'no--repository': --repository may only be given on the command line +optional repository + + $ hg optionalrepo + init $ cd alias - + $ cat > .hg/hgrc < [alias] + > myinit = init -q + > EOF + $ hg optionalrepo + init -q no usage diff --git a/tests/test-casefolding.t b/tests/test-casefolding.t --- a/tests/test-casefolding.t +++ b/tests/test-casefolding.t @@ -57,14 +57,14 @@ test changing case of path components A D/c $ hg ci -m addc D/c $ hg mv d/b d/e - moving D/b to D/e + moving D/b to D/e (glob) $ hg st A D/e R D/b $ hg revert -aq $ rm d/e $ hg mv d/b D/B - moving D/b to D/B + moving D/b to D/B (glob) $ hg st A D/B R D/b diff --git a/tests/test-hook.t b/tests/test-hook.t --- a/tests/test-hook.t +++ b/tests/test-hook.t @@ -579,3 +579,30 @@ new tags must be visible in pretxncommit $ hg tag -f foo ['a', 'foo', 'tip'] +new commits must be visible in pretxnchangegroup (issue3428) + + $ cd .. + $ hg init to + $ echo '[hooks]' >> to/.hg/hgrc + $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc + $ echo a >> to/a + $ hg --cwd to ci -Ama + adding a + $ hg clone to from + updating to branch default + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ echo aa >> from/a + $ hg --cwd from ci -mb + $ hg --cwd from push + pushing to $TESTTMP/to + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files + changeset: 1:9836a07b9b9d + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: b + diff --git a/tests/test-parseindex2.py b/tests/test-parseindex2.py --- a/tests/test-parseindex2.py +++ b/tests/test-parseindex2.py @@ -114,8 +114,12 @@ def runtest() : for i, r in enumerate(ix): if r[7] == nullid: i = -1 - if ix[r[7]] != i: - print 'Reverse lookup inconsistent for %r' % r[7].encode('hex') + try: + if ix[r[7]] != i: + print 'Reverse lookup inconsistent for %r' % r[7].encode('hex') + except TypeError: + # pure version doesn't support this + break print "done" diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -278,19 +278,36 @@ Test remote paths with spaces (issue2983 $ hg id --ssh "python \"$TESTDIR/dummyssh\"" "ssh://user@dummy/a repo" 3fb238f49e8c -Test hg-ssh: +Test hg-ssh using a helper script that will restore PYTHONPATH (which might +have been cleared by a hg.exe wrapper) and invoke hg-ssh with the right +parameters: - $ SSH_ORIGINAL_COMMAND="'hg' -R 'a repo' serve --stdio" hg id --ssh "python \"$TESTDIR\"/../contrib/hg-ssh \"$TESTTMP/a repo\"" "ssh://user@dummy/a repo" + $ cat > ssh.sh << EOF + > userhost="\$1" + > SSH_ORIGINAL_COMMAND="\$2" + > export SSH_ORIGINAL_COMMAND + > PYTHONPATH="$PYTHONPATH" + > export PYTHONPATH + > python "$TESTDIR/../contrib/hg-ssh" "$TESTTMP/a repo" + > EOF + + $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a repo" 3fb238f49e8c - $ SSH_ORIGINAL_COMMAND="'hg' -R 'a repo' serve --stdio" hg id --ssh "python \"$TESTDIR\"/../contrib/hg-ssh \"$TESTTMP\"" "ssh://user@dummy/a repo" - remote: Illegal repository '$TESTTMP/a repo' (glob) + + $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a'repo" + remote: Illegal repository "$TESTTMP/a'repo" (glob) abort: no suitable response from remote hg! [255] - $ SSH_ORIGINAL_COMMAND="'hg' -R 'a'repo' serve --stdio" hg id --ssh "python \"$TESTDIR\"/../contrib/hg-ssh \"$TESTTMP\"" "ssh://user@dummy/a repo" - remote: Illegal command "'hg' -R 'a'repo' serve --stdio": No closing quotation + + $ hg id --ssh "sh ssh.sh" --remotecmd hacking "ssh://user@dummy/a'repo" + remote: Illegal command "hacking -R 'a'\''repo' serve --stdio" abort: no suitable response from remote hg! [255] + $ SSH_ORIGINAL_COMMAND="'hg' -R 'a'repo' serve --stdio" python "$TESTDIR/../contrib/hg-ssh" + Illegal command "'hg' -R 'a'repo' serve --stdio": No closing quotation + [255] + $ cat dummylog Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio Got arguments 1:user@dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio