#!/bin/sh # # Copyright (c) 2012 Steven Walter # global test_description := ''git svn merge detection'' source ./lib-git-svn.sh global svn_ver := $[svn --version --quiet] matchstr $svn_ver { 0.* | 1.[0-4].* { global skip_all := ""skipping git-svn test - SVN too old ($svn_ver)"" test_done } } test_expect_success 'initialize source svn repo' ' svn_cmd mkdir -m x "$svnrepo"/trunk && svn_cmd mkdir -m x "$svnrepo"/branches && svn_cmd co "$svnrepo"/trunk "$SVN_TREE" && ( cd "$SVN_TREE" && touch foo && svn_cmd add foo && svn_cmd commit -m "initial commit" && svn_cmd cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch1 && svn_cmd switch "$svnrepo"/branches/branch1 && touch bar && svn_cmd add bar && svn_cmd commit -m branch1 && svn_cmd cp -m branch "$svnrepo"/branches/branch1 "$svnrepo"/branches/branch2 && svn_cmd switch "$svnrepo"/branches/branch2 && touch baz && svn_cmd add baz && svn_cmd commit -m branch2 && svn_cmd switch "$svnrepo"/trunk && svn_cmd merge --reintegrate "$svnrepo"/branches/branch2 && svn_cmd commit -m "merge branch2" ) && rm -rf "$SVN_TREE" ' test_expect_success 'clone svn repo' ' git svn init -s "$svnrepo" && git svn fetch ' test_expect_success 'verify merge commit' 'x=$(git rev-parse HEAD^2) && y=$(git rev-parse origin/branch2) && test "x$x" = "x$y" ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git svn merge detection">)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./lib-git-svn.sh)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:svn_ver) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(svn)} {(--version)} {(--quiet)})]) left_token: spids: [25 31] ) ) } spids: [23] ) ] spids: [23] ) (Case to_match: {($ VSub_Name "$svn_ver")} arms: [ (case_arm pat_list: [ {(0.) (Lit_Other "*")} {(1.) (Lit_Other "[") (0-4) (Lit_Other "]") (.) (Lit_Other "*")} ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:skip_all) op: Equal rhs: {(DQ ("skipping git-svn test - SVN too old (") ($ VSub_Name "$svn_ver") (")"))} spids: [54] ) ] spids: [54] ) (C {(test_done)}) ] spids: [40 51 65 -1] ) ] spids: [34 38 67] ) (C {(test_expect_success)} {(SQ <"initialize source svn repo">)} { (SQ <"\n"> <"\tsvn_cmd mkdir -m x \"$svnrepo\"/trunk &&\n"> <"\tsvn_cmd mkdir -m x \"$svnrepo\"/branches &&\n"> <"\tsvn_cmd co \"$svnrepo\"/trunk \"$SVN_TREE\" &&\n"> <"\t(\n"> <"\t\tcd \"$SVN_TREE\" &&\n"> <"\t\ttouch foo &&\n"> <"\t\tsvn_cmd add foo &&\n"> <"\t\tsvn_cmd commit -m \"initial commit\" &&\n"> <"\t\tsvn_cmd cp -m branch \"$svnrepo\"/trunk \"$svnrepo\"/branches/branch1 &&\n"> <"\t\tsvn_cmd switch \"$svnrepo\"/branches/branch1 &&\n"> <"\t\ttouch bar &&\n"> <"\t\tsvn_cmd add bar &&\n"> <"\t\tsvn_cmd commit -m branch1 &&\n"> < "\t\tsvn_cmd cp -m branch \"$svnrepo\"/branches/branch1 \"$svnrepo\"/branches/branch2 &&\n" > <"\t\tsvn_cmd switch \"$svnrepo\"/branches/branch2 &&\n"> <"\t\ttouch baz &&\n"> <"\t\tsvn_cmd add baz &&\n"> <"\t\tsvn_cmd commit -m branch2 &&\n"> <"\t\tsvn_cmd switch \"$svnrepo\"/trunk &&\n"> <"\t\tsvn_cmd merge --reintegrate \"$svnrepo\"/branches/branch2 &&\n"> <"\t\tsvn_cmd commit -m \"merge branch2\"\n"> <"\t) &&\n"> <"\trm -rf \"$SVN_TREE\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"clone svn repo">)} {(SQ <"\n"> <"\tgit svn init -s \"$svnrepo\" &&\n"> <"\tgit svn fetch\n">)} ) (C {(test_expect_success)} {(SQ <"verify merge commit">)} { (SQ <"x=$(git rev-parse HEAD^2) &&\n"> <"\ty=$(git rev-parse origin/branch2) &&\n"> <"\ttest \"x$x\" = \"x$y\"\n"> ) } ) (C {(test_done)}) ] )