monotone

monotone Mtn Source Tree

Root/contrib/extra-commands.lua

1-- WARNING: this feature is not available in the mainline yet
2-- you can find it in net.venge.monotone.ws_automate
3
4-- include this in your monotonerc file to gain the extra commands.
5
6-- Not all of the automate commands used by this lua code are committed
7-- to trunk at present. As such this should currently be treated as
8-- sample code, not working commands.
9
10if alias_command == nil then
11 -- If we're using an older version of monotone that cannot handle lua commands
12 -- then turn make sure we don't error.
13 function alias_command(...) print("Warning: alias_command() not available in this version of Monotone.") end
14end
15
16if mtn_automate == nil or register_command == nil then
17 function register_command(...) print("Warning: register_command() not available in this version of Monotone.") end
18end
19
20alias_command("annotate", "blame")
21alias_command("annotate", "praise")
22
23function net_update(...)
24 result, output = mtn_automate("get_option", "branch")-- make sure we have a valid workspace
25 if not result then
26 print("Error from mtn automate call to get_option: ", ouput)
27 print("Do you have a vaild workspace?")
28 return
29 end
30 result, output = mtn_automate("pull")
31 if not result then
32 print("Error from mtn automate call to pull: ", output)
33 return
34 end
35 result, output = mtn_automate("update")
36 if not result then
37 print("Error from mtn automate call to update: ", output)
38 return
39 end
40 -- print(output)
41end
42
43register_command("net_update", "", "Pull and update a workspace",
44 "This command approximates the update command of a centralised revision control system. " ..
45 "It first contacts the server to gather new revisions and then it updates the workspace.", "net_update")
46
47alias_command("net_update", "nup")
48
49function net_commit(...)
50 result, output = mtn_automate("get_option", "branch")-- make sure we have a valid workspace
51 if not result then
52 print("Error from mtn automate call to get_option: ", output)
53 print("Do you have a vaild workspace?")
54 return
55 end
56 result, output = mtn_automate("commit")
57 if not result then
58 print("Error from mtn automate call to commit: ", output)
59 return
60 end
61 print(output)
62 result, output = mtn_automate("pull")
63 if not result then
64 print("Error from mtn automate call to pull: ", output)
65 return
66 end
67 result, heads = mtn_automate("heads")
68 if not result then
69 print("Error from mtn automate call to heads: ", output)
70 return
71 end
72 words = 0
73 for word in string.gfind(heads, "[^%s]+") do words=words+1 end
74 if words == 1 then
75 result, output = mtn_automate("push")
76 if not result then
77 print("Error from mtn automate call to push: ", output)
78 return
79 end
80 else
81 print("There are multiple heads in your current branch.")
82 print("You should run 'mtn merge_update' to merge the heads and update.")
83 print("After you have verified the merged revision is ok, run 'mtn nci'")
84 print("again to commit and push the changes.")
85 end
86end
87
88register_command("net_commit", "", "Commit, pull and push a workspace",
89 "This command approximates the commit command of a centralised revision control system. " ..
90 "It first commits your work to the local repository, then contacts the server to gather " ..
91 "new revisions. If there is a single head at this point, then the local changes are pushed " ..
92 "to the server.", "net_commit")
93
94alias_command("net_commit", "nci")
95
96function merge_update(...)
97 result, output = mtn_automate("get_option", "branch")-- make sure we have a valid workspace
98 if not result then
99 print("Error from mtn_automate call to get_option: ", output)
100 print("Do you have a vaild workspace?")
101 return
102 end
103 result, output = mtn_automate("merge")
104 if not result then
105 print("Error from mtn_automate call to heads: ", output)
106 return
107 end
108 -- print(output)
109 result, output = mtn_automate("update")
110 if not result then
111 print("Error from mtn_automate call to heads: ", output)
112 return
113 end
114 -- print(output)
115end
116
117register_command("merge_update", "", "Merge and update a workspace",
118 "This command merges multiple heads of a branch, and then updates the current workspace " ..
119 "to the resulting revision.", "merge_update")
120
121alias_command("merge_update", "mup")

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status