Help with my first extension

Mads Kiilerich mads at kiilerich.com
Sun Sep 11 13:29:38 CDT 2011


illusory wrote, On 09/11/2011 12:27 AM:
> I'm creating my first Mercurial extension (I'm also a Python newbie), and I've
> become stuck.
>
> The extension I'm creating is called 'checkpoint'.  It is very simple, and it
> allows the user to create temporary checkpoints when desired.  Here is how it
> will work:
>
>      http://paste.pocoo.org/show/RkAbiX8w9pxOVJ9ClSVD/

For reference, here is a way to do almost the same with mq and alias. 
(Will need minor modification for windows cmd shell.)

   $ echo '[extensions]' >> $HGRCPATH
   $ echo 'mq=' >> $HGRCPATH
   $ echo '[alias]' >> $HGRCPATH
   $ echo 'checkpoint-start = qnew -q checkpoint' >> $HGRCPATH
   $ echo 'checkpoint = qref' >> $HGRCPATH
   $ echo 'checkpoint-reset = qref -X glob:*' >> $HGRCPATH
   $ echo 'checkpoint-finish = ! hg checkpoint-reset && hg qpop -qf && 
hg qrm checkpoint' >> $HGRCPATH

   $ hg init
   $ echo foo > foo
   $ hg ci -Aqm foo
   $ echo first >> foo
   $ hg diff --nodates --git
   diff --git a/foo b/foo
   --- a/foo
   +++ b/foo
   @@ -1,1 +1,2 @@
    foo
   +first

   $ hg checkpoint-start
   $ hg diff --nodates --git
   $ echo second >> foo
   $ hg diff --nodates --git
   diff --git a/foo b/foo
   --- a/foo
   +++ b/foo
   @@ -1,2 +1,3 @@
    foo
    first
   +second

   $ hg checkpoint
   $ hg diff --nodates --git

   $ hg checkpoint-finish
   patch queue now empty
   $ hg diff --nodates --git
   diff --git a/foo b/foo
   --- a/foo
   +++ b/foo
   @@ -1,1 +1,3 @@
    foo
   +first
   +second

/Mads



More information about the Mercurial-devel mailing list