# # # patch "automate.cc" # from [060a251cef12fc73aafe107f77110972ea686a9e] # to [a3c5247f4b232a312e2ffe3b58acf1a47b9137d5] # # patch "cmd_list.cc" # from [783991aedffea80666c33fe6e3fff2ff251a87d9] # to [9adabc8d0d37c8abe373e1d9d8bb7a992b9f8487] # # patch "lua_hooks.cc" # from [1d95c581d5880c74fd9c941fd69e2564d624d2e2] # to [1e2ebbd1287df55bebb113fe5b9f493786bf3632] # # patch "lua_hooks.hh" # from [0968f4973ed14ccd60fb411de351f30008f7da7e] # to [774874ea8627c7da818aaed6854b3625ebfc6230] # # patch "project.cc" # from [e36cabaeb25304c08435a3a8aa1ab9c22ed820a7] # to [c6cf0aa9374a6dd8979f2c804049d8a341215865] # # patch "std_hooks.lua" # from [476117cb5843a576bc2cfb7f989eba32fd0524c4] # to [7ee6b496c559913b44682a64863fb958b93ad5d4] # ============================================================ --- automate.cc 060a251cef12fc73aafe107f77110972ea686a9e +++ automate.cc a3c5247f4b232a312e2ffe3b58acf1a47b9137d5 @@ -1248,7 +1248,7 @@ CMD_AUTOMATE(branches, "", for (set::const_iterator i = names.begin(); i != names.end(); ++i) { - if (!app.lua.hook_ignore_branch(*i)) + if (!app.lua.hook_ignore_branch(app, *i)) output << (*i) << '\n'; } } @@ -1322,7 +1322,7 @@ CMD_AUTOMATE(tags, N_("[BRANCH_PATTERN]" for (set::const_iterator branch = branches.begin(); branch != branches.end(); ++branch) { - if (app.lua.hook_ignore_branch(*branch)) + if (app.lua.hook_ignore_branch(app, *branch)) continue; if (!show && match((*branch)())) ============================================================ --- cmd_list.cc 783991aedffea80666c33fe6e3fff2ff251a87d9 +++ cmd_list.cc 9adabc8d0d37c8abe373e1d9d8bb7a992b9f8487 @@ -266,7 +266,7 @@ CMD(branches, "branches", "", CMD_REF(li for (set::const_iterator i = names.begin(); i != names.end(); ++i) { - if (match((*i)()) && !app.lua.hook_ignore_branch(*i)) + if (match((*i)()) && !app.lua.hook_ignore_branch(app, *i)) { cout << *i << '\n'; } ============================================================ --- lua_hooks.cc 1d95c581d5880c74fd9c941fd69e2564d624d2e2 +++ lua_hooks.cc 1e2ebbd1287df55bebb113fe5b9f493786bf3632 @@ -16,6 +16,7 @@ #include #include #include +#include #include "lua.hh" @@ -304,10 +305,33 @@ lua_hooks::hook_ignore_file(file_path co return exec_ok && ignore_it; } +LUAEXT(get_branch_heads, ) +{ + app_state *app_p = map_of_lua_to_app[L]; + I(app_p); + const char *branch = luaL_checkstring(L, -1); + std::set heads; + + app_p->get_project().get_branch_heads(branch_name(branch), heads); + + lua_pushnumber(L, heads.size()); + + std::ostringstream o; + + for (std::set::const_iterator it = heads.begin(); it != heads.end(); ++it) + o << *it << " "; + + lua_pushstring(L, o.str().c_str()); + + return 2; +} + bool -lua_hooks::hook_ignore_branch(branch_name const & branch) +lua_hooks::hook_ignore_branch(app_state & app, branch_name const & branch) { bool ignore_it = false; + app.db.ensure_open(); + I(map_of_lua_to_app[st] == &app); bool exec_ok = Lua(st) .func("ignore_branch") .push_str(branch()) ============================================================ --- lua_hooks.hh 0968f4973ed14ccd60fb411de351f30008f7da7e +++ lua_hooks.hh 774874ea8627c7da818aaed6854b3625ebfc6230 @@ -85,7 +85,7 @@ public: // local repo hooks bool hook_ignore_file(file_path const & p); - bool hook_ignore_branch(branch_name const & branch); + bool hook_ignore_branch(app_state & app, branch_name const & branch); bool hook_merge3(file_path const & anc_path, file_path const & left_path, file_path const & right_path, ============================================================ --- project.cc e36cabaeb25304c08435a3a8aa1ab9c22ed820a7 +++ project.cc c6cf0aa9374a6dd8979f2c804049d8a341215865 @@ -28,16 +28,7 @@ project_t::get_branch_list(std::set::iterator i = got.begin(); i != got.end(); ++i) - { - // check that the branch has at least one non-suspended head - const branch_name branch(*i); - std::set heads; - - get_branch_heads(branch, heads); - - if (!heads.empty()) - branches.insert(branch); - } + branches.insert(branch_name(*i)); } names = branches; @@ -52,16 +43,7 @@ project_t::get_branch_list(globish const names.clear(); for (std::vector::iterator i = got.begin(); i != got.end(); ++i) - { - // check that the branch has at least one non-suspended head - const branch_name branch(*i); - std::set heads; - - get_branch_heads(branch, heads); - - if (!heads.empty()) - names.insert(branch); - } + names.insert(branch_name(*i)); } namespace ============================================================ --- std_hooks.lua 476117cb5843a576bc2cfb7f989eba32fd0524c4 +++ std_hooks.lua 7ee6b496c559913b44682a64863fb958b93ad5d4 @@ -93,6 +93,11 @@ end return false end +function ignore_branch(name) + headCount = get_branch_heads(name) + return (headCount == 0) +end + function ignore_file(name) -- project specific if (ignored_files == nil) then