Proof of concept: version control of node contents / per-node-history

6 views
Skip to first unread message

Ville M. Vainio

unread,
Feb 11, 2009, 12:33:52 PM2/11/09
to leo-e...@googlegroups.com
Yet another trivial ILeo hack that needs extreme polish ;-).

This uses directory ~/.leo/dump to store version history of leo nodes
that you "dump" there explicitly. It's a git repository with gnx'es as
the file name (because git is fast and popular. It doesn't really
matter what vcs is used). I've attached the thin node if anyone is
interested, but the only interesting part is this script:

QQQ

wb.require('flatleo_setup')

for n in wb.match_h('.*'):
name, date, num = n.p.t.fileIndex
fname = '%s/%s%s%s' % (flatroot, name, date, num)
open(fname,'w').write(n.b)
print "wrote", fname

print "committing to git"

cd $flatroot
git add *
git commit -m "leo autocommit"

print "committed"

QQQ

That's it! It won't be hard to implement something that will allow you
to go back / forward (revert) in history, now you just need to use
normal git commands and copy/paste ;-). Even now something like this
can make sense as a backup of your data. This would make most sense as
a @button.


--
Ville M. Vainio
http://tinyurl.com/vainio

flatleo.py

Edward K. Ream

unread,
Feb 12, 2009, 7:37:12 AM2/12/09
to leo-e...@googlegroups.com
On Wed, Feb 11, 2009 at 11:33 AM, Ville M. Vainio <viva...@gmail.com> wrote:

This uses directory ~/.leo/dump to store version history of leo nodes
that you "dump" there explicitly.

Cool.  Several people have suggested that this kind of scheme would be more useful than the present global undo.  I tend to agree, although there are times when global undo works well enough to earn its keep.

This looks like an excellent start.  I suspect that with this feature particularly, polish will be important--to reassure people if for no other reason.

Edward

Ville M. Vainio

unread,
Feb 14, 2009, 10:12:18 AM2/14/09
to leo-e...@googlegroups.com
On Wed, Feb 11, 2009 at 7:33 PM, Ville M. Vainio <viva...@gmail.com> wrote:

> Yet another trivial ILeo hack that needs extreme polish ;-).
>
> This uses directory ~/.leo/dump to store version history of leo nodes
> that you "dump" there explicitly. It's a git repository with gnx'es as
> the file name (because git is fast and popular. It doesn't really
> matter what vcs is used). I've attached the thin node if anyone is
> interested, but the only interesting part is this script:

Here is a snippet you can add to "@button git-dump" node:

QQQ
""" Dump nodes to ~/.leo/dump git repository.

Before using this, you need to:
mkdir ~/.leo/dump; cd ~/.leo/dump; git init

"""

import os
flatroot = os.path.expanduser('~/.leo/dump')
assert os.path.isdir(flatroot)

hl = []

def dump_nodes():
for p in c.all_positions_with_unique_tnodes_iter():
name, date, num = p.t.fileIndex
gnx = '%s%s%s' % (name, date, num)
hl.append('<a href="%s">%s%s</a><br/>' % (gnx, '-' * p.level(), p.h))
fname = gnx
open(fname,'w').write(p.b)
print "wrote", fname

os.chdir(flatroot)

dump_nodes()
lis = "\n".join(hl)

html = "<body>\n<tt>\n" + lis + "\n</tt></body>"

#titlename = c.frame.getTitle() + '.html'
titlename = 'index.html'
open(titlename,'w').write(html)

g.es("committing to " + flatroot)

os.system('git add *')
os.system('git commit -m "Leo autocommit"')
g.es("committed")

QQQ

It stores the outline structure as browseable html.

I will push this to scripts.leo as an example.

Edward K. Ream

unread,
Feb 23, 2009, 7:27:06 AM2/23/09
to leo-e...@googlegroups.com
On Sat, Feb 14, 2009 at 9:12 AM, Ville M. Vainio <viva...@gmail.com> wrote:

Here is a snippet you can add to "@button git-dump" node:

QQQ
""" Dump nodes to ~/.leo/dump git repository.

[snip]

This does not seem to have been committed.

Edward

Reply all
Reply to author
Forward
0 new messages