view tests/test-convert-svn-sink @ 10397:8cb81d75730c

mq: add parent node IDs to MQ patches on qrefresh/qnew The goal of this patch is to add the IDs of the parents of applied MQ patches into the patch file headers whenever qnew or qrefresh are run. This will serve as a reminder of when the patches last applied cleanly and will let us do more intelligent things in the future, such as: * Resolve conflicts found when qpushing to a new location by merging instead of simply showing rejects. * Display better diffs of versioned MQ patches because we can tell how the patched files have changed in the meantime. Here are the new rules this patch introduces. They are checked in this order: * If a patch currently has old, plain-style patch headers ("From:" and "Date:") do not change the style or add any new headers. * If the 'mq.plain' configuration setting is true, only plain-style headers will be used for all MQ patches. * qnew will initialize new patches with HG-style headers and fill in the "# Parent" header with the appropriate parent node. * qrefresh will refresh the "# Parent" header with the current parent of the current patch.
author Steve Losh <steve@stevelosh.com>
date Sun, 07 Feb 2010 10:47:54 -0500
parents 99e5f97c9a97
children 14db59e3b248
line wrap: on
line source

#!/bin/sh

"$TESTDIR/hghave" svn svn-bindings no-outer-repo || exit 80

fixpath()
{
    tr '\\' /
}

svnupanddisplay()
{
    (
       cd $1;
       svn up;
       svn st -v | fixpath | sed 's/  */ /g'
       limit=''
       if [ $2 -gt 0 ]; then
           limit="--limit=$2"
       fi
       svn log --xml -v $limit | fixpath | sed 's,<date>.*,<date/>,' | grep -v 'kind="'
    )
}

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

hg init a

echo a > a/a
mkdir -p a/d1/d2
echo b > a/d1/d2/b
echo % add
hg --cwd a ci -d '0 0' -A -m 'add a file'

"$TESTDIR/svn-safe-append.py" a a/a
echo % modify
hg --cwd a ci -d '1 0' -m 'modify a file'
hg --cwd a tip -q

hg convert -d svn a
svnupanddisplay a-hg-wc 2
ls a a-hg-wc
cmp a/a a-hg-wc/a && echo same || echo different

hg --cwd a mv a b
echo % rename
hg --cwd a ci -d '2 0' -m 'rename a file'
hg --cwd a tip -q

hg convert -d svn a
svnupanddisplay a-hg-wc 1
ls a a-hg-wc

hg --cwd a cp b c
echo % copy
hg --cwd a ci -d '3 0' -m 'copy a file'
hg --cwd a tip -q

hg convert -d svn a
svnupanddisplay a-hg-wc 1
ls a a-hg-wc

hg --cwd a rm b
echo % remove
hg --cwd a ci -d '4 0' -m 'remove a file'
hg --cwd a tip -q

hg convert -d svn a
svnupanddisplay a-hg-wc 1
ls a a-hg-wc

chmod +x a/c
echo % executable
hg --cwd a ci -d '5 0' -m 'make a file executable'
hg --cwd a tip -q

hg convert -d svn a
svnupanddisplay a-hg-wc 1
test -x a-hg-wc/c && echo executable || echo not executable

echo % executable in new directory

rm -rf a a-hg a-hg-wc
hg init a

mkdir a/d1
echo a > a/d1/a
chmod +x a/d1/a
hg --cwd a ci -d '0 0' -A -m 'add executable file in new directory'

hg convert -d svn a
svnupanddisplay a-hg-wc 1
test -x a-hg-wc/d1/a && echo executable || echo not executable

echo % copy to new directory

mkdir a/d2
hg --cwd a cp d1/a d2/a
hg --cwd a ci -d '1 0' -A -m 'copy file to new directory'

hg convert -d svn a
svnupanddisplay a-hg-wc 1

echo % branchy history

hg init b
echo base > b/b
hg --cwd b ci -d '0 0' -Ambase

"$TESTDIR/svn-safe-append.py" left-1 b/b
echo left-1 > b/left-1
hg --cwd b ci -d '1 0' -Amleft-1

"$TESTDIR/svn-safe-append.py" left-2 b/b
echo left-2 > b/left-2
hg --cwd b ci -d '2 0' -Amleft-2

hg --cwd b up 0

"$TESTDIR/svn-safe-append.py" right-1 b/b
echo right-1 > b/right-1
hg --cwd b ci -d '3 0' -Amright-1

"$TESTDIR/svn-safe-append.py" right-2 b/b
echo right-2 > b/right-2
hg --cwd b ci -d '4 0' -Amright-2

hg --cwd b up -C 2
hg --cwd b merge
hg --cwd b revert -r 2 b
hg resolve -m b
hg --cwd b ci -d '5 0' -m 'merge'

hg convert -d svn b
echo % expect 4 changes
svnupanddisplay b-hg-wc 0