monotone

monotone Mtn Source Tree

Root/examples/display_branches.lua

1-- Lua snippet to display what branches were affected by revisions and certs
2-- that came into the database. It will display each branch name and the
3-- amount of times they each appeared.
4-- I integrate it into my ~/.monotone/monotonerc
5-- /Richard Levitte
6--
7-- Released as public domain
8
9netsync_branches = {}
10function note_netsync_start(nonce)
11 netsync_branches[nonce] = {}
12end
13
14function _note_netsync_cert_received(rev_id,key,name,value,nonce)
15 if name == "branch" then
16 if netsync_branches[nonce][value] == nil then
17 netsync_branches[nonce][value] = 1
18 else
19 netsync_branches[nonce][value] = netsync_branches[nonce][value] + 1
20 end
21 end
22end
23
24function note_netsync_revision_received(new_id,revision,certs,nonce)
25 for _, item in pairs(certs)
26 do
27 _note_netsync_cert_received(new_id,item.key,item.name,item.value,nonce)
28 end
29end
30
31function note_netsync_cert_received(rev_id,key,name,value,nonce)
32 _note_netsync_cert_received(rev_id,key,name,value,nonce)
33end
34
35function note_netsync_end(nonce)
36 local first = true
37 for item, amount in pairs(netsync_branches[nonce])
38 do
39 if first then
40 io.stderr:write("Affected branches:\n")
41 first = false
42 end
43 io.stderr:write(" ",item," (",amount,")\n")
44 end
45 netsync_branches[nonce] = nil
46end

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status