Mercurial > hg
view tests/test-mactext.t @ 29497:ee2027195847
perf: define command annotation locally for Mercurial earlier than 3.1
Before this patch, using cmdutil.command() for "@command" annotation
prevents perf.py from being loaded by Mercurial earlier than 1.9 (or
2daa5179e73f), because cmdutil.command() isn't available in such
Mercurial, even though there are some code paths for Mercurial earlier
than 1.9.
For example, setting "_prereadsize" attribute in perfindex() and
perfnodelookup() is effective only with hg earlier than 1.8 (or
61c9bc3da402).
In addition to it, "norepo" option of command annotation has been
available since 3.1 (or 75a96326cecb), and this is another blocker for
loading perf.py with earlier Mercurial.
============ ============ ======
command of
hg version cmdutil norepo
============ ============ ======
3.1 or later o o
1.9 or later o x
earlier x x
============ ============ ======
This patch defines "command()" for annotation locally as below:
- define wrapper of existing cmdutil.command(), if cmdutil.command()
doesn't support "norepo"
(for Mercurial earlier than 3.1)
- define full command() locally with minimum function, if
cmdutil.command() isn't available at runtime
(for Mercurial earlier than 1.9)
This patch also defines parsealiases() locally without examining
whether it is available or not, because it is small enough to define
locally.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 05 Jul 2016 07:25:51 +0900 |
parents | 7985a9e2ddce |
children | 75be14993fda |
line wrap: on
line source
$ cat > unix2mac.py <<EOF > import sys > > for path in sys.argv[1:]: > data = file(path, 'rb').read() > data = data.replace('\n', '\r') > file(path, 'wb').write(data) > EOF $ cat > print.py <<EOF > import sys > print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>')) > EOF $ hg init $ echo '[hooks]' >> .hg/hgrc $ echo 'pretxncommit.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc $ echo 'pretxnchangegroup.cr = python:hgext.win32text.forbidcr' >> .hg/hgrc $ cat .hg/hgrc [hooks] pretxncommit.cr = python:hgext.win32text.forbidcr pretxnchangegroup.cr = python:hgext.win32text.forbidcr $ echo hello > f $ hg add f $ hg ci -m 1 $ python unix2mac.py f $ hg ci -m 2 attempt to commit or push text file(s) using CR line endings in dea860dc51ec: f transaction abort! rollback completed abort: pretxncommit.cr hook failed [255] $ hg cat f | python print.py hello<LF> $ cat f | python print.py hello<CR>