Class RSCM::Monotone
In: lib/rscm/scm/monotone.rb
Parent: Base

Methods

Attributes

branch  [RW] 
db_file  [RW] 
key  [RW] 
keys_file  [RW] 
passphrase  [RW] 
server  [RW] 

Public Class methods

[Source]

    # File lib/rscm/scm/monotone.rb, line 14
14:     def initialize(branch=nil, key=nil, passphrase=nil, keys_file=nil, server=nil, central_checkout_dir=nil)
15:       @branch = branch
16:       @key = key
17:       @passphrase = passphrase
18:       @keys_file = keys_file
19:       @server = server
20:       @central_checkout_dir = File.expand_path(central_checkout_dir) unless central_checkout_dir.nil?
21:     end

Public Instance methods

[Source]

    # File lib/rscm/scm/monotone.rb, line 23
23:     def add(relative_filename)
24:       db = db(@checkout_dir)
25:       with_working_dir(@checkout_dir) do
26:         monotone("add #{relative_filename}", db)
27:       end
28:     end

[Source]

    # File lib/rscm/scm/monotone.rb, line 37
37:     def can_create_central?
38:       @server == "localhost" && !@central_checkout_dir.nil?
39:     end

[Source]

    # File lib/rscm/scm/monotone.rb, line 41
41:     def central_exists?
42:       @central_checkout_dir && @serve_pid
43:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 108
108:     def checked_out?
109:       mt = File.expand_path("#{@checkout_dir}/MT")
110:       File.exists?(mt)
111:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 134
134:     def commit(message)
135:       commit_in_dir(message, @checkout_dir)
136:       with_working_dir(@checkout_dir) do
137:         monotone("push #{@server} #{@branch}") do |io|
138:           io.puts(@passphrase)
139:           io.close_write
140:           io.read
141:         end
142:       end
143:     end

[Source]

    # File lib/rscm/scm/monotone.rb, line 45
45:     def create_central
46:       init(@central_checkout_dir)
47:       # create empty working copy
48:       dir = PathConverter.filepath_to_nativepath(@central_checkout_dir, false)
49:       # set up a working copy
50:       monotone("setup #{dir}")
51:       start_serve
52:     end

[Source]

    # File lib/rscm/scm/monotone.rb, line 89
89:     def destroy_central
90:       stop_serve
91:       FileUtils.rm_rf(@central_checkout_dir) if File.exist?(@central_checkout_dir)
92:       FileUtils.rm(db(@central_checkout_dir)) if File.exist?(db(@central_checkout_dir))
93:       puts "Destroyed Monotone server"
94:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 174
174:     def diff(change, &block)
175:       checkout(change.revision)
176:       with_working_dir(@checkout_dir) do
177:         monotone("diff --revision=#{change.previous_native_revision_identifier} #{change.path}") do |stdout|
178:           yield stdout
179:         end
180:       end
181:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 100
100:     def import_central(dir, message)
101:       FileUtils.cp_r(Dir["#{dir}/*"], @central_checkout_dir)
102:       with_working_dir(@central_checkout_dir) do
103:         monotone("add .")
104:         commit_in_dir(message, @central_checkout_dir)
105:       end
106:     end

www.venge.net/monotone/monotone.html#Hook-Reference

[Source]

     # File lib/rscm/scm/monotone.rb, line 154
154:     def install_trigger(trigger_command, install_dir)
155:       stop_serve
156:       if (WINDOWS)
157:         install_win_trigger(trigger_comand, install_dir)
158:       else
159:         install_unix_trigger(trigger_command, install_dir)
160:       end
161:       start_serve
162:     end

[Source]

    # File lib/rscm/scm/monotone.rb, line 30
30:     def move(relative_src, relative_dest)
31:       with_working_dir(@checkout_dir) do
32:         monotone("rename #{relative_src} #{relative_dest}", db)
33:         FileUtils.mv(relative_src, relative_dest)
34:       end
35:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 124
124:     def revisions(from_identifier, to_identifier=Time.infinity)
125:       checkout(to_identifier)
126:       to_identifier = Time.infinity if to_identifier.nil?
127:       with_working_dir(checkout_dir) do
128:         monotone("log") do |stdout|
129:           MonotoneLogParser.new.parse_revisions(stdout, from_identifier, to_identifier)
130:         end
131:       end
132:     end

[Source]

    # File lib/rscm/scm/monotone.rb, line 54
54:     def start_serve
55:       mode = File::CREAT|File::WRONLY
56:       if File.exist?(rcfile)
57:         mode = File::APPEND|File::WRONLY
58:       end
59: 
60:       begin
61:         File.open(rcfile, mode) do |file|
62:           file.puts("function get_netsync_anonymous_read_permitted(collection)")
63:           file.puts("  return true")
64:           file.puts("end")
65:         end
66:       rescue => e
67:         puts e.message
68:         puts e.backtrace.join("\n")
69:         raise "Didn't have permission to write to #{rcfile}."
70:       end
71: 
72:       @serve_pid = fork do
73:         #Signal.trap("HUP") { puts "Monotone server shutting down..."; exit }
74:         monotone("serve --rcfile=\"#{rcfile}\" #{@server} #{@branch}", db(@central_checkout_dir)) do |io|
75:           puts "PASSPHRASE: #{@passphrase}"
76:           io.puts(@passphrase)
77:           io.close_write
78:         end
79:       end
80:       Process.detach(@serve_pid)
81:     end

[Source]

    # File lib/rscm/scm/monotone.rb, line 83
83:     def stop_serve
84:       Process.kill("HUP", @serve_pid) if @serve_pid
85:       Process.waitpid2(@serve_pid) if @serve_pid
86:       @serve_pid = nil
87:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 145
145:     def supports_trigger?
146:       true
147:     end

[Source]

    # File lib/rscm/scm/monotone.rb, line 96
96:     def transactional?
97:       true
98:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 164
164:     def trigger_installed?(trigger_command, install_dir)
165:       File.exist?(rcfile)
166:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 149
149:     def trigger_mechanism
150:       "MT/monotonerc"
151:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 168
168:     def uninstall_trigger(trigger_command, install_dir)
169:       stop_serve
170:       File.delete(rcfile)
171:       start_serve
172:     end

[Source]

     # File lib/rscm/scm/monotone.rb, line 113
113:     def uptodate?(identifier=nil)
114:       if (!checked_out?)
115:         false
116:       else
117:         pull
118: 
119:         rev = identifier ? identifier : head_revision
120:         local_revision == rev
121:       end
122:     end

Protected Instance methods

Checks out silently. Called by superclass’ checkout.

[Source]

     # File lib/rscm/scm/monotone.rb, line 186
186:     def checkout_silent(to_identifier)
187:       # raise "Monotone doesn't support checkout to time. Please use identifiers instead." if to_identifier.is_a?(Time)
188:       db_file = db(@checkout_dir)
189:       if(!File.exist?(db_file))
190:         init(@checkout_dir)
191:       end
192: 
193:       pull
194:       checked_out = checked_out?
195: 
196:       with_working_dir(@checkout_dir) do
197:         monotone("checkout .", db_file, @branch) unless checked_out
198: 
199:         selector = expand_selector(to_identifier)
200:         monotone("update #{selector}", db_file)
201:       end
202:     end

Administrative files that should be ignored when counting files.

[Source]

     # File lib/rscm/scm/monotone.rb, line 205
205:     def ignore_paths
206:       [/MT/, /\.mt-attrs/]
207:     end

[Validate]