Class: CloudRCS::Rmfile
Overview
A primitive patch type that represents the deletion of a file.
Constant Summary
PrimitivePatch::PATH_PREFIX
Class Method Summary
collapse
Instance Method Summary
collapse
#apply!, escape_path, merge, #named_patch?, #new_path, #primitive_patch?, #to_a, unescape_path
Class Method Details
.generate(orig_file, changed_file) ⇒ Object
44
45
46
47
48
|
# File 'lib/cloud_rcs/patch_types/rmfile.rb', line 44
def generate(orig_file, changed_file)
if changed_file.nil? and not orig_file.nil?
return Rmfile.new(:path => orig_file.path)
end
end
|
.parse(contents) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/cloud_rcs/patch_types/rmfile.rb', line 50
def parse(contents)
unless contents =~ /^rmfile\s+(\S+)\s*$/
raise "Failed to parse rmfile patch: #{contents}"
end
Rmfile.new(:path => unescape_path($1))
end
|
.priority ⇒ Object
40
41
42
|
# File 'lib/cloud_rcs/patch_types/rmfile.rb', line 40
def priority
90
end
|
Instance Method Details
#after_initialize ⇒ Object
7
8
9
|
# File 'lib/cloud_rcs/patch_types/rmfile.rb', line 7
def after_initialize
verify_path_prefix
end
|
#apply_to(file) ⇒ Object
33
34
35
36
|
# File 'lib/cloud_rcs/patch_types/rmfile.rb', line 33
def apply_to(file)
return file unless file and file.path == path
return nil end
|
#commute(patch) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/cloud_rcs/patch_types/rmfile.rb', line 19
def commute(patch)
if patch.is_a? Rmfile and patch.path == self.path
raise CommuteException(true, "Conflict: cannot remove the same file twice.")
elsif patch.is_a? Addfile and patch.path == self.path
raise CommuteException(true, "Conflict: commuting rmfile and addfile yields two files with the same name.")
elsif patch.is_a? Move and patch.path == self.path
raise CommuteException(true, "Conflict: commuting rmfile and move yields two files with the same name.")
else
patch1 = patch.clone
patch2 = self.clone
end
return patch1, patch2
end
|
#inverse ⇒ Object
15
16
17
|
# File 'lib/cloud_rcs/patch_types/rmfile.rb', line 15
def inverse
Addfile.new(:path => path)
end
|
#to_s ⇒ Object
11
12
13
|
# File 'lib/cloud_rcs/patch_types/rmfile.rb', line 11
def to_s
"rmfile #{self.class.escape_path(path)}"
end
|