hgforest-crew / test-forest

#! /bin/sh

#alias hg='hg --traceback'

fixpath()
{
    sed -e "s@\(/private\)*$HGTMP@HGTMP@g"
}

HGRCPATH=$HGTMP/.hgrc
export HGRCPATH
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
echo "forest=" >> $HGRCPATH

echo "# setup initial forest"
hg init toplevel
echo "f" > toplevel/f
mkdir toplevel/d
echo "d/f" > toplevel/d/f
mkdir toplevel/d/d
echo "d/d/f" > toplevel/d/d/f
hg init toplevel/d/d/t
echo "d/d/t/f" > toplevel/d/d/t/f
hg init toplevel/t
echo "t/f" > toplevel/t/f
hg init toplevel/t/t
echo "t/t/f" > toplevel/t/t/f
mkdir toplevel/e
hg init toplevel/e/d
echo "e/d/f" > toplevel/e/d/f
hg commit --cwd toplevel -A -m "start" -d "0 0"
hg commit --cwd toplevel/d/d/t -A -m "start" -d "0 0"
hg commit --cwd toplevel/t -A -m "start" -d "0 0"
hg commit --cwd toplevel/t/t -A -m "start" -d "0 0"
hg commit --cwd toplevel/e/d -A -m "start" -d "0 0"

echo "# ftrees"
hg ftrees --convert --cwd toplevel

echo "# fstatus"
echo "x" >> toplevel/d/d/t/f
echo "new" >> toplevel/t/t/f2
hg fstatus --cwd toplevel
hg revert --cwd toplevel/d/d/t --no-backup  f
rm -f toplevel/t/t/f2
hg fstatus --cwd toplevel

echo "# fclone"
hg fclone toplevel topcopy
hg fsnap --cwd topcopy > top-snap

echo "# fsnap"
hg fsnap --cwd toplevel > top-snap1
echo "x" >> toplevel/t/t/f
hg commit --cwd toplevel/t/t -m "new line" -d "0 0"
echo "f2" > toplevel/d/d/f2
hg commit --cwd toplevel/d/d -A -m "new file" -d "0 0"
hg fsnap -R toplevel > top-snap2
diff -u top-snap1 top-snap2 | \
    sed -e 's/--- top-snap1.*$/--- top-snap1/' \
        -e 's/+++ top-snap2.*$/+++ top-snap2/'

echo "# ftag"
hg fclone toplevel newtop > /dev/null
hg ftag -R newtop fred
hg ftag -R newtop barney
hg ftag -R newtop -r fred wilma
hg tags --cwd newtop | sed -e 's/:.*//'
echo
hg tags --cwd newtop/d/d/t | sed -e 's/:.*//'
echo
rm -rf newtop

echo "# fupdate"
hg fclone toplevel newtop > /dev/null
hg fupdate -R newtop top-snap
hg parents --cwd newtop/d/d/t
hg parents --cwd newtop/t/t
hg fupdate --cwd newtop --tip
hg update --cwd newtop 0
hg update --cwd newtop/t/t 0
hg fupdate --cwd newtop
hg update --cwd newtop 0
hg update --cwd newtop/t/t 0
hg fupdate --cwd newtop --rev tip
hg update --cwd newtop 0
hg update --cwd newtop/t/t 0
hg fupdate --cwd newtop tip
hg update --cwd newtop 0
hg update --cwd newtop/t/t 0
rm -f newtop/f newtop/t/t/f
hg fupdate --cwd newtop -C
hg parents --cwd newtop/d/d/t
hg parents --cwd newtop/t/t
rm -rf newtop

echo "# fseed"
hg clone toplevel newtop
hg fseed top-snap default
rm -rf newtop
hg fseed --traceback --root newtop top-snap default >/dev/null
hg fsnap --cwd newtop --compatible | fixpath
hg fsnap --cwd newtop | fixpath
rm -rf newtop

echo "# fpull"
hg fpull --cwd topcopy -u --snapfile=../top-snap default 2>&1 \
    | fixpath
hg fpull --cwd topcopy -u ../top-snap default 2>&1 \
    | fixpath
# Simulate a new repository
rm -rf topcopy/t
hg fpull -R topcopy -u 2>&1 \
    | fixpath

