diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -223,7 +223,8 @@ def clone(ui, source, dest=None, pull=Fa if dest_repo.local(): fp = dest_repo.opener("hgrc", "w", text=True) fp.write("[paths]\n") - fp.write("default = %s\n" % abspath) + # percent needs to be escaped for ConfigParser + fp.write("default = %s\n" % abspath.replace('%', '%%')) fp.close() if update: diff --git a/tests/test-doctest.py b/tests/test-doctest.py --- a/tests/test-doctest.py +++ b/tests/test-doctest.py @@ -1,3 +1,5 @@ +# this is hack to make sure no escape characters are inserted into the output +import os; del os.environ['TERM'] import doctest import mercurial.changelog diff --git a/tests/test-hgrc b/tests/test-hgrc --- a/tests/test-hgrc +++ b/tests/test-hgrc @@ -5,3 +5,14 @@ cd t hg init echo "invalid" > .hg/hgrc hg status 2>&1 |sed -e "s:/.*\(/t/.*\):...\1:" + +#issue 1199, escaping + +cd .. +hg init "foo%bar" +hg clone "foo%bar" foobar +p=`pwd` +cd foobar +cat .hg/hgrc |sed -e "s:$p:...:" +hg paths |sed -e "s:$p:...:" +hg showconfig |sed -e "s:$p:...:" diff --git a/tests/test-hgrc.out b/tests/test-hgrc.out --- a/tests/test-hgrc.out +++ b/tests/test-hgrc.out @@ -2,3 +2,15 @@ abort: Failed to parse .../t/.hg/hgrc File contains no section headers. file: .../t/.hg/hgrc, line: 1 'invalid\n' +updating working directory +0 files updated, 0 files merged, 0 files removed, 0 files unresolved +[paths] +default = .../foo%%bar +default = .../foo%bar +bundle.mainreporoot=.../foobar +defaults.backout=-d "0 0" +defaults.commit=-d "0 0" +defaults.debugrawcommit=-d "0 0" +defaults.tag=-d "0 0" +paths.default=.../foo%bar +ui.slash=True diff --git a/tests/test-mq b/tests/test-mq --- a/tests/test-mq +++ b/tests/test-mq @@ -520,7 +520,7 @@ echo % qpush should fail, local changes hg qpush echo % apply force, should not discard changes with empty patch -hg qpush -f +hg qpush -f 2>&1 | sed 's,^.*/patch,patch,g' hg diff --config diff.nodates=True hg qdiff --config diff.nodates=True hg log -l1 -p diff --git a/tests/test-mq.out b/tests/test-mq.out --- a/tests/test-mq.out +++ b/tests/test-mq.out @@ -500,7 +500,7 @@ Patch queue now empty abort: local changes found, refresh first % apply force, should not discard changes with empty patch applying empty -/usr/bin/patch: **** Only garbage was found in the patch input. +patch: **** Only garbage was found in the patch input. patch failed, unable to continue (try -v) patch empty is empty Now at: empty diff --git a/tests/test-notify-changegroup b/tests/test-notify-changegroup new file mode 100755 --- /dev/null +++ b/tests/test-notify-changegroup @@ -0,0 +1,43 @@ +#!/bin/sh + +cat <> $HGRCPATH +[extensions] +notify= + +[hooks] +changegroup.notify = python:hgext.notify.hook + +[notify] +sources = push +diffstat = False +maxsubject = 200 + +[usersubs] +foo@bar = * + +[reposubs] +* = baz +EOF + +hg init a + +echo % clone +hg --traceback clone a b + +echo a > b/a +echo % commit +hg --traceback --cwd b commit -Ama + +echo a >> b/a +echo % commit +hg --traceback --cwd b commit -Amb + +echo % push +hg --traceback --cwd b push ../a 2>&1 | + python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' | + sed -e 's/\(Message-Id:\).*/\1/' \ + -e 's/changeset \([0-9a-f]* *\)in .*test-notif/changeset \1in test-notif/' \ + -e 's/^Subject: .*test-notify/Subject: test-notify/' \ + -e 's/^details: .*test-notify/details: test-notify/' \ + -e 's/^Date:.*/Date:/' + diff --git a/tests/test-notify-changegroup.out b/tests/test-notify-changegroup.out new file mode 100644 --- /dev/null +++ b/tests/test-notify-changegroup.out @@ -0,0 +1,36 @@ +% clone +updating working directory +0 files updated, 0 files merged, 0 files removed, 0 files unresolved +% commit +adding a +% commit +% push +pushing to ../a +searching for changes +adding changesets +adding manifests +adding file changes +added 2 changesets with 2 changes to 1 files +Date: +Subject: test-notify-changegroup/a: 2 new changesets +From: test +X-Hg-Notification: changeset cb9a9f314b8b +Message-Id: +To: baz, foo@bar + +changeset cb9a9f314b8b in test-notify-changegroup/a +details: test-notify-changegroup/a?cmd=changeset;node=cb9a9f314b8b +summary: a + +changeset ba677d0156c1 in test-notify-changegroup/a +details: test-notify-changegroup/a?cmd=changeset;node=ba677d0156c1 +summary: b + +diffs (6 lines): + +diff -r 000000000000 -r ba677d0156c1 a +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/a Thu Jan 01 00:00:00 1970 +0000 +@@ -0,0 +1,2 @@ ++a ++a