# # patch "ChangeLog" # from [479f8d96506852ef9a05ed25bae57211b82bd929] # to [7342978080856e97c0d449e6b04a3698b71a665b] # # patch "Makefile.am" # from [bedd826d1991853466ab57d77d80be1635014d17] # to [308ee398868765c988fb19e3abaff29b6a9c579d] # # patch "monotone.texi" # from [6403bd5e94050c2dad166cd94378e4a067415874] # to [cde5b927d4a6fd8a91c6a190880db005308cde9d] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,8 @@ +2005-06-18 Riccardo Ghetta + * monotone.texi: include std_hooks.lua as an appendix and remove long + lua excerpts from hook reference. + * Makefile.am : make monotone.pdf/eps depend on monotone.info + 2005-06-17 Matt Johnston * database.cc (database::execute()): truncate long query log messages --- Makefile.am +++ Makefile.am @@ -297,9 +297,9 @@ MAKEINFOFLAGS=-I $(top_builddir) -monotone.pdf: monotone.texi version.texi $(PDF_FIGURES) +monotone.pdf: monotone.info version.texi std_hooks.lua $(PDF_FIGURES) -monotone.dvi: monotone.texi version.texi $(EPS_FIGURES) +monotone.dvi: monotone.info version.texi std_hooks.lua $(EPS_FIGURES) #%.eps: %.epsi # mv $< $@ --- monotone.texi +++ monotone.texi @@ -77,6 +77,7 @@ * Hook Reference:: Functions which extend monotone * Special Topics:: Extra explanations and details * Man Page:: That other document +* Default monotonerc:: The default monotonerc file * Index:: Index of concepts and functions @end menu @@ -5280,10 +5281,15 @@ using the @address@hidden option; hooks defined in files specified on the command-line will shadow hooks from the the automatic files. +By specifying @address@hidden you can automatically +load all the files contained into @var{directory}. -Monotone also exports to hooks a number of helper functions exposing -functionality not available with standard lua. +Monotone also makes available to hook writers a number of helper +functions exposing functionality not available with standard lua. +For the complete source of the default hooks see @ref{Default +monotonerc}. + @menu * Hooks:: All hooks called by monotone. * Additional Lua Functions:: Extra functionality availabe to hook writers. @@ -5392,46 +5398,8 @@ a successful commit, the contents of @file{MT/log} are erased setting the system up for another edit/commit cycle. -The default definition of this hook is: +For the default definition of this hook, see @ref{Default monotonerc}. address@hidden address@hidden -function edit_comment(commentary, user_log_message) - local exe = "vi" - local visual = os.getenv("VISUAL") - if (visual ~= nil) then exe = visual end - local editor = os.getenv("EDITOR") - if (editor ~= nil) then exe = editor end - - local tmp, tname = temp_file() - if (tmp == nil) then return nil end - commentary = "MT: " .. string.gsub(commentary, "\n", "\nMT: ") - tmp:write(user_log_message) - tmp:write(commentary) - io.close(tmp) - - if (os.execute(string.format("%s %s", exe, tname)) ~= 0) then - os.remove(tname) - return nil - end - - tmp = io.open(tname, "r") - if (tmp == nil) then os.remove(tname); return nil end - local res = "" - local line = tmp:read() - while(line ~= nil) do - if (not string.find(line, "^MT:")) then - res = res .. line .. "\n" - end - line = tmp:read() - end - io.close(tmp) - os.remove(tname) - return res -end address@hidden group address@hidden smallexample - @item persist_phrase_ok () Returns @code{true} if you want monotone to remember the passphrase of @@ -5532,34 +5500,9 @@ Returns @code{true} if @var{filename} should be ignored while adding, dropping, or moving files. Otherwise returns @code{false}. This is most important when performing recursive actions on directories, which -may affect multiple files simultaneously. The default definition of -this hook is: +may affect multiple files simultaneously. +For the default definition of this hook, see @ref{Default monotonerc}. address@hidden address@hidden -function ignore_file(name) - if (string.find(name, "%.a$")) then return true end - if (string.find(name, "%.so$")) then return true end - if (string.find(name, "%.o$")) then return true end - if (string.find(name, "%.la$")) then return true end - if (string.find(name, "%.lo$")) then return true end - if (string.find(name, "%.aux$")) then return true end - if (string.find(name, "%.bak$")) then return true end - if (string.find(name, "%.orig$")) then return true end - if (string.find(name, "%.rej$")) then return true end - if (string.find(name, "%~$")) then return true end - if (string.find(name, "/core$")) then return true end - if (string.find(name, "^CVS/")) then return true end - if (string.find(name, "/CVS/")) then return true end - if (string.find(name, "^%.svn/")) then return true end - if (string.find(name, "/%.svn/")) then return true end - if (string.find(name, "^SCCS/")) then return true end - if (string.find(name, "/SCCS/")) then return true end - return false; -end address@hidden group address@hidden smallexample - @item ignore_branch (@var{branchname}) Returns @code{true} if @var{branchname} should be ignored while listing @@ -5658,61 +5601,10 @@ strings, which are the contents of the @var{left} and @var{right} nodes of a file fork which monotone was unable to automatically merge. The merge should either call an intelligent merge program or -interact with the user. The default definition of this hook is: +interact with the user. +For the default definition of this hook, see @ref{Default monotonerc}. address@hidden address@hidden -function merge2 (left_path, right_path, merged_path, left, right) - local ret = nil - local tbl = @address@hidden - - tbl.lfile = nil - tbl.rfile = nil - tbl.outfile = nil - tbl.meld_exists = false - - tbl.lfile = write_to_temporary_file (left) - tbl.rfile = write_to_temporary_file (right) - tbl.outfile = write_to_temporary_file ("") - - if tbl.lfile ~= nil and tbl.rfile ~= nil and tbl.outfile ~= nil - then - tbl.left_path = left_path - tbl.right_path = right_path - tbl.merged_path = merged_path - - local cmd = get_preferred_merge2_command (tbl) - - if cmd ~=nil - then - io.write ( - string.format("executing external 2-way merge command\n")) - cmd () - if tbl.meld_exists - then - ret = read_contents_of_file (tbl.lfile) - else - ret = read_contents_of_file (tbl.outfile) - end - if string.len (ret) == 0 - then - ret = nil - end - else - io.write ("no external 2-way merge command found\n") - end - end - - os.remove (tbl.lfile) - os.remove (tbl.rfile) - os.remove (tbl.outfile) - - return ret -end address@hidden group address@hidden smallexample - @anchor{get_preferred_merge2_command} @item get_preferred_merge2_command(@var{tbl}) @@ -5722,58 +5614,7 @@ that you would like to use to perform merge2 operations, override this hook to specify it. address@hidden address@hidden -function get_preferred_merge2_command (tbl) - local cmd = nil - local left_path = tbl.left_path - local right_path = tbl.right_path - local merged_path = tbl.merged_path - local lfile = tbl.lfile - local rfile = tbl.rfile - local outfile = tbl.outfile - - local editor = string.lower(os.getenv("EDITOR")) - - - if program_exists_in_path("kdiff3") then - cmd = merge2_kdiff3_cmd (left_path, right_path, merged_path, - lfile, rfile, outfile) - elseif program_exists_in_path ("meld") then - tbl.meld_exists = true - io.write (string.format( - "\nWARNING: 'meld' was choosen to perform external 2-way merge.\n".. - "You should merge all changes to *LEFT* file due to limitation of program\n".. - "arguments.\n\n")) - cmd = merge2_meld_cmd (lfile, rfile) - elseif program_exists_in_path ("xxdiff") then - cmd = merge2_xxdiff_cmd (left_path, right_path, merged_path, - lfile, rfile, outfile) - else - if string.find(editor, "emacs") ~= nil - or string.find(editor, "gnu") ~= nil - then - if program_exists_in_path ("emacs") then - cmd = merge2_emacs_cmd ("emacs", lfile, rfile, outfile) - elseif program_exists_in_path ("xemacs") then - cmd = merge2_emacs_cmd ("xemacs", lfile, rfile, outfile) - end - else if string.find(editor, "vim") ~= nil then - if os.getenv ("DISPLAY") ~= nil - and program_exists_in_path ("gvim") - then - cmd = merge2_vim_cmd ("gvim", lfile, rfile, outfile) - elseif program_exists_in_path ("vim") then - cmd = merge2_vim_cmd ("vim", lfile, rfile, outfile) - end - end - end - return cmd -end address@hidden group address@hidden smallexample - @anchor{merge3} @item merge3 (@var{ancestor}, @var{left}, @var{right}) @@ -5781,65 +5622,10 @@ strings, which are the contents of @var{left} and @var{right} nodes, and least common @var{ancestor}, of a file fork which monotone was unable to automatically merge. This hook delegates the actual merge -to the result of @ref{get_preferred_merge3_command}. The default -definition of this hook is: +to the result of @ref{get_preferred_merge3_command}. +For the default definition of this hook, see @ref{Default monotonerc}. address@hidden address@hidden -function merge3 (anc_path, left_path, right_path, merged_path, - ancestor, left, right) - local ret - local tbl = @address@hidden - - tbl.anc_path = anc_path - tbl.left_path = left_path - tbl.right_path = right_path - tbl.merged_path = merged_path - tbl.afile = nil - tbl.lfile = nil - tbl.rfile = nil - tbl.outfile = nil - tbl.meld_exists = false - tbl.lfile = write_to_temporary_file (left) - tbl.afile = write_to_temporary_file (ancestor) - tbl.rfile = write_to_temporary_file (right) - tbl.outfile = write_to_temporary_file ("") - - if tbl.lfile ~= nil and tbl.rfile ~= nil - and tbl.afile ~= nil and tbl.outfile ~= nil - then - local cmd = get_preferred_merge3_command (tbl) - if cmd ~=nil - then - io.write (string.format( - "executing external 3-way merge command\n")) - cmd () - if tbl.meld_exists - then - ret = read_contents_of_file (tbl.afile) - else - ret = read_contents_of_file (tbl.outfile) - end - if string.len (ret) == 0 - then - ret = nil - end - else - io.write ("no external 3-way merge command found\n") - end - end - - os.remove (tbl.lfile) - os.remove (tbl.rfile) - os.remove (tbl.afile) - os.remove (tbl.outfile) - - return ret -end address@hidden group address@hidden smallexample - @anchor{get_preferred_merge3_command} @item get_preferred_merge3_command(@var{tbl}) @@ -5849,65 +5635,6 @@ that you would like to use to perform merge3 operations, override this hook to specify it. address@hidden address@hidden -function get_preferred_merge3_command (tbl) - local cmd = nil - local left_path = tbl.left_path - local anc_path = tbl.anc_path - local right_path = tbl.right_path - local merged_path = tbl.merged_path - local lfile = tbl.lfile - local afile = tbl.afile - local rfile = tbl.rfile - local outfile = tbl.outfile - - local editor = string.lower(os.getenv("EDITOR")) - - if program_exists_in_path("kdiff3") then - cmd = merge3_kdiff3_cmd (left_path, anc_path, right_path, - merged_path, lfile, afile, rfile, outfile) - elseif program_exists_in_path ("meld") then - tbl.meld_exists = true - io.write (string.format( - "\nWARNING: 'meld' was choosen to perform external 3-way merge.\n".. - "You should merge all changes to *CENTER* file due to limitation of program\n".. - "arguments.\n\n")) - cmd = merge3_meld_cmd (lfile, afile, rfile) - elseif program_exists_in_path ("xxdiff") then - cmd = merge3_xxdiff_cmd (left_path, anc_path, right_path, - merged_path, lfile, afile, rfile, outfile) - else - -- prefer emacs/xemacs - if string.find(editor, "emacs") ~= nil - or string.find(editor, "gnu") ~= nil - then - if program_exists_in_path ("xemacs") then - cmd = merge3_emacs_cmd ("xemacs", lfile, afile, - rfile, outfile) - elseif program_exists_in_path ("emacs") then - cmd = merge3_emacs_cmd ("emacs", lfile, afile, - rfile, outfile) - end - elseif string.find(editor, "vim") ~= nil then -- prefer vim - if os.getenv ("DISPLAY") ~= nil - and program_exists_in_path ("gvim") - then - cmd = merge3_vim_cmd ("gvim", lfile, afile, - rfile, outfile) - elseif program_exists_in_path ("vim") then - cmd = merge3_vim_cmd ("vim", lfile, afile, - rfile, outfile) - end - end - end - - return cmd -end address@hidden group address@hidden smallexample - - @item expand_selector (@var{str}) Attempts to expand @var{str} as a selector. Expansion generally means @@ -5915,115 +5642,18 @@ authors or @code{d:} for dates. Expansion may also mean recognizing and interpreting special words such as @code{yesterday} or @code{6 months ago} and converting them into well formed selectors. For more -detail on the use of selectors, see @ref{Selectors}. The default -definition of this hook is: +detail on the use of selectors, see @ref{Selectors}. +For the default definition of this hook, see @ref{Default monotonerc}. address@hidden address@hidden -function expand_selector(str) - - -- something which looks like a generic cert pattern - if string.find(str, "^[^=]*=.*$") - then - return ("c:" .. str) - end - - -- something which looks like an email address - if string.find(str, "[%w%-_]+@@[%w%-_]+") - then - return ("a:" .. str) - end - - -- something which looks like a branch name - if string.find(str, "[%w%-]+%.[%w%-]+") - then - return ("b:" .. str) - end - - -- a sequence of nothing but hex digits - if string.find(str, "^%x+$") - then - return ("i:" .. str) - end - - -- tries to expand as a date - local dtstr = expand_date(str) - if dtstr ~= nil - then - return ("d:" .. dtstr) - end - - return nil -end address@hidden group address@hidden smallexample - @item expand_date (@var{str}) Attempts to expand @var{str} as a date expression. Expansion means recognizing and interpreting special words such as @code{yesterday} or @code{6 months ago} and converting them into well formed date expressions. For more -detail on the use of selectors, see @ref{Selectors}. The default -definition of this hook is: +detail on the use of selectors, see @ref{Selectors}. +For the default definition of this hook, see @ref{Default monotonerc}. address@hidden address@hidden -function expand_date(str) - -- simple date patterns - if string.find(str, "^19%d%d%-%d%d") - or string.find(str, "^20%d%d%-%d%d") - then - return (str) - end - -- "now" - if str == "now" - then - local t = os.time(os.date('!*t')) - return os.date("%FT%T", t) - end - - -- today don't uses the time - if str == "today" - then - local t = os.time(os.date('!*t')) - return os.date("%F", t) - end - - -- "yesterday", the source of all hangovers - if str == "yesterday" - then - local t = os.time(os.date('!*t')) - return os.date("%F", t - 86400) - end - - -- "CVS style" relative dates such as "3 weeks ago" - local trans = @{ - minute = 60; - hour = 3600; - day = 86400; - week = 604800; - month = 2678400; - year = 31536000 - @} - local pos, len, n, type = string.find(str, "(%d+) ([minutehordaywk]+)s? ago") - if trans[type] ~= nil - then - local t = os.time(os.date('!*t')) - if trans[type] <= 3600 - then - return os.date("%FT%T", t - (n * trans[type])) - else - return os.date("%F", t - (n * trans[type])) - end - end - - return nil -end address@hidden group address@hidden smallexample - - @item get_system_linesep () Returns a string which defines the default system line separator. @@ -6145,39 +5775,9 @@ @end group @end smallexample -The @code{binary_file} function is also defined as a lua hook as -follows: - address@hidden address@hidden -function binary_file(name) - local lowname=string.lower(name) - -- some known binaries, return true - if (string.find(lowname, "%.gif$")) then return true end - if (string.find(lowname, "%.jpe?g$")) then return true end - if (string.find(lowname, "%.png$")) then return true end - if (string.find(lowname, "%.bz2$")) then return true end - if (string.find(lowname, "%.gz$")) then return true end - if (string.find(lowname, "%.zip$")) then return true end - -- some known text, return false - if (string.find(lowname, "%.cc?$")) then return false end - if (string.find(lowname, "%.cxx$")) then return false end - if (string.find(lowname, "%.hh?$")) then return false end - if (string.find(lowname, "%.hxx$")) then return false end - if (string.find(lowname, "%.lua$")) then return false end - if (string.find(lowname, "%.texi$")) then return false end - if (string.find(lowname, "%.sql$")) then return false end - -- unknown - read file and use the guess-binary built-in - -- monotone function - filedata=read_contents_of_file(name) - if (filedata ~= nil) then return guess_binary(filedata) end - -- if still unknown, treat as binary - return true -end address@hidden group address@hidden smallexample +The @code{binary_file} function is also defined as a lua hook. See address@hidden monotonerc}. - @end ftable @page @@ -6264,6 +5864,7 @@ function, unless you need to run monotone with the @option{--nostd} option. @code{temp_file()} builds on @code{mkstemp()} and creates a file in the standard TMP/TEMP directories. +For the definition of @code{temp_file()}, see @ref{Default monotonerc}. @item sleep(@var{seconds}) @@ -7364,6 +6965,14 @@ graydon hoare address@hidden Default monotonerc address@hidden Default monotonerc + +This section contains the entire source code of the default monotonerc +hook file, i.e. the hooks active if no other monotonerc is loaded. + address@hidden std_hooks.lua + @node Index @unnumbered Index