This is a common question I know, but I want to take it to the next level, I know how to use bundles, but is kind of boring having to dig trough the “hg log” to see my last changes, so I want to make it automatic, checking my log trough bash/awk and identifying work/home changes trough date and mail, (I have diferent mails in .hgrc, me@work and me@home).
I already have this bash function but I have to pass the base revision manually:
hgb () {
hg bundle --base $1 ~/changes-`date +%Y-%m-%d-%H-%M`.hg
}
So I would like something like:
mkwbundle #make work bundle for home
and:
mkhbundle #make home bundle for work
I’m just beginning at awk/sed but I’ve seen miracles, I ask before doing it with Python which is my goto tool for almost anything.
Update:
For mercurial agnostic people, this is how hg log looks like:
changeset: 28:f5200232460e
tag: tip
user: Manuel@home
date: Tue Jan 15 23:39:57 2013 -0500
summary: Adding DevTodo
changeset: 27:828dbba6830a
user: Manuel@home
date: Tue Jan 15 23:24:57 2013 -0500
summary: login twig
changeset: 26:781477f86f6f
user: Manuel@home
date: Tue Jan 15 00:18:54 2013 -0500
summary: UI mockup
changeset: 25:0c9365b200a8
user: Manuel@home
date: Mon Jan 14 23:50:22 2013 -0500
summary: using twig blocks, remember reuse parent
changeset: 24:a1abfcfcefed
user: Manuel@work
date: Mon Jan 14 23:49:44 2013 -0500
summary: smaller footer
changeset: 23:3cd12b7fb684
user: Manuel@work
date: Mon Jan 14 23:20:18 2013 -0500
summary: test content width
I want to get the base revision when in work to make a bundle, let’s say I started working in rev 24 at home and made 4 changes, then I’m in 28, I want to get 24 as base rev and make a bundle, then the same at work.
EDIT: per @dhunter comment below, the expected output of the script would be:
24
Revset version for
hg bundle --base REVtype of commandUsed: revsets, revsets aliases
Task in a verbal form: find latest changeset, after which to tip changesets continuously created by another author, than sought-for changeset
Solution:
Iteration 1
max(user('work'))for bundle with changesets, intended to be transferred to work (all after latest “work” is homework)max(user('home'))for bundle with changesets, intended to be transferred to home (all after latest “home” is workplacework)Iteration 2
Compacting and beautification: I’m too lazy for too much typing. Bundleable() function-name shortened to ba() and added to in the “revsetalias” section of a Mercurial configuration file for home and work repos
(‘$1’ instead of $1 used in order to don’t write ” around parameter – signal string – by hand)
Results
hg bundle --base "ba(home)"orhg bundle --base "ba(work)"home|work define destination, for which bundle have to be prepared