Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG24849d53697d: tests: clean up many print statements to be print functions instead
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | tests/test-commit-interactive-curses.t (2 lines) | |||
M | tests/test-commit-multiple.t (6 lines) | |||
M | tests/test-contrib-check-code.t (24 lines) | |||
M | tests/test-convert-cvs.t (4 lines) | |||
M | tests/test-eol.t (2 lines) | |||
M | tests/test-extension.t (12 lines) | |||
M | tests/test-filebranch.t (3 lines) | |||
M | tests/test-glog.t (2 lines) | |||
M | tests/test-hardlinks.t (3 lines) | |||
M | tests/test-help.t (4 lines) | |||
M | tests/test-hook.t (11 lines) | |||
M | tests/test-inherit-mode.t (4 lines) | |||
M | tests/test-issue4074.t (2 lines) | |||
M | tests/test-largefiles-cache.t (2 lines) | |||
M | tests/test-log.t (8 lines) | |||
M | tests/test-merge-symlinks.t (3 lines) | |||
M | tests/test-merge1.t (3 lines) | |||
M | tests/test-merge6.t (2 lines) | |||
M | tests/test-mq-eol.t (2 lines) | |||
M | tests/test-notify-changegroup.t (6 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Abandoned | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 |
Check ui.interface logic for the chunkselector | Check ui.interface logic for the chunkselector | ||||
The default interface is text | The default interface is text | ||||
$ cp $HGRCPATH.pretest $HGRCPATH | $ cp $HGRCPATH.pretest $HGRCPATH | ||||
$ chunkselectorinterface() { | $ chunkselectorinterface() { | ||||
> $PYTHON <<EOF | > $PYTHON <<EOF | ||||
> from mercurial import hg, ui;\ | > from mercurial import hg, ui;\ | ||||
> repo = hg.repository(ui.ui.load(), ".");\ | > repo = hg.repository(ui.ui.load(), ".");\ | ||||
> print repo.ui.interface("chunkselector") | > print(repo.ui.interface("chunkselector")) | ||||
> EOF | > EOF | ||||
> } | > } | ||||
$ chunkselectorinterface | $ chunkselectorinterface | ||||
text | text | ||||
If only the default is set, we'll use that for the feature, too | If only the default is set, we'll use that for the feature, too | ||||
$ cp $HGRCPATH.pretest $HGRCPATH | $ cp $HGRCPATH.pretest $HGRCPATH | ||||
$ cat <<EOF >> $HGRCPATH | $ cat <<EOF >> $HGRCPATH |
> | > | ||||
> def replacebyte(fn, b): | > def replacebyte(fn, b): | ||||
> f = open(fn, "rb+") | > f = open(fn, "rb+") | ||||
> f.seek(0, 0) | > f.seek(0, 0) | ||||
> f.write(b) | > f.write(b) | ||||
> f.close() | > f.close() | ||||
> | > | ||||
> def printfiles(repo, rev): | > def printfiles(repo, rev): | ||||
> print "revision %s files: %s" % (rev, repo[rev].files()) | > print("revision %s files: %s" % (rev, repo[rev].files())) | ||||
> | > | ||||
> repo = hg.repository(ui.ui.load(), '.') | > repo = hg.repository(ui.ui.load(), '.') | ||||
> assert len(repo) == 6, \ | > assert len(repo) == 6, \ | ||||
> "initial: len(repo): %d, expected: 6" % len(repo) | > "initial: len(repo): %d, expected: 6" % len(repo) | ||||
> | > | ||||
> replacebyte("bugfix", "u") | > replacebyte("bugfix", "u") | ||||
> sleep(2) | > sleep(2) | ||||
> try: | > try: | ||||
> print "PRE: len(repo): %d" % len(repo) | > print("PRE: len(repo): %d" % len(repo)) | ||||
> wlock = repo.wlock() | > wlock = repo.wlock() | ||||
> lock = repo.lock() | > lock = repo.lock() | ||||
> replacebyte("file1", "x") | > replacebyte("file1", "x") | ||||
> repo.commit(text="x", user="test", date=(0, 0)) | > repo.commit(text="x", user="test", date=(0, 0)) | ||||
> replacebyte("file1", "y") | > replacebyte("file1", "y") | ||||
> repo.commit(text="y", user="test", date=(0, 0)) | > repo.commit(text="y", user="test", date=(0, 0)) | ||||
> print "POST: len(repo): %d" % len(repo) | > print("POST: len(repo): %d" % len(repo)) | ||||
> finally: | > finally: | ||||
> lock.release() | > lock.release() | ||||
> wlock.release() | > wlock.release() | ||||
> printfiles(repo, 6) | > printfiles(repo, 6) | ||||
> printfiles(repo, 7) | > printfiles(repo, 7) | ||||
> __EOF__ | > __EOF__ | ||||
$ $PYTHON $TESTTMP/committwice.py | $ $PYTHON $TESTTMP/committwice.py | ||||
PRE: len(repo): 6 | PRE: len(repo): 6 |
> .. note:: | > .. note:: | ||||
warning: add two newlines after '.. note::' | warning: add two newlines after '.. note::' | ||||
rst.py:26: | rst.py:26: | ||||
> .. note:: | > .. note:: | ||||
warning: add two newlines after '.. note::' | warning: add two newlines after '.. note::' | ||||
[1] | [1] | ||||
$ cat > ./map-inside-gettext.py <<EOF | $ cat > ./map-inside-gettext.py <<EOF | ||||
> print _("map inside gettext %s" % v) | > print(_("map inside gettext %s" % v)) | ||||
> | > | ||||
> print _("concatenating " " by " " space %s" % v) | > print(_("concatenating " " by " " space %s" % v)) | ||||
> print _("concatenating " + " by " + " '+' %s" % v) | > print(_("concatenating " + " by " + " '+' %s" % v)) | ||||
> | > | ||||
> print _("mapping operation in different line %s" | > print(_("mapping operation in different line %s" | ||||
> % v) | > % v)) | ||||
> | > | ||||
> print _( | > print(_( | ||||
> "leading spaces inside of '(' %s" % v) | > "leading spaces inside of '(' %s" % v)) | ||||
> EOF | > EOF | ||||
$ "$check_code" ./map-inside-gettext.py | $ "$check_code" ./map-inside-gettext.py | ||||
./map-inside-gettext.py:1: | ./map-inside-gettext.py:1: | ||||
> print _("map inside gettext %s" % v) | > print(_("map inside gettext %s" % v)) | ||||
don't use % inside _() | don't use % inside _() | ||||
./map-inside-gettext.py:3: | ./map-inside-gettext.py:3: | ||||
> print _("concatenating " " by " " space %s" % v) | > print(_("concatenating " " by " " space %s" % v)) | ||||
don't use % inside _() | don't use % inside _() | ||||
./map-inside-gettext.py:4: | ./map-inside-gettext.py:4: | ||||
> print _("concatenating " + " by " + " '+' %s" % v) | > print(_("concatenating " + " by " + " '+' %s" % v)) | ||||
don't use % inside _() | don't use % inside _() | ||||
./map-inside-gettext.py:6: | ./map-inside-gettext.py:6: | ||||
> print _("mapping operation in different line %s" | > print(_("mapping operation in different line %s" | ||||
don't use % inside _() | don't use % inside _() | ||||
./map-inside-gettext.py:9: | ./map-inside-gettext.py:9: | ||||
> print _( | > print(_( | ||||
don't use % inside _() | don't use % inside _() | ||||
[1] | [1] | ||||
web templates | web templates | ||||
$ mkdir -p mercurial/templates | $ mkdir -p mercurial/templates | ||||
$ cat > mercurial/templates/example.tmpl <<EOF | $ cat > mercurial/templates/example.tmpl <<EOF | ||||
> {desc} | > {desc} |
#require cvs | #require cvs | ||||
$ cvscall() | $ cvscall() | ||||
> { | > { | ||||
> cvs -f "$@" | > cvs -f "$@" | ||||
> } | > } | ||||
$ hgcat() | $ hgcat() | ||||
> { | > { | ||||
> hg --cwd src-hg cat -r tip "$1" | > hg --cwd src-hg cat -r tip "$1" | ||||
> } | > } | ||||
$ echo "[extensions]" >> $HGRCPATH | $ echo "[extensions]" >> $HGRCPATH | ||||
$ echo "convert = " >> $HGRCPATH | $ echo "convert = " >> $HGRCPATH | ||||
$ cat > cvshooks.py <<EOF | $ cat > cvshooks.py <<EOF | ||||
> def cvslog(ui,repo,hooktype,log): | > def cvslog(ui,repo,hooktype,log): | ||||
> print "%s hook: %d entries"%(hooktype,len(log)) | > print("%s hook: %d entries"%(hooktype,len(log))) | ||||
> | > | ||||
> def cvschangesets(ui,repo,hooktype,changesets): | > def cvschangesets(ui,repo,hooktype,changesets): | ||||
> print "%s hook: %d changesets"%(hooktype,len(changesets)) | > print("%s hook: %d changesets"%(hooktype,len(changesets))) | ||||
> EOF | > EOF | ||||
$ hookpath=`pwd` | $ hookpath=`pwd` | ||||
$ cat <<EOF >> $HGRCPATH | $ cat <<EOF >> $HGRCPATH | ||||
> [hooks] | > [hooks] | ||||
> cvslog = python:$hookpath/cvshooks.py:cvslog | > cvslog = python:$hookpath/cvshooks.py:cvslog | ||||
> cvschangesets = python:$hookpath/cvshooks.py:cvschangesets | > cvschangesets = python:$hookpath/cvshooks.py:cvschangesets | ||||
> EOF | > EOF | ||||
> import sys | > import sys | ||||
> try: | > try: | ||||
> import os, msvcrt | > import os, msvcrt | ||||
> msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) | > msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) | ||||
> msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | ||||
> except ImportError: | > except ImportError: | ||||
> pass | > pass | ||||
> (old, new) = sys.argv[1] == 'LF' and ('\n', '\r\n') or ('\r\n', '\n') | > (old, new) = sys.argv[1] == 'LF' and ('\n', '\r\n') or ('\r\n', '\n') | ||||
> print "%% switching encoding from %r to %r" % (old, new) | > print("%% switching encoding from %r to %r" % (old, new)) | ||||
> for path in sys.argv[2:]: | > for path in sys.argv[2:]: | ||||
> data = file(path, 'rb').read() | > data = file(path, 'rb').read() | ||||
> data = data.replace(old, new) | > data = data.replace(old, new) | ||||
> file(path, 'wb').write(data) | > file(path, 'wb').write(data) | ||||
> EOF | > EOF | ||||
$ seteol () { | $ seteol () { | ||||
> if [ $1 = "LF" ]; then | > if [ $1 = "LF" ]; then |
Foo | Foo | ||||
$ echo 'barfoo = !' >> $HGRCPATH | $ echo 'barfoo = !' >> $HGRCPATH | ||||
Check that extensions are loaded in phases: | Check that extensions are loaded in phases: | ||||
$ cat > foo.py <<EOF | $ cat > foo.py <<EOF | ||||
> import os | > import os | ||||
> name = os.path.basename(__file__).rsplit('.', 1)[0] | > name = os.path.basename(__file__).rsplit('.', 1)[0] | ||||
> print "1) %s imported" % name | > print("1) %s imported" % name) | ||||
> def uisetup(ui): | > def uisetup(ui): | ||||
> print "2) %s uisetup" % name | > print("2) %s uisetup" % name) | ||||
> def extsetup(): | > def extsetup(): | ||||
> print "3) %s extsetup" % name | > print("3) %s extsetup" % name) | ||||
> def reposetup(ui, repo): | > def reposetup(ui, repo): | ||||
> print "4) %s reposetup" % name | > print("4) %s reposetup" % name) | ||||
> | > | ||||
> # custom predicate to check registration of functions at loading | > # custom predicate to check registration of functions at loading | ||||
> from mercurial import ( | > from mercurial import ( | ||||
> registrar, | > registrar, | ||||
> smartset, | > smartset, | ||||
> ) | > ) | ||||
> revsetpredicate = registrar.revsetpredicate() | > revsetpredicate = registrar.revsetpredicate() | ||||
> @revsetpredicate(name, safe=True) # safe=True for query via hgweb | > @revsetpredicate(name, safe=True) # safe=True for query via hgweb | ||||
$ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF | $ cat > $TESTTMP/libroot/mod/ambigabs.py <<EOF | ||||
> from __future__ import absolute_import | > from __future__ import absolute_import | ||||
> import ambig # should load "libroot/ambig.py" | > import ambig # should load "libroot/ambig.py" | ||||
> s = ambig.s | > s = ambig.s | ||||
> EOF | > EOF | ||||
$ cat > loadabs.py <<EOF | $ cat > loadabs.py <<EOF | ||||
> import mod.ambigabs as ambigabs | > import mod.ambigabs as ambigabs | ||||
> def extsetup(): | > def extsetup(): | ||||
> print 'ambigabs.s=%s' % ambigabs.s | > print('ambigabs.s=%s' % ambigabs.s) | ||||
> EOF | > EOF | ||||
$ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root) | $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root) | ||||
ambigabs.s=libroot/ambig.py | ambigabs.s=libroot/ambig.py | ||||
$TESTTMP/a (glob) | $TESTTMP/a (glob) | ||||
#if no-py3k | #if no-py3k | ||||
$ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF | $ cat > $TESTTMP/libroot/mod/ambigrel.py <<EOF | ||||
> import ambig # should load "libroot/mod/ambig.py" | > import ambig # should load "libroot/mod/ambig.py" | ||||
> s = ambig.s | > s = ambig.s | ||||
> EOF | > EOF | ||||
$ cat > loadrel.py <<EOF | $ cat > loadrel.py <<EOF | ||||
> import mod.ambigrel as ambigrel | > import mod.ambigrel as ambigrel | ||||
> def extsetup(): | > def extsetup(): | ||||
> print 'ambigrel.s=%s' % ambigrel.s | > print('ambigrel.s=%s' % ambigrel.s) | ||||
> EOF | > EOF | ||||
$ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root) | $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root) | ||||
ambigrel.s=libroot/mod/ambig.py | ambigrel.s=libroot/mod/ambig.py | ||||
$TESTTMP/a (glob) | $TESTTMP/a (glob) | ||||
#endif | #endif | ||||
Check absolute/relative import of extension specific modules | Check absolute/relative import of extension specific modules | ||||
This test makes sure that we don't mark a file as merged with its ancestor | This test makes sure that we don't mark a file as merged with its ancestor | ||||
when we do a merge. | when we do a merge. | ||||
$ cat <<EOF > merge | $ cat <<EOF > merge | ||||
> from __future__ import print_function | |||||
> import sys, os | > import sys, os | ||||
> print "merging for", os.path.basename(sys.argv[1]) | > print("merging for", os.path.basename(sys.argv[1])) | ||||
> EOF | > EOF | ||||
$ HGMERGE="$PYTHON ../merge"; export HGMERGE | $ HGMERGE="$PYTHON ../merge"; export HGMERGE | ||||
Creating base: | Creating base: | ||||
$ hg init a | $ hg init a | ||||
$ cd a | $ cd a | ||||
$ echo 1 > foo | $ echo 1 > foo |
('string', 'i:a') | ('string', 'i:a') | ||||
('string', 'i:e') | ('string', 'i:e') | ||||
('string', 'x:b') | ('string', 'x:b') | ||||
('string', 'x:e')))) | ('string', 'x:e')))) | ||||
Test glob expansion of pats | Test glob expansion of pats | ||||
$ expandglobs=`$PYTHON -c "import mercurial.util; \ | $ expandglobs=`$PYTHON -c "import mercurial.util; \ | ||||
> print mercurial.util.expandglobs and 'true' or 'false'"` | > print(mercurial.util.expandglobs and 'true' or 'false')"` | ||||
$ if [ $expandglobs = "true" ]; then | $ if [ $expandglobs = "true" ]; then | ||||
> testlog 'a*'; | > testlog 'a*'; | ||||
> else | > else | ||||
> testlog a*; | > testlog a*; | ||||
> fi; | > fi; | ||||
[] | [] | ||||
(group | (group | ||||
(group | (group |
#require hardlink | #require hardlink | ||||
$ cat > nlinks.py <<EOF | $ cat > nlinks.py <<EOF | ||||
> from __future__ import print_function | |||||
> import sys | > import sys | ||||
> from mercurial import util | > from mercurial import util | ||||
> for f in sorted(sys.stdin.readlines()): | > for f in sorted(sys.stdin.readlines()): | ||||
> f = f[:-1] | > f = f[:-1] | ||||
> print util.nlinks(f), f | > print(util.nlinks(f), f) | ||||
> EOF | > EOF | ||||
$ nlinksdir() | $ nlinksdir() | ||||
> { | > { | ||||
> find "$@" -type f | $PYTHON $TESTTMP/nlinks.py | > find "$@" -type f | $PYTHON $TESTTMP/nlinks.py | ||||
> } | > } | ||||
Some implementations of cp can't create hardlinks (replaces 'cp -al' on Linux): | Some implementations of cp can't create hardlinks (replaces 'cp -al' on Linux): |
$ cat >> $HGRCPATH <<EOF | $ cat >> $HGRCPATH <<EOF | ||||
> [extensions] | > [extensions] | ||||
> ambiguous = ./ambiguous.py | > ambiguous = ./ambiguous.py | ||||
> EOF | > EOF | ||||
$ $PYTHON <<EOF | sh | $ $PYTHON <<EOF | sh | ||||
> upper = "\x8bL\x98^" | > upper = "\x8bL\x98^" | ||||
> print "hg --encoding cp932 help -e ambiguous.%s" % upper | > print("hg --encoding cp932 help -e ambiguous.%s" % upper) | ||||
> EOF | > EOF | ||||
\x8bL\x98^ (esc) | \x8bL\x98^ (esc) | ||||
---- | ---- | ||||
Upper name should show only this message | Upper name should show only this message | ||||
$ $PYTHON <<EOF | sh | $ $PYTHON <<EOF | sh | ||||
> lower = "\x8bl\x98^" | > lower = "\x8bl\x98^" | ||||
> print "hg --encoding cp932 help -e ambiguous.%s" % lower | > print("hg --encoding cp932 help -e ambiguous.%s" % lower) | ||||
> EOF | > EOF | ||||
\x8bl\x98^ (esc) | \x8bl\x98^ (esc) | ||||
---- | ---- | ||||
Lower name should show only this message | Lower name should show only this message | ||||
$ cat >> $HGRCPATH <<EOF | $ cat >> $HGRCPATH <<EOF |
preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=clone | preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=clone | ||||
preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid HG_HOOKTYPE=preoutgoing HG_SOURCE=clone | preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid HG_HOOKTYPE=preoutgoing HG_SOURCE=clone | ||||
abort: preoutgoing.forbid hook exited with status 1 | abort: preoutgoing.forbid hook exited with status 1 | ||||
[255] | [255] | ||||
$ cd "$TESTTMP/b" | $ cd "$TESTTMP/b" | ||||
$ cat > hooktests.py <<EOF | $ cat > hooktests.py <<EOF | ||||
> from __future__ import print_function | |||||
> from mercurial import error | > from mercurial import error | ||||
> | > | ||||
> uncallable = 0 | > uncallable = 0 | ||||
> | > | ||||
> def printargs(args): | > def printargs(args): | ||||
> args.pop('ui', None) | > args.pop('ui', None) | ||||
> args.pop('repo', None) | > args.pop('repo', None) | ||||
> a = list(args.items()) | > a = list(args.items()) | ||||
> a.sort() | > a.sort() | ||||
> print 'hook args:' | > print('hook args:') | ||||
> for k, v in a: | > for k, v in a: | ||||
> print ' ', k, v | > print(' ', k, v) | ||||
> | > | ||||
> def passhook(**args): | > def passhook(**args): | ||||
> printargs(args) | > printargs(args) | ||||
> | > | ||||
> def failhook(**args): | > def failhook(**args): | ||||
> printargs(args) | > printargs(args) | ||||
> return True | > return True | ||||
> | > | ||||
> class LocalException(Exception): | > class LocalException(Exception): | ||||
> pass | > pass | ||||
> | > | ||||
> def raisehook(**args): | > def raisehook(**args): | ||||
> raise LocalException('exception from hook') | > raise LocalException('exception from hook') | ||||
> | > | ||||
> def aborthook(**args): | > def aborthook(**args): | ||||
> raise error.Abort('raise abort from hook') | > raise error.Abort('raise abort from hook') | ||||
> | > | ||||
> def brokenhook(**args): | > def brokenhook(**args): | ||||
> return 1 + {} | > return 1 + {} | ||||
> | > | ||||
> def verbosehook(ui, **args): | > def verbosehook(ui, **args): | ||||
> ui.note('verbose output from hook\n') | > ui.note('verbose output from hook\n') | ||||
> | > | ||||
> def printtags(ui, repo, **args): | > def printtags(ui, repo, **args): | ||||
> print sorted(repo.tags()) | > print(sorted(repo.tags())) | ||||
> | > | ||||
> class container: | > class container: | ||||
> unreachable = 1 | > unreachable = 1 | ||||
> EOF | > EOF | ||||
$ cat > syntaxerror.py << EOF | $ cat > syntaxerror.py << EOF | ||||
> (foo | > (foo | ||||
> EOF | > EOF | ||||
Traceback (most recent call last): | Traceback (most recent call last): | ||||
$ cd .. | $ cd .. | ||||
$ hg init c | $ hg init c | ||||
$ cd c | $ cd c | ||||
$ cat > hookext.py <<EOF | $ cat > hookext.py <<EOF | ||||
> def autohook(**args): | > def autohook(**args): | ||||
> print "Automatically installed hook" | > print("Automatically installed hook") | ||||
> | > | ||||
> def reposetup(ui, repo): | > def reposetup(ui, repo): | ||||
> repo.ui.setconfig("hooks", "commit.auto", autohook) | > repo.ui.setconfig("hooks", "commit.auto", autohook) | ||||
> EOF | > EOF | ||||
$ echo '[extensions]' >> .hg/hgrc | $ echo '[extensions]' >> .hg/hgrc | ||||
$ echo 'hookext = hookext.py' >> .hg/hgrc | $ echo 'hookext = hookext.py' >> .hg/hgrc | ||||
$ touch foo | $ touch foo | ||||
$ mkdir d | $ mkdir d | ||||
$ cd d | $ cd d | ||||
$ hg init repo | $ hg init repo | ||||
$ mkdir hooks | $ mkdir hooks | ||||
$ cd hooks | $ cd hooks | ||||
$ cat > testhooks.py <<EOF | $ cat > testhooks.py <<EOF | ||||
> def testhook(**args): | > def testhook(**args): | ||||
> print 'hook works' | > print('hook works') | ||||
> EOF | > EOF | ||||
$ echo '[hooks]' > ../repo/.hg/hgrc | $ echo '[hooks]' > ../repo/.hg/hgrc | ||||
$ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc | $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc | ||||
$ cd ../repo | $ cd ../repo | ||||
$ hg commit -d '0 0' | $ hg commit -d '0 0' | ||||
hook works | hook works | ||||
nothing changed | nothing changed |
> isdir[name] = 1 | > isdir[name] = 1 | ||||
> allnames.append(name) | > allnames.append(name) | ||||
> for f in files: | > for f in files: | ||||
> name = os.path.join(root, f) | > name = os.path.join(root, f) | ||||
> allnames.append(name) | > allnames.append(name) | ||||
> allnames.sort() | > allnames.sort() | ||||
> for name in allnames: | > for name in allnames: | ||||
> suffix = name in isdir and '/' or '' | > suffix = name in isdir and '/' or '' | ||||
> print '%05o %s%s' % (os.lstat(name).st_mode & 07777, name, suffix) | > print('%05o %s%s' % (os.lstat(name).st_mode & 07777, name, suffix)) | ||||
> EOF | > EOF | ||||
$ cat >mode.py <<EOF | $ cat >mode.py <<EOF | ||||
> import sys | > import sys | ||||
> import os | > import os | ||||
> print '%05o' % os.lstat(sys.argv[1]).st_mode | > print('%05o' % os.lstat(sys.argv[1]).st_mode) | ||||
> EOF | > EOF | ||||
$ umask 077 | $ umask 077 | ||||
$ hg init repo | $ hg init repo | ||||
$ cd repo | $ cd repo | ||||
$ chmod 0770 .hg/store | $ chmod 0770 .hg/store |
#require no-pure | #require no-pure | ||||
A script to generate nasty diff worst-case scenarios: | A script to generate nasty diff worst-case scenarios: | ||||
$ cat > s.py <<EOF | $ cat > s.py <<EOF | ||||
> import random | > import random | ||||
> for x in xrange(100000): | > for x in xrange(100000): | ||||
> if random.randint(0, 100) >= 50: | > if random.randint(0, 100) >= 50: | ||||
> x += 1 | > x += 1 | ||||
> print hex(x) | > print(hex(x)) | ||||
> EOF | > EOF | ||||
$ hg init a | $ hg init a | ||||
$ cd a | $ cd a | ||||
Check in a big file: | Check in a big file: | ||||
$ $PYTHON ../s.py > a | $ $PYTHON ../s.py > a |
#if unix-permissions | #if unix-permissions | ||||
Portable way to print file permissions: | Portable way to print file permissions: | ||||
$ cat > ls-l.py <<EOF | $ cat > ls-l.py <<EOF | ||||
> #!$PYTHON | > #!$PYTHON | ||||
> import sys, os | > import sys, os | ||||
> path = sys.argv[1] | > path = sys.argv[1] | ||||
> print '%03o' % (os.lstat(path).st_mode & 0777) | > print('%03o' % (os.lstat(path).st_mode & 0777)) | ||||
> EOF | > EOF | ||||
$ chmod +x ls-l.py | $ chmod +x ls-l.py | ||||
Test that files in .hg/largefiles inherit mode from .hg/store, not | Test that files in .hg/largefiles inherit mode from .hg/store, not | ||||
from file in working copy: | from file in working copy: | ||||
$ cd src | $ cd src | ||||
$ chmod 750 .hg/store | $ chmod 750 .hg/store |
# unicode: cp932: | # unicode: cp932: | ||||
# u30A2 0x83 0x41(= 'A') | # u30A2 0x83 0x41(= 'A') | ||||
# u30C2 0x83 0x61(= 'a') | # u30C2 0x83 0x61(= 'a') | ||||
$ hg init problematicencoding | $ hg init problematicencoding | ||||
$ cd problematicencoding | $ cd problematicencoding | ||||
$ $PYTHON > setup.sh <<EOF | $ $PYTHON > setup.sh <<EOF | ||||
> print u''' | > print(u''' | ||||
> echo a > text | > echo a > text | ||||
> hg add text | > hg add text | ||||
> hg --encoding utf-8 commit -u '\u30A2' -m none | > hg --encoding utf-8 commit -u '\u30A2' -m none | ||||
> echo b > text | > echo b > text | ||||
> hg --encoding utf-8 commit -u '\u30C2' -m none | > hg --encoding utf-8 commit -u '\u30C2' -m none | ||||
> echo c > text | > echo c > text | ||||
> hg --encoding utf-8 commit -u none -m '\u30A2' | > hg --encoding utf-8 commit -u none -m '\u30A2' | ||||
> echo d > text | > echo d > text | ||||
> hg --encoding utf-8 commit -u none -m '\u30C2' | > hg --encoding utf-8 commit -u none -m '\u30C2' | ||||
> '''.encode('utf-8') | > '''.encode('utf-8')) | ||||
> EOF | > EOF | ||||
$ sh < setup.sh | $ sh < setup.sh | ||||
test in problematic encoding | test in problematic encoding | ||||
$ $PYTHON > test.sh <<EOF | $ $PYTHON > test.sh <<EOF | ||||
> print u''' | > print(u''' | ||||
> hg --encoding cp932 log --template '{rev}\\n' -u '\u30A2' | > hg --encoding cp932 log --template '{rev}\\n' -u '\u30A2' | ||||
> echo ==== | > echo ==== | ||||
> hg --encoding cp932 log --template '{rev}\\n' -u '\u30C2' | > hg --encoding cp932 log --template '{rev}\\n' -u '\u30C2' | ||||
> echo ==== | > echo ==== | ||||
> hg --encoding cp932 log --template '{rev}\\n' -k '\u30A2' | > hg --encoding cp932 log --template '{rev}\\n' -k '\u30A2' | ||||
> echo ==== | > echo ==== | ||||
> hg --encoding cp932 log --template '{rev}\\n' -k '\u30C2' | > hg --encoding cp932 log --template '{rev}\\n' -k '\u30C2' | ||||
> '''.encode('cp932') | > '''.encode('cp932')) | ||||
> EOF | > EOF | ||||
$ sh < test.sh | $ sh < test.sh | ||||
0 | 0 | ||||
==== | ==== | ||||
1 | 1 | ||||
==== | ==== | ||||
2 | 2 | ||||
0 | 0 |
$ cat > echo.py <<EOF | $ cat > echo.py <<EOF | ||||
> #!$PYTHON | > #!$PYTHON | ||||
> from __future__ import print_function | |||||
> import os, sys | > import os, sys | ||||
> try: | > try: | ||||
> import msvcrt | > import msvcrt | ||||
> msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | ||||
> msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) | > msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) | ||||
> except ImportError: | > except ImportError: | ||||
> pass | > pass | ||||
> | > | ||||
> for k in ('HG_FILE', 'HG_MY_ISLINK', 'HG_OTHER_ISLINK', 'HG_BASE_ISLINK'): | > for k in ('HG_FILE', 'HG_MY_ISLINK', 'HG_OTHER_ISLINK', 'HG_BASE_ISLINK'): | ||||
> print k, os.environ[k] | > print(k, os.environ[k]) | ||||
> EOF | > EOF | ||||
Create 2 heads containing the same file, once as | Create 2 heads containing the same file, once as | ||||
a file, once as a link. Bundle was generated with: | a file, once as a link. Bundle was generated with: | ||||
# hg init t | # hg init t | ||||
# cd t | # cd t | ||||
# echo a > a | # echo a > a |
$ cat <<EOF > merge | $ cat <<EOF > merge | ||||
> from __future__ import print_function | |||||
> import sys, os | > import sys, os | ||||
> | > | ||||
> try: | > try: | ||||
> import msvcrt | > import msvcrt | ||||
> msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | ||||
> msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) | > msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) | ||||
> except ImportError: | > except ImportError: | ||||
> pass | > pass | ||||
> | > | ||||
> print "merging for", os.path.basename(sys.argv[1]) | > print("merging for", os.path.basename(sys.argv[1])) | ||||
> EOF | > EOF | ||||
$ HGMERGE="$PYTHON ../merge"; export HGMERGE | $ HGMERGE="$PYTHON ../merge"; export HGMERGE | ||||
$ hg init t | $ hg init t | ||||
$ cd t | $ cd t | ||||
$ echo This is file a1 > a | $ echo This is file a1 > a | ||||
$ hg add a | $ hg add a | ||||
$ hg commit -m "commit #0" | $ hg commit -m "commit #0" |
$ cat <<EOF > merge | $ cat <<EOF > merge | ||||
> import sys, os | > import sys, os | ||||
> print "merging for", os.path.basename(sys.argv[1]) | > print("merging for", os.path.basename(sys.argv[1])) | ||||
> EOF | > EOF | ||||
$ HGMERGE="$PYTHON ../merge"; export HGMERGE | $ HGMERGE="$PYTHON ../merge"; export HGMERGE | ||||
$ hg init A1 | $ hg init A1 | ||||
$ cd A1 | $ cd A1 | ||||
$ echo This is file foo1 > foo | $ echo This is file foo1 > foo | ||||
$ echo This is file bar1 > bar | $ echo This is file bar1 > bar | ||||
$ hg add foo bar | $ hg add foo bar |
> w('\ No newline at end of file\r\n') | > w('\ No newline at end of file\r\n') | ||||
> EOF | > EOF | ||||
$ cat > cateol.py <<EOF | $ cat > cateol.py <<EOF | ||||
> import sys | > import sys | ||||
> for line in file(sys.argv[1], 'rb'): | > for line in file(sys.argv[1], 'rb'): | ||||
> line = line.replace('\r', '<CR>') | > line = line.replace('\r', '<CR>') | ||||
> line = line.replace('\n', '<LF>') | > line = line.replace('\n', '<LF>') | ||||
> print line | > print(line) | ||||
> EOF | > EOF | ||||
$ hg init repo | $ hg init repo | ||||
$ cd repo | $ cd repo | ||||
$ echo '\.diff' > .hgignore | $ echo '\.diff' > .hgignore | ||||
$ echo '\.rej' >> .hgignore | $ echo '\.rej' >> .hgignore | ||||
commit | commit | ||||
$ hg --traceback --cwd b commit -Amb | $ hg --traceback --cwd b commit -Amb | ||||
push | push | ||||
$ hg --traceback --cwd b push ../a 2>&1 | | $ hg --traceback --cwd b push ../a 2>&1 | | ||||
> $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' | > $PYTHON -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")' | ||||
pushing to ../a | pushing to ../a | ||||
searching for changes | searching for changes | ||||
adding changesets | adding changesets | ||||
adding manifests | adding manifests | ||||
adding file changes | adding file changes | ||||
added 2 changesets with 2 changes to 1 files | added 2 changesets with 2 changes to 1 files | ||||
Content-Type: text/plain; charset="us-ascii" | Content-Type: text/plain; charset="us-ascii" | ||||
MIME-Version: 1.0 | MIME-Version: 1.0 | ||||
added 2 changesets with 2 changes to 1 files | added 2 changesets with 2 changes to 1 files | ||||
(run 'hg update' to get a working copy) | (run 'hg update' to get a working copy) | ||||
$ hg --cwd a rollback | $ hg --cwd a rollback | ||||
repository tip rolled back to revision -1 (undo unbundle) | repository tip rolled back to revision -1 (undo unbundle) | ||||
unbundle with correct source | unbundle with correct source | ||||
$ hg --config notify.sources=unbundle --cwd a unbundle ../test.hg 2>&1 | | $ hg --config notify.sources=unbundle --cwd a unbundle ../test.hg 2>&1 | | ||||
> $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' | > $PYTHON -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")' | ||||
adding changesets | adding changesets | ||||
adding manifests | adding manifests | ||||
adding file changes | adding file changes | ||||
added 2 changesets with 2 changes to 1 files | added 2 changesets with 2 changes to 1 files | ||||
Content-Type: text/plain; charset="us-ascii" | Content-Type: text/plain; charset="us-ascii" | ||||
MIME-Version: 1.0 | MIME-Version: 1.0 | ||||
Content-Transfer-Encoding: 7bit | Content-Transfer-Encoding: 7bit | ||||
Date: * (glob) | Date: * (glob) | ||||
0 files updated, 1 files merged, 0 files removed, 0 files unresolved | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | ||||
(branch merge, don't forget to commit) | (branch merge, don't forget to commit) | ||||
$ hg --traceback --cwd b commit -Am "merged" | $ hg --traceback --cwd b commit -Am "merged" | ||||
push | push | ||||
$ hg --traceback --cwd b --config notify.fromauthor=True push ../a 2>&1 | | $ hg --traceback --cwd b --config notify.fromauthor=True push ../a 2>&1 | | ||||
> $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' | > $PYTHON -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")' | ||||
pushing to ../a | pushing to ../a | ||||
searching for changes | searching for changes | ||||
adding changesets | adding changesets | ||||
adding manifests | adding manifests | ||||
adding file changes | adding file changes | ||||
added 4 changesets with 4 changes to 1 files | added 4 changesets with 4 changes to 1 files | ||||
Content-Type: text/plain; charset="us-ascii" | Content-Type: text/plain; charset="us-ascii" | ||||
MIME-Version: 1.0 | MIME-Version: 1.0 |