Class: BetweenMeals::Repo::Hg
Defined Under Namespace
Classes: Cmd
Instance Attribute Summary
#bin, #repo_path
Instance Method Summary
collapse
#create, get, #head, #head_msg, #head_msg=, #initialize, #latest_revision
Instance Method Details
#changes(start_ref, end_ref) ⇒ Object
Return files changed between two revisions
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/between_meals/repo/hg.rb', line 47
def changes(start_ref, end_ref)
valid_ref?(start_ref)
valid_ref?(end_ref) if end_ref
stdout = @cmd.status(start_ref, end_ref).stdout
begin
parse_status(stdout).compact
rescue StandardError => e
@logger.error(
'Something went wrong. Please report this output.',
)
@logger.error(e)
stdout.lines.each do |line|
@logger.error(line.strip)
end
exit(1)
end
end
|
#checkout(url) ⇒ Object
42
43
44
|
# File 'lib/between_meals/repo/hg.rb', line 42
def checkout(url)
@cmd.clone(url, @repo_path)
end
|
#email ⇒ Object
116
117
118
119
120
|
# File 'lib/between_meals/repo/hg.rb', line 116
def email
username[2]
rescue StandardError
nil
end
|
#exists? ⇒ Boolean
34
35
36
|
# File 'lib/between_meals/repo/hg.rb', line 34
def exists?
Dir.exists?(Pathname.new(@repo_path).join('.hg'))
end
|
#files ⇒ Object
75
76
77
78
79
|
# File 'lib/between_meals/repo/hg.rb', line 75
def files
@cmd.manifest.stdout.split("\n").map do |x|
{ :path => x, :status => :created }
end
end
|
#head_parents ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/between_meals/repo/hg.rb', line 81
def head_parents
[{
:time => Time.parse(@cmd.log('date|isodate', 'master').stdout),
:rev => @cmd.log('node', 'master').stdout,
}]
rescue StandardError
[{
:time => nil,
:rev => nil,
}]
end
|
#head_rev ⇒ Object
38
39
40
|
# File 'lib/between_meals/repo/hg.rb', line 38
def head_rev
@cmd.log('node').stdout
end
|
#last_author ⇒ Object
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/between_meals/repo/hg.rb', line 93
def last_author
[
/^.*<(.*)>$/,
/^(.*@.*)$/,
].each do |re|
m = @cmd.log('author').stdout.match(re)
return { :email => m[1] } if m
end
return { :email => nil }
end
|
#last_msg ⇒ Object
104
105
106
107
108
|
# File 'lib/between_meals/repo/hg.rb', line 104
def last_msg
@cmd.log('desc').stdout
rescue StandardError
nil
end
|
#last_msg=(msg) ⇒ Object
110
111
112
113
114
|
# File 'lib/between_meals/repo/hg.rb', line 110
def last_msg=(msg)
if last_msg.strip != msg.strip
@cmd.amend(msg.strip)
end
end
|
#name ⇒ Object
122
123
124
125
126
|
# File 'lib/between_meals/repo/hg.rb', line 122
def name
username[1]
rescue StandardError
nil
end
|
#setup ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/between_meals/repo/hg.rb', line 25
def setup
@bin = 'hg'
@cmd = BetweenMeals::Repo::Hg::Cmd.new(
:bin => @bin,
:cwd => @repo_path,
:logger => @logger,
)
end
|
#status ⇒ Object
128
129
130
|
# File 'lib/between_meals/repo/hg.rb', line 128
def status
@cmd.status.stdout
end
|
#update ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/between_meals/repo/hg.rb', line 66
def update
@cmd.pull.stdout
rescue StandardError
@logger.error('Something went wrong with hg!')
@logger.error(cmd.stdout)
raise
end
|
#upstream?(rev) ⇒ Boolean
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/between_meals/repo/hg.rb', line 132
def upstream?(rev)
if @cmd.rev("'ancestor(master,#{rev}) & #{rev}'").stdout.empty?
return false
else
return true
end
end
|
#valid_ref?(ref) ⇒ Boolean
143
144
145
146
147
148
|
# File 'lib/between_meals/repo/hg.rb', line 143
def valid_ref?(ref)
@cmd.rev(ref)
return true
rescue StandardError
raise Changeset::ReferenceError
end
|