view tests/test-mq-guards @ 5378:8a2915f57dfc

convert: add a mode where mercurial_sink skips empty revisions. The getchanges function of some converter_source classes can return some false positives. I.e. they sometimes claim that a file "foo" was changed in some revision, even though its contents are still the same. convert_svn is particularly bad, but I think this can also happen with convert_cvs and, at least in theory, with mercurial_source. For regular conversions this is not really a problem - as long as getfile returns the right contents, we'll get a converted revision with the right contents. But when we use --filemap, this could lead to superfluous revisions being converted. Instead of fixing every converter_source, I decided to change mercurial_sink to work around this problem. When --filemap is used, we're interested only in revisions that touch some specific files. If a revision doesn't change any of these files, then we're not interested in it (at least for revisions with a single parent; merges are special). For mercurial_sink, we abuse this property and rollback a commit if the manifest text hasn't changed. This avoids duplicating the logic from localrepo.filecommit to detect unchanged files.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Thu, 04 Oct 2007 23:21:37 -0300
parents 8369672060b5
children 5b81c1cc6ebe
line wrap: on
line source

#!/bin/sh

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

hg init
hg qinit

echo x > x
hg ci -Ama

hg qnew a.patch
echo a > a
hg add a
hg qrefresh

hg qnew b.patch
echo b > b
hg add b
hg qrefresh

hg qnew c.patch
echo c > c
hg add c
hg qrefresh

hg qpop -a

echo % should fail
hg qguard does-not-exist.patch +bleh

echo % should fail
hg qguard +fail

hg qpush
echo % should guard a.patch
hg qguard +a
echo % should print +a
hg qguard
hg qpop

hg qguard a.patch
echo % should push b.patch
hg qpush

hg qpop
hg qselect a
echo % should push a.patch
hg qpush

hg qguard c.patch -a
echo % should print -a
hg qguard c.patch

echo % should skip c.patch
hg qpush -a
echo % should display b.patch
hg qtop

hg qguard -n c.patch
echo % should push c.patch
hg qpush -a

hg qpop -a
hg qselect -n
echo % should push all
hg qpush -a

hg qpop -a
hg qguard a.patch +1
hg qguard b.patch +2
hg qselect 1
echo % should push a.patch, not b.patch
hg qpush
hg qpush
hg qpop -a

hg qselect 2
echo % should push b.patch
hg qpush
hg qpush -a
# Used to be an issue with holes in the patch sequence
# So, put one hole on the base and ask for topmost patch.
hg qtop
hg qpop -a

hg qselect 1 2
echo % should push a.patch, b.patch
hg qpush
hg qpush
hg qpop -a

hg qguard a.patch +1 +2 -3
hg qselect 1 2 3
echo % list patches and guards
hg qguard -l
echo % list series
hg qseries -v
echo % list guards
hg qselect
echo % should push b.patch
hg qpush

hg qpush -a
hg qselect -n --reapply
echo % guards in series file: +1 +2 -3
hg qselect -s
echo % should show c.patch
hg qapplied

hg qrename a.patch new.patch
echo % should show :
echo % new.patch: +1 +2 -3
echo % b.patch: +2
echo % c.patch: unguarded
hg qguard -l

hg qnew d.patch
hg qpop
echo % should show new.patch and b.patch as Guarded, c.patch as Applied
echo % and d.patch as Unapplied
hg qseries -v

hg qguard d.patch +2
echo % new.patch, b.patch: Guarded. c.patch: Applied. d.patch: Guarded.
hg qseries -v

qappunappv()
(
    for command in qapplied "qapplied -v" qunapplied "qunapplied -v"; do
        echo % hg $command
        hg $command
    done
)

hg qpop -a
hg qguard -l
qappunappv
hg qselect 1
qappunappv
hg qpush -a
qappunappv
hg qselect 2
qappunappv

for patch in `hg qseries`; do
    echo % hg qapplied $patch
    hg qapplied $patch
    echo % hg qunapplied $patch
    hg qunapplied $patch
done

echo % hg qseries -m: only b.patch should be shown
echo the guards file was not ignored in the past
hg qdelete -k b.patch
hg qseries -m