Created
January 15, 2015 00:33
-
-
Save mapio/bb26708a2dd858e00045 to your computer and use it in GitHub Desktop.
A trick to collapse Mercurial revisions in steps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dbg() { | |
echo WORK | |
hg -R work log --template '{node|short} {desc}\n' | |
echo PUBLIC | |
hg -R public log --template '{node|short} {desc}\n' | |
echo CLEAN | |
hg -R clean log --template '{node|short} {desc}\n' | |
} | |
first_magic() { | |
local MFROM=$(hg -R work log -r 1 --template '{node|short}\n') | |
local MTO=$(hg -R work tip --template '{node|short}\n') | |
hg -R public pull work | |
hg -R public phase --draft --force 0:tip | |
hg -R public rebase --dest 0 --base "$MTO" --collapse -m"Collapsed $MFROM up to $MTO" | |
echo $MTO > mto | |
} | |
magic() { | |
local PMTO=$(cat mto) | |
local MFIRST=$(hg -R work log -r 1 --template '{node|short}\n') | |
local MFROM=$(hg -R work log -r "children($PMTO)" --template '{node|short}\n') | |
local MTO=$(hg -R work tip --template '{node|short}\n') | |
local DEST=$(hg -R public tip --template '{node|short}\n') | |
hg -R public pull work | |
hg -R public phase --draft --force 0:tip | |
hg -R public rebase --dest "$DEST" --source "$MFROM" --collapse -m"Collapsed $MFROM up to $MTO" | |
#hg -R public strip -r "$MFIRST" | |
hg -R public push -r tip clean | |
hg -R public up | |
echo $MTO > mto | |
} | |
rm -rf work public clean | |
hg init work | |
hg init public | |
hg init clean | |
V=0 | |
echo $V > work/file.txt | |
hg -R work add work/file.txt | |
hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
first_magic | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
magic | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
magic | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
V=$((V+1)); echo $V > work/file.txt; hg -R work ci -m"Versione $V" | |
magic | |
dbg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment