Jelajahi Sumber

upgrade my RSE patchset to provide the 'mtn base' command for convenient sub-branch management

Ralf S. Engelschall 18 tahun lalu
induk
melakukan
20fdfca2f7
2 mengubah file dengan 68 tambahan dan 8 penghapusan
  1. 67 7
      monotone/monotone.patch.rse
  2. 1 1
      monotone/monotone.spec

+ 67 - 7
monotone/monotone.patch.rse

@@ -531,7 +531,7 @@ Index: roster_merge.cc
 ===================================================================
 Index: std_hooks.lua
 --- std_hooks.lua	a53348ca15431cc67266c65e6215640f6f55eee7
-+++ std_hooks.lua	a22ecb0c807ba34a9c4a564fb0d86ce246e9e1c9
++++ std_hooks.lua	2bf9ca9c0181225388eba671beb3d6ca05fe8089
 @@ -284,6 +284,15 @@ function edit_comment(basetext, user_log
     if user_log_message == "" or string.sub(user_log_message, -1) ~= "\n" then
        tmp:write("\n")
@@ -548,10 +548,11 @@ Index: std_hooks.lua
     tmp:write(basetext)
     io.close(tmp)
  
-@@ -1112,6 +1121,93 @@ end
-     return "socat"
+@@ -1175,3 +1184,153 @@ end
+    netsync_notifiers[precedence] = notifier
+    return true, warning
  end
- 
++
 +--  #if defined(RSE) /* extra-command */
 +
 +--  extra command: "mtn fuse REVISION"
@@ -637,11 +638,70 @@ Index: std_hooks.lua
 +    end
 +end
 +
++--  extra command: "mtn base {upgrade|diff}"
++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 " ..
++    "in the \".mtn-base\" file in the workspace 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 and base base
++    local rc, branch_this = mtn_automate("get_option", "branch")
++    if branch_this ~= nil then
++        branch_this = string.match(branch_this, "^%s*(%S+)%s*$")
++    end
++    if branch_this == nil then
++        io.stderr:write("mtn: base: ERROR: failed to determine current branch\n")
++        return
++    end
++    local branch_base = read_contents_of_file(".mtn-base", "r")
++    if branch_base ~= nil then
++        branch_base = string.match(branch_base, "^%s*(%S+)%s*$")
++    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: revision: ERROR: failed to execute \"mtn propagate\"\n")
++            return
++        end
++        rc = execute("mtn", "update")
++        if rc ~= 0 then
++            io.stderr:write("mtn: revision: 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: revision: ERROR: failed to execute \"mtn diff\"\n")
++            return
++        end
++    end
++    return
++end
++
 +--  #endif
 +
- -- Netsync notifiers are tables containing 5 functions:
- -- start, revision_received, cert_received, pubkey_received and end
- -- Those functions take exactly the same arguments as the corresponding
 ===================================================================
 Index: work.cc
 --- work.cc	04389e4274f38d0b2bc866c6938d53bbda5e8a2f

+ 1 - 1
monotone/monotone.spec

@@ -33,7 +33,7 @@ Class:        EVAL
 Group:        SCM
 License:      GPL
 Version:      0.37
-Release:      20071026
+Release:      20071029
 
 #   package options
 %option       with_rse  yes