Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build: off

test_script:
- test\hg\bat\test-incoming.bat
- test\hg\bat\test-incoming.bat
- test\hg\bat\test-incoming.bat branch-with-dash
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ install: true

script:
- chmod +x test/hg/bash/test-incoming.sh
- ./test/hg/bash/test-incoming.sh
- ./test/hg/bash/test-incoming.sh
- ./test/hg/bash/test-incoming.sh with-dash
6 changes: 3 additions & 3 deletions src/hg/bat/incoming.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ set closed=hg log -r "closed() and branch(%BRANCH%)" --template "{node}\n"
FOR /F "tokens=*" %%f in ('%first%') do SET INITIAL=%%f
rem On new branch
if "%HG_NODE%"=="%INITIAL%" (
if not "%~1"=="" call %~1 %BRANCH% %HG_NODE%
if not "%~1"=="" call %~1 "%BRANCH%" "%HG_NODE%"
goto done
)
FOR /F "tokens=*" %%f in ('%closed%') do SET CLOSE=%%f

rem On close branch
if "%HG_NODE%"=="%CLOSE%" (
if not "%~3"=="" call %~3 %BRANCH% %HG_NODE%
if not "%~3"=="" call %~3 "%BRANCH%" "%HG_NODE%"
goto done
)

rem On existing branch
if not "%~2"=="" call %~2 %BRANCH% %HG_NODE%
if not "%~2"=="" call %~2 "%BRANCH%" "%HG_NODE%"
goto done
:done
15 changes: 15 additions & 0 deletions test/hg/bash/change-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

if [ -z $2 ]; then
echo "ERROR: Branch name not given. Cannot create branch without name."
exit 1
fi

CURRENT=$(hg branch)

if [ "$CURRENT" = "$1" ]; then
echo "WARN: Already in given branch."
fi

hg -R $1 branch $2
hg -R $1 push -f
19 changes: 13 additions & 6 deletions test/hg/bash/test-incoming.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ checkReturnCode() {
fi
}

BRANCH=$1

if [ -z $BRANCH ]; then
BRANCH=default
fi

REPO1=repository1
REPO2=repository2
SCRIPT_PATH=$(dirname `which $0`)
Expand All @@ -31,6 +37,7 @@ source $SCRIPT_PATH/add-hook.sh $REPO1 incoming "$NP" "$NE" "$NC"
ret_code=$?
checkReturnCode $ret_code $CLEANUP

source $SCRIPT_PATH/change-branch.sh $ABSOLUTE/$REPO2 $BRANCH

source $SCRIPT_PATH/change-file.sh $ABSOLUTE/$REPO2 "file"
ret_code=$?
Expand All @@ -44,9 +51,9 @@ source $SCRIPT_PATH/close-branch.sh $ABSOLUTE/$REPO2
ret_code=$?
checkReturnCode $ret_code $CLEANUP

EXPECTED_NEW=("default")
EXPECTED_EXISTING=("default")
EXPECTED_CLOSED=("default")
EXPECTED_NEW=("$BRANCH")
EXPECTED_EXISTING=("$BRANCH")
EXPECTED_CLOSED=("$BRANCH")
I=0
while IFS='' read -r line || [[ -n "$line" ]]; do
linearr=($line)
Expand All @@ -55,7 +62,7 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
fi
let "I++"
done < "$NEWBRANCH"
if [! $i -eq ${EXPECTED_NEW[@]} ]; then
if [ "$I" -ne "${#EXPECTED_NEW[@]}" ]; then
RESULT=1
fi
I=0
Expand All @@ -68,7 +75,7 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
let "I++"
done < "$EXISTING"

if [! $i -eq ${EXPECTED_EXISTING[@]} ]; then
if [ "$I" -ne "${#EXPECTED_EXISTING[@]}" ]; then
RESULT=1
fi

Expand All @@ -82,7 +89,7 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
let "I++"
done < "$CLOSED"

if [! $i -eq ${EXPECTED_CLOSED[@]} ]; then
if [ "$I" -ne "${#EXPECTED_CLOSED[@]}" ]; then
RESULT=1
fi

Expand Down
18 changes: 18 additions & 0 deletions test/hg/bat/change-branch.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
IF [%2] == [] GOTO BranchNotSet


for /f %%i in ('hg -R %1 branch') do set current=%%i

if [%2] == [%current%] GOTO Ready

hg -R %1 branch %2
hg -R %1 push -f
GOTO Ready


:BranchNotSet
echo "ERROR: Cannot change branch if it is not defined"
exit 1

:Ready

11 changes: 6 additions & 5 deletions test/hg/bat/test-incoming.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@ECHO OFF
setlocal EnableDelayedExpansion

set branch=%1
if [%branch%] == [] set branch=default
set result=0
set r1=repository1
set r2=repository2
Expand All @@ -17,16 +18,16 @@ if errorlevel 1 (
set result=1
goto CLEANUP
)

call %~dp0\change-branch.bat %r2% %branch%
call %~dp0\change-file.bat %r2% file
call %~dp0\change-file.bat %r2% file
call %~dp0\close-branch.bat %r2%

rem Verify results
echo Starting to verify results
set expectedNew[0]=default
set expectedExisting[0]=default
set expectedClose[0]=default
set expectedNew[0]=%branch%
set expectedExisting[0]=%branch%
set expectedClose[0]=%branch%

rem TODO: calculate from above
set countNew=1
Expand Down