# # # add_dir "contrib/command" # # add_file "contrib/command/README" # content [052f8380176ee4d89a6963129f574ae27dc95cfb] # # add_file "contrib/command/base.lua" # content [85a4ee27e8b7165ba31f4ac50e12102bf82cae80] # # add_file "contrib/command/conflicts.lua" # content [c6ab694de839b398bd050cf39f99b911f17d6c2a] # # add_file "contrib/command/fuse.lua" # content [e64d2d33e7578029a3a4030206b283eb71f51cac] # # add_file "contrib/command/revision.lua" # content [c8e3e268d1823f73229a5865530e474cef118ea4] # # patch "NEWS" # from [522e1c484e1f930dcd570b98c84cbc8052a0b593] # to [3982818d2ee76437a20bd4fe361ac31b3b993e8c] # ============================================================ --- contrib/command/README 052f8380176ee4d89a6963129f574ae27dc95cfb +++ contrib/command/README 052f8380176ee4d89a6963129f574ae27dc95cfb @@ -0,0 +1,4 @@ + +These are Lua scripts which implement additional Monotone commands. +A script in file .lua usually implements "mtn [...]". + ============================================================ --- contrib/command/base.lua 85a4ee27e8b7165ba31f4ac50e12102bf82cae80 +++ contrib/command/base.lua 85a4ee27e8b7165ba31f4ac50e12102bf82cae80 @@ -0,0 +1,85 @@ +-- +-- base.lua -- Monotone Lua extension command "mtn base" +-- Copyright (C) 2007 Ralf S. Engelschall +-- +-- This program is made available under the GNU GPL version 2.0 or +-- greater. See the accompanying file COPYING for details. +-- +-- This program is distributed WITHOUT ANY WARRANTY; without even the +-- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +-- PURPOSE. +-- + +register_command( + "base", "upgrade|diff", + "Upgrades or compares current branch against base branch", + "Upgrade current branch from base branch or compares current " .. + "branch against base branch. The base branch has to be stored " .. + "either in the \"mtn:base\" attribute of the root directory " .. + "or in a \".mtn-base\" file in the root directory.", + "command_base" +) + +function command_base(op) + -- sanity check command line + if op == nil then + io.stderr:write("mtn: base: ERROR: no operation specified\n") + return + end + if op ~= "upgrade" and op ~= "diff" then + io.stderr:write("mtn: base: ERROR: either \"upgrade\" or \"diff\" operation has to be specified\n") + return + end + + -- determine current branch of workspace + local branch_this = nil + local rc, txt = mtn_automate("get_option", "branch") + if txt ~= nil then + branch_this = string.match(txt, "^%s*(%S+)%s*$") + end + if branch_this == nil then + io.stderr:write("mtn: base: ERROR: failed to determine current branch\n") + return + end + + -- determine base branch of workspace + local branch_base = nil + local rc, txt = mtn_automate("get_attributes", ".") + if txt ~= nil then + branch_base = string.match(txt, "attr%s+\"mtn:base\"%s+\"([^\"]+)\"") + end + if branch_base == nil then + local txt = read_contents_of_file(".mtn-base", "r") + if txt ~= nil then + branch_base = string.match(txt, "^%s*(%S+)%s*$") + end + end + if branch_base == nil then + io.stderr:write("mtn: base: ERROR: failed to determine base branch\n") + return + end + + -- dispatch according to operation + if op == "upgrade" then + -- upgrade current branch by merging in revisions of base branch + local rc = execute("mtn", "propagate", branch_base, branch_this) + if rc ~= 0 then + io.stderr:write("mtn: base: ERROR: failed to execute \"mtn propagate\"\n") + return + end + rc = execute("mtn", "update") + if rc ~= 0 then + io.stderr:write("mtn: base: ERROR: failed to execute \"mtn update\"\n") + return + end + elseif op == "diff" then + -- upgrade current branch by merging in revisions of base branch + local rc = execute("mtn", "diff", "-r", "h:" .. branch_base, "-r", "h:" .. branch_this) + if rc ~= 0 then + io.stderr:write("mtn: base: ERROR: failed to execute \"mtn diff\"\n") + return + end + end + return +end + ============================================================ --- contrib/command/conflicts.lua c6ab694de839b398bd050cf39f99b911f17d6c2a +++ contrib/command/conflicts.lua c6ab694de839b398bd050cf39f99b911f17d6c2a @@ -0,0 +1,41 @@ +-- +-- conflicts.lua -- Monotone Lua extension command "mtn conflicts" +-- Copyright (C) 2007 Ralf S. Engelschall +-- +-- This program is made available under the GNU GPL version 2.0 or +-- greater. See the accompanying file COPYING for details. +-- +-- This program is distributed WITHOUT ANY WARRANTY; without even the +-- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +-- PURPOSE. +-- + +register_command( + "conflicts", "", + "Lists files in workspace containing conflict markers.", + "Lists all files in the current workspace containing the " .. + "conflict markers produced by GNU diffutils' \"diff3\" " .. + "command. This indicates still unresolved merge conflicts.", + "command_conflicts" +) + +function command_conflicts() + -- sanity check run-time environment + if program_exists_in_path("egrep") == 0 then + io.stderr:write("mtn: conflicts: ERROR: require GNU grep command \"egrep\" in PATH\n") + return + end + + -- make sure we have a valid workspace + mtn_automate("get_option", "branch") + + -- perform check operation via GNU grep's egrep(1) + local rc = execute( + "egrep", + "--files-with-matches", + "--recursive", + "^(<<<<<<<|=======|>>>>>>>) ", + "." + ) +end + ============================================================ --- contrib/command/fuse.lua e64d2d33e7578029a3a4030206b283eb71f51cac +++ contrib/command/fuse.lua e64d2d33e7578029a3a4030206b283eb71f51cac @@ -0,0 +1,50 @@ +-- +-- fuse.lua -- Monotone Lua extension command "mtn fuse" +-- Copyright (C) 2007 Ralf S. Engelschall +-- +-- This program is made available under the GNU GPL version 2.0 or +-- greater. See the accompanying file COPYING for details. +-- +-- This program is distributed WITHOUT ANY WARRANTY; without even the +-- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +-- PURPOSE. +-- + +register_command( + "fuse", "REVISION", + "Fuse revision into workspace with conflict markers.", + "Fuse the specified revision into the current workspace by merging " .. + "the revision into the workspace while providing inline conflict " .. + "markers for manually resolving the conflicts in the workspace " .. + "before comitting the conflicts-resolved workspace as the new " .. + "merged revision.", + "command_fuse" +) + +function command_fuse(revision) + -- argument sanity checking + if revision == nil then + io.stderr:write("mtn: fuse: ERROR: revision not given\n") + return + end + + -- run-time sanity checking + if program_exists_in_path("mtn") == 0 then + io.stderr:write("mtn: fuse: ERROR: require Monotone command \"mtn\" in PATH\n") + return + end + + -- make sure we have a valid workspace + mtn_automate("get_option", "branch") + + -- perform the revision "fusion" operation + local cmd = + "MTN_MERGE=diffutils " .. + "MTN_MERGE_DIFFUTILS=\"partial,diff3opts=-E\" " .. + "mtn " .. "merge_into_workspace " .. revision + local rc = execute("sh", "-c", cmd) + if rc ~= 0 then + io.stderr:write("mtn: fuse: ERROR: failed to execute command \"" .. cmd .. "\"\n") + end +end + ============================================================ --- contrib/command/revision.lua c8e3e268d1823f73229a5865530e474cef118ea4 +++ contrib/command/revision.lua c8e3e268d1823f73229a5865530e474cef118ea4 @@ -0,0 +1,46 @@ +-- +-- revision.lua -- Monotone Lua extension command "mtn revision" +-- Copyright (C) 2007 Ralf S. Engelschall +-- +-- This program is made available under the GNU GPL version 2.0 or +-- greater. See the accompanying file COPYING for details. +-- +-- This program is distributed WITHOUT ANY WARRANTY; without even the +-- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +-- PURPOSE. +-- + +register_command( + "revision", "REVISION [ANCESTOR-REVISION]", + "Shows summary information about revision(s)", + "Shows summary information about a particular revision " .. + "(or a range of revisions in case an ancestor revision is also specified). " .. + "This is just a convenience wrapper command around \"mtn log --diffs\".", + "command_revision" +) + +alias_command( + "revision", + "rev" +) + +function command_revision(revision, ancestor) + -- argument sanity checking + if revision == nil then + io.stderr:write("mtn: revision: ERROR: no revision specified\n") + return + end + if ancestor == nil then + ancestor = revision + end + + -- make sure we have a valid workspace + mtn_automate("get_option", "branch") + + -- perform the operation + execute("mtn", "log", "--diffs", "--no-graph", "--from", ancestor, "--to", revision) + if rc ~= 0 then + io.stderr:write("mtn: revision: ERROR: failed to execute\n") + end +end + ============================================================ --- NEWS 522e1c484e1f930dcd570b98c84cbc8052a0b593 +++ NEWS 3982818d2ee76437a20bd4fe361ac31b3b993e8c @@ -1,7 +1,13 @@ [ somewhen in the future ] 0.38 release. + Changes + + - Added the scripts of the following Lua-based contributed + Monotone extension commands to contrib/command/: + "mtn base", "mtn fuse", "mtn revision", "mtn conflicts". + Internal - Update Botan to 1.7.2.