monotone

monotone Mtn Source Tree

Root/contrib/extra-commands.lua

1alias_command("annotate", "blame")
2alias_command("annotate", "praise")
3
4function net_update(...)
5 -- could use 'mtn pull --update', or add --update to get_default_command_options for 'pull'
6
7 result, output = mtn_automate("get_option", "branch")-- make sure we have a valid workspace
8 if not result then
9 print("Error from mtn automate call to get_option: ", ouput)
10 print("Do you have a vaild workspace?")
11 return
12 end
13 result, output = mtn_automate("pull")
14 if not result then
15 print("Error from mtn automate call to pull: ", output)
16 return
17 end
18 result, output = mtn_automate("update")
19 if not result then
20 print("Error from mtn automate call to update: ", output)
21 return
22 end
23 -- print(output)
24end
25
26register_command("net_update", "", "Pull and update a workspace",
27 "This command approximates the update command of a centralised revision control system. " ..
28 "It first contacts the server to gather new revisions and then it updates the workspace.", "net_update")
29
30alias_command("net_update", "nup")
31
32function net_commit(...)
33 result, output = mtn_automate("get_option", "branch")-- make sure we have a valid workspace
34 if not result then
35 print("Error from mtn automate call to get_option: ", output)
36 print("Do you have a vaild workspace?")
37 return
38 end
39 result, output = mtn_automate("commit")
40 if not result then
41 print("Error from mtn automate call to commit: ", output)
42 return
43 end
44 print(output)
45 result, output = mtn_automate("pull")
46 if not result then
47 print("Error from mtn automate call to pull: ", output)
48 return
49 end
50 result, heads = mtn_automate("heads")
51 if not result then
52 print("Error from mtn automate call to heads: ", output)
53 return
54 end
55 words = 0
56 for word in string.gfind(heads, "[^%s]+") do words=words+1 end
57 if words == 1 then
58 result, output = mtn_automate("push")
59 if not result then
60 print("Error from mtn automate call to push: ", output)
61 return
62 end
63 else
64 print("There are multiple heads in your current branch.")
65 print("You should run 'mtn merge_update' to merge the heads and update.")
66 print("After you have verified the merged revision is ok, run 'mtn nci'")
67 print("again to commit and push the changes.")
68 end
69end
70
71register_command("net_commit", "", "Commit, pull and push a workspace",
72 "This command approximates the commit command of a centralised revision control system. " ..
73 "It first commits your work to the local repository, then contacts the server to gather " ..
74 "new revisions. If there is a single head at this point, then the local changes are pushed " ..
75 "to the server.", "net_commit")
76
77alias_command("net_commit", "nci")
78
79function merge_update(...)
80 -- could use 'mtn merge --update', or add --update to get_default_command_options for 'merge'
81
82 result, output = mtn_automate("get_option", "branch")-- make sure we have a valid workspace
83 if not result then
84 print("Error from mtn_automate call to get_option: ", output)
85 print("Do you have a vaild workspace?")
86 return
87 end
88 result, output = mtn_automate("merge")
89 if not result then
90 print("Error from mtn_automate call to heads: ", output)
91 return
92 end
93 -- print(output)
94 result, output = mtn_automate("update")
95 if not result then
96 print("Error from mtn_automate call to heads: ", output)
97 return
98 end
99 -- print(output)
100end
101
102register_command("merge_update", "", "Merge and update a workspace",
103 "This command merges multiple heads of a branch, and then updates the current workspace " ..
104 "to the resulting revision.", "merge_update")
105
106alias_command("merge_update", "mup")

Archive Download this file

Branches

Tags

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