tests/test-convert-p4
author Patrick Mezard <pmezard@gmail.com>
Mon, 01 Aug 2011 23:58:50 +0200
branchstable
changeset 15005 4a43e23b8c55
parent 9044 d4d4da54ab05
permissions -rwxr-xr-x
hgweb: do not ignore [auth] if url has a username (issue2822) The [auth] section was ignored when handling URLs like: http://user@example.com/foo Instead, we look in [auth] for an entry matching the URL and supplied user name. Entries without username can match URL with a username. Prefix length ties are resolved in favor of entries matching the username. With: foo.prefix = http://example.org foo.username = user foo.password = password bar.prefix = http://example.org/bar and the input URL: http://user@example.org/bar the 'bar' entry will be selected because of prefix length, therefore prompting for a password. This behaviour ensure that entries selection is consistent when looking for credentials or for certificates, and that certificates can be picked even if their entries do no define usernames while the URL does. Additionally, entries without a username matched against a username are returned as if they did have requested username set to avoid prompting again for a username if the password is not set. v2: reparse the URL in readauthforuri() to handle HTTP and HTTPS similarly. v3: allow unset usernames to match URL usernames to pick certificates. Resolve prefix length ties in favor of entries with usernames.

#!/bin/sh

"$TESTDIR/hghave" p4 || exit 80

echo "[extensions]" >> $HGRCPATH
echo "convert = " >> $HGRCPATH

echo % create p4 depot
P4ROOT=`pwd`/depot; export P4ROOT
P4AUDIT=$P4ROOT/audit; export P4AUDIT
P4JOURNAL=$P4ROOT/journal; export P4JOURNAL
P4LOG=$P4ROOT/log; export P4LOG
P4PORT=localhost:16661; export P4PORT
P4DEBUG=1; export P4DEBUG

echo % start the p4 server
[ ! -d $P4ROOT ] && mkdir $P4ROOT
p4d -f -J off >$P4ROOT/stdout 2>$P4ROOT/stderr &
trap "echo % stop the p4 server ; p4 admin stop" EXIT

# wait for the server to initialize
while ! p4 ; do
   sleep 1
done >/dev/null 2>/dev/null

echo % create a client spec
P4CLIENT=hg-p4-import; export P4CLIENT
DEPOTPATH=//depot/test-mercurial-import/...
p4 client -o | sed '/^View:/,$ d' >p4client
echo View: >>p4client
echo " $DEPOTPATH //$P4CLIENT/..." >>p4client
p4 client -i <p4client

echo % populate the depot
echo a > a
mkdir b
echo c > b/c
p4 add a b/c
p4 submit -d initial

echo % change some files
p4 edit a
echo aa >> a
p4 submit -d "change a"

p4 edit b/c
echo cc >> b/c
p4 submit -d "change b/c"

echo % convert
hg convert -s p4 $DEPOTPATH dst
hg -R dst log --template 'rev={rev} desc="{desc}" tags="{tags}" files="{files}"\n'

echo % change some files
p4 edit a b/c
echo aaa >> a
echo ccc >> b/c
p4 submit -d "change a b/c"

echo % convert again
hg convert -s p4 $DEPOTPATH dst
hg -R dst log --template 'rev={rev} desc="{desc}" tags="{tags}" files="{files}"\n'

echo % interesting names
echo dddd > "d d"
mkdir " e"
echo fff >" e/ f"
p4 add "d d" " e/ f"
p4 submit -d "add d e f"

echo % convert again
hg convert -s p4 $DEPOTPATH dst
hg -R dst log --template 'rev={rev} desc="{desc}" tags="{tags}" files="{files}"\n'