echo "# foutgoing"
echo "t/t/f" > topcopy/t/t/f
hg commit --cwd topcopy/t/t -m "delete new line" -d "0 0"
hg remove --cwd topcopy/d/d f2
hg commit -R topcopy -m "remove new file" -d "0 0"
hg foutgoing -R topcopy 2>&1 | fixpath
hg foutgoing --cwd topcopy default 2>&1 | fixpath
hg foutgoing -R topcopy foo 2>&1 | fixpath

echo "# fincoming"
hg fincoming -R toplevel topcopy 2>&1 | fixpath
hg fincoming --cwd toplevel ../topcopy 2>&1 | fixpath
hg fincoming -R toplevel foo 2>&1 | fixpath

echo "# fpush"
hg fpush -R topcopy top-snap default | fixpath

echo "# fseed and fpull, missing section"
cat top-snap | \
    sed -e '/\[tree2\]/,/^$/ d' \
        -e '/\[tree2.paths\]/,/^$/ d' > top-snap-missing
# with --root
hg fseed --root missing top-snap-missing default
hg ftrees --cwd missing --convert
rm -rf missing
# without --root
hg init missing
hg fseed --cwd missing ../top-snap-missing default
hg ftrees -R missing --convert
# pull (should find toplevel changesets)
hg fpull -R missing top-snap-missing default 2>&1 \
    | fixpath
rm -rf missing

echo "# fseed and fpull, named section"
cat top-snap | \
  sed 's/\[tree2/\[treenamed/' > top-snap-named
hg fseed --root named top-snap-named default
hg ftrees --cwd named --convert
# pull (should find nothing)
hg fpull --cwd named ../top-snap-named default 2>&1 \
    | fixpath
rm -rf named

# create an mq patch in topcopy/t
hg qinit --cwd topcopy/t
hg qnew --cwd topcopy/t mq-patch
echo "zzz" > topcopy/t/z
hg add --cwd topcopy/t z
hg qrefresh --cwd topcopy/t

# create a versioned mq patch in topcopy/t
hg qinit -c --cwd topcopy/t/t
hg qnew --cwd topcopy/t/t mq-patch
echo "zzz" > topcopy/t/t/z
hg add --cwd topcopy/t/t z
hg qrefresh --cwd topcopy/t/t

echo "# fstatus + mq"
hg fstatus --cwd topcopy

echo "# fclone + mq"
hg fclone topcopy newtop
rm -rf newtop

echo "# fsnap + mq"
hg fsnap --cwd topcopy ../top-snap1

echo "# fpull + mq"
hg fpull --cwd topcopy -u ../top-snap default 2>&1 \
    | fixpath

echo "# fpush + mq"
hg fpush --cwd topcopy ../top-snap default 2>&1 \
    | fixpath

echo "# fupdate + mq"
hg fupdate --cwd topcopy

echo "# walk **/.hg"
hg init walkhg
hg init walkhg/.hg/h
hg init walkhg/a
hg init walkhg/a/.hg/h
hg ftrees --cwd walkhg --convert --walkhg=0
hg ftrees -R walkhg --convert
echo "[forest]" >> walkhg/.hg/hgrc
echo "walkhg = Yes" >> walkhg/.hg/hgrc
hg ftrees -R walkhg --convert
hg ftrees --cwd walkhg --convert --walkhg=FALSE
echo "[forest]" >> walkhg/.hg/hgrc
echo "walkhg = No" >> walkhg/.hg/hgrc
hg ftrees -R walkhg --convert
hg ftrees --cwd walkhg --convert --walkhg=FALSE

echo "# circular trees"
hg init circular
hg init circular/a
ln -s . circular/b
hg init circular/a/a
ln -s . circular/a/b
ln -s .. circular/a/c
hg fstatus -R circular

echo "# fpull --partial"
hg init partial
hg init partial/a
echo "a" >partial/a/f
hg init partial/b
echo "b" >partial/b/f
hg commit --cwd partial/a -A -m init -d "0 0"
hg commit --cwd partial/b -A -m init -d "0 0"
hg fclone partial partial-clone | fixpath
rm -rf partial-clone/b
hg --cwd partial-clone fpull --partial 2>&1 | fixpath
echo "[forest]" >> partial-clone/.hg/hgrc
echo "partial = Yes" >> partial-clone/.hg/hgrc
hg --cwd partial-clone fpull 2>&1 | fixpath
echo "[forest]" >> partial-clone/.hg/hgrc
echo "partial = No" >> partial-clone/.hg/hgrc
hg --cwd partial-clone fpull 2>&1 | fixpath
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.