# # # add_file "contrib/display_branches.lua" # content [f3f80b5d575e8709b7d9e6d9503b7e48c1d2b12c] # ============================================================ --- contrib/display_branches.lua f3f80b5d575e8709b7d9e6d9503b7e48c1d2b12c +++ contrib/display_branches.lua f3f80b5d575e8709b7d9e6d9503b7e48c1d2b12c @@ -0,0 +1,36 @@ +-- Lua snippet to display what branches were affected by revisions and certs +-- that came into the database. I integrate it into my ~/.monotone/monotonerc +-- /Richard Levitte +-- +-- Released as public domain + +netsync_branches = {} +function note_netsync_start(nonce) + netsync_branches[nonce] = {} +end + +function note_netsync_revision_received(new_id,revision,certs,nonce) + for _, item in pairs(certs) + do + note_netsync_cert_received(new_id,item.key,item.name,item.value,nonce) + end +end + +function note_netsync_cert_received(rev_id,key,name,value,nonce) + if name == "branch" then + netsync_branches[nonce][value] = 1 + end +end + +function note_netsync_end(nonce) + local first = true + for item, _ in pairs(netsync_branches[nonce]) + do + if first then + io.stderr:write("Affected branches:\n") + first = false + end + io.stderr:write(" "..item.."\n") + end + netsync_branches[nonce] = nil +end