| 
#!/bin/bash
 | 
 | 
 | 
 | 
# Comparativo de ramificação entre Subversion, Git e Mercurial
 | 
 | 
# https://blog.pronus.io/posts/comparacao-de-ramificacao-entre-subversion-mercurial-e-git
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
# Estudo de caso
 | 
 | 
#
 | 
 | 
#          (2)----(3)                       > 1.x
 | 
 | 
#          /         \
 | 
 | 
#  (0)---(1)---(4)---(6)---(7)--(11)--(12)  > principal
 | 
 | 
#                \           \        /
 | 
 | 
#                (5)---(8)---(9)---(10)     > funcionalidade-x
 | 
 | 
 | 
 | 
 | 
 | 
#
 | 
 | 
# Subversion
 | 
 | 
#
 | 
 | 
 | 
 | 
 | 
 | 
if [ -d /tmp/svn_repos ]; then
 | 
 | 
    rm -rf svn_repos svn_user
 | 
 | 
fi
 | 
 | 
 | 
 | 
cd /tmp
 | 
 | 
 | 
 | 
# function revisao_svn {
 | 
 | 
#     echo $1 > $1.txt
 | 
 | 
#     svn add $1.txt
 | 
 | 
#     svn commit -m $1 --username Fulano
 | 
 | 
# }
 | 
 | 
 | 
 | 
# svnadmin create svn_repos
 | 
 | 
# path='file:///tmp/svn_repos'
 | 
 | 
# svn mkdir $path/trunk $path/branches $path/tags -m estrutura_inicial --username Fulano
 | 
 | 
# svn checkout $path/trunk svn_user
 | 
 | 
# cd svn_user
 | 
 | 
# revisao_svn 0
 | 
 | 
# revisao_svn 1
 | 
 | 
 | 
 | 
# svn cp ^/trunk ^/branches/1.x -m 'Criação do ramo 1.x' --username Fulano
 | 
 | 
# svn switch ^/branches/1.x
 | 
 | 
# revisao_svn 2
 | 
 | 
# revisao_svn 3
 | 
 | 
 | 
 | 
# svn switch ^/trunk
 | 
 | 
# revisao_svn 4
 | 
 | 
 | 
 | 
# svn cp ^/trunk ^/branches/funcionalidade-x -m 'Criação do ramo funcionalidade-x' --username Fulano
 | 
 | 
# svn switch ^/branches/funcionalidade-x
 | 
 | 
# revisao_svn 5
 | 
 | 
 | 
 | 
# svn switch ^/trunk
 | 
 | 
# svn merge ^/branches/1.x
 | 
 | 
# svn commit -m '6' --username Fulano
 | 
 | 
# revisao_svn 7
 | 
 | 
 | 
 | 
# svn switch ^/branches/funcionalidade-x
 | 
 | 
# revisao_svn 8
 | 
 | 
# svn update
 | 
 | 
# svn merge ^/trunk
 | 
 | 
# svn commit -m '9' --username Fulano
 | 
 | 
# revisao_svn 10
 | 
 | 
 | 
 | 
# svn switch ^/trunk
 | 
 | 
# revisao_svn 11
 | 
 | 
# svn update
 | 
 | 
# svn merge ^/branches/funcionalidade-x
 | 
 | 
# svn commit -m '12' --username Fulano
 | 
 | 
 | 
 | 
# echo -e '\nLog do ramo principal (trunk)'
 | 
 | 
# svn log ^/trunk | grep -P '^[^r-]'
 | 
 | 
# echo -e '\nLog do ramo 1.x'
 | 
 | 
# svn log --stop-on-copy ^/branches/1.x | grep -P '^[^r-]'
 | 
 | 
# echo -e '\nLog do ramo funcionalidade-x'
 | 
 | 
# svn log --stop-on-copy ^/branches/funcionalidade-x | grep -P '^[^r-]'
 | 
 | 
# echo -e '\nPropriedade svn:mergeinfo no trunk ao final do estudo de caso'
 | 
 | 
# svn propget svn:mergeinfo
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
# echo -e '\n\n\n--------------------------------------------------\nMercurial'
 | 
 | 
 | 
 | 
 | 
 | 
# if [ -d hg_user ]; then
 | 
 | 
#     rm -rf hg_user
 | 
 | 
# fi
 | 
 | 
 | 
 | 
# cd /tmp
 | 
 | 
 | 
 | 
# hg='chg'
 | 
 | 
 | 
 | 
# function revisao_hg {
 | 
 | 
#     echo $1 > $1.txt
 | 
 | 
#     $hg commit -Am $1
 | 
 | 
# }
 | 
 | 
 | 
 | 
 | 
 | 
# $hg init hg_user
 | 
 | 
# cd hg_user
 | 
 | 
# echo '[ui]
 | 
 | 
# username = Fulano <fulano@email.com>' > .hg/hgrc
 | 
 | 
# revisao_hg 0
 | 
 | 
# revisao_hg 1
 | 
 | 
 | 
 | 
# $hg branch 1.x
 | 
 | 
# revisao_hg 2
 | 
 | 
# revisao_hg 3
 | 
 | 
 | 
 | 
# $hg update default
 | 
 | 
# revisao_hg 4
 | 
 | 
 | 
 | 
# $hg branch funcionalidade-x
 | 
 | 
# revisao_hg 5
 | 
 | 
 | 
 | 
# $hg update default
 | 
 | 
# $hg merge 1.x
 | 
 | 
# $hg commit -m 6
 | 
 | 
# revisao_hg 7
 | 
 | 
 | 
 | 
# $hg update funcionalidade-x
 | 
 | 
# revisao_hg 8
 | 
 | 
# $hg merge default
 | 
 | 
# $hg commit -m 9
 | 
 | 
# revisao_hg 10
 | 
 | 
 | 
 | 
# $hg update default
 | 
 | 
# revisao_hg 11
 | 
 | 
# $hg merge funcionalidade-x
 | 
 | 
# $hg commit -m 12
 | 
 | 
 | 
 | 
 | 
 | 
# echo -e '\nLog do ramo principal (default)'
 | 
 | 
# $hg log -b default -T '{rev}\n'
 | 
 | 
# echo -e '\nLog do ramo 1.x'
 | 
 | 
# $hg log -b 1.x -T '{rev}\n'
 | 
 | 
# echo -e '\nLog do ramo funcionalidade-x'
 | 
 | 
# $hg log -b funcionalidade-x -T '{rev}\n'
 | 
 | 
 | 
 | 
 | 
 | 
 | 
 | 
echo -e '\n\n\n--------------------------------------------------\nGit'
 | 
 | 
 | 
 | 
#
 | 
 | 
# Ramificação pelo Git
 | 
 | 
#
 | 
 | 
 | 
 | 
 | 
 | 
function revisao_git {
 | 
 | 
    echo $1 > $1.txt
 | 
 | 
    git add $1.txt
 | 
 | 
    git commit -am $1
 | 
 | 
}
 | 
 | 
 | 
 | 
if [ -d /tmp/git_user ]; then
 | 
 | 
    rm -rf git_user
 | 
 | 
fi
 | 
 | 
 | 
 | 
cd /tmp
 | 
 | 
 | 
 | 
git init git_user
 | 
 | 
cd git_user
 | 
 | 
git config user.name Fulano
 | 
 | 
git config user.email fulano@email.com
 | 
 | 
 | 
 | 
revisao_git 0
 | 
 | 
revisao_git 1
 | 
 | 
 | 
 | 
git checkout -b 1.x
 | 
 | 
revisao_git 2
 | 
 | 
revisao_git 3
 | 
 | 
 | 
 | 
git checkout master
 | 
 | 
revisao_git 4
 | 
 | 
git checkout -b funcionalidade-x
 | 
 | 
revisao_git 5
 | 
 | 
git checkout master
 | 
 | 
git merge 1.x -m 6
 | 
 | 
revisao_git 7
 | 
 | 
 | 
 | 
git checkout funcionalidade-x
 | 
 | 
revisao_git 8
 | 
 | 
git merge master -m 9
 | 
 | 
revisao_git 10
 | 
 | 
git checkout master
 | 
 | 
revisao_git 11
 | 
 | 
git merge funcionalidade-x -m 12
 | 
 | 
 | 
 | 
 | 
 | 
echo -e '\n\n======\nmaster\n======'
 | 
 | 
git log --graph --pretty=oneline master
 | 
 | 
echo -e '\n\n===\n1.x\n==='
 | 
 | 
git log --graph --pretty=oneline 1.x
 | 
 | 
echo -e '\n\n=======\nfuncionalidade-x\n======='
 | 
 | 
git log --graph --pretty=oneline funcionalidade-x
 |