Skip to content

Instantly share code, notes, and snippets.

@mapio mapio/collapse
Created Jan 15, 2015

Embed
What would you like to do?
A trick to collapse Mercurial revisions in steps
#!/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
You can’t perform that action at this time.