Class: PVN::Pct::RepositoryDiffer
- Inherits:
-
Differ
- Object
- Differ
- PVN::Pct::RepositoryDiffer
show all
- Defined in:
- lib/pvn/pct/repository_differ.rb
Instance Method Summary
collapse
Methods inherited from Differ
#initialize, #show_diff_counts
Instance Method Details
#directory?(elmt) ⇒ Boolean
32
33
34
35
|
# File 'lib/pvn/pct/repository_differ.rb', line 32
def directory? elmt
elmtinfo = elmt.get_info
elmtinfo.kind == 'dir'
end
|
#get_diff_counts(path, options) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/pvn/pct/repository_differ.rb', line 46
def get_diff_counts path, options
revision = options.revision
fromrev, torev = get_from_to_revisions revision
elmt = PVN::IO::Element.new :local => path
modnames = get_modified elmt, fromrev, torev
reporoot = elmt.repo_root
svninfo = get_local_info
filter = svninfo.url.dup
filter.slice! svninfo.root
filterre = Regexp.new '^' + filter + '/'
diff_counts = Array.new
modnames.each do |mod|
fullpath = reporoot + mod
elmt = PVN::IO::Element.new :path => fullpath
next unless has_revisions? elmt, fromrev, torev
next if directory? elmt
from_count = get_line_count elmt, fromrev
to_count = get_line_count elmt, torev
name = mod.dup
name.slice! filterre
dc = PVN::DiffCount.new from_count, to_count, name
diff_counts << dc
end
diff_counts
end
|
#get_from_to_revisions(rev) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/pvn/pct/repository_differ.rb', line 11
def get_from_to_revisions rev
if rev.size == 1
if md = Regexp.new('(.+):(.+)').match(rev[0])
[ md[1], md[2] ]
else
[ (rev[0].to_i - 1).to_s, rev[0] ]
end
else
[ rev[0], rev[1] ]
end
end
|
#get_line_count(elmt, rev) ⇒ Object
42
43
44
|
# File 'lib/pvn/pct/repository_differ.rb', line 42
def get_line_count elmt, rev
elmt.cat(rev).size
end
|
#get_local_info ⇒ Object
37
38
39
40
|
# File 'lib/pvn/pct/repository_differ.rb', line 37
def get_local_info
direlmt = PVN::IO::Element.new :local => '.'
direlmt.get_info
end
|
#get_modified(elmt, fromrev, torev) ⇒ Object
23
24
25
26
|
# File 'lib/pvn/pct/repository_differ.rb', line 23
def get_modified elmt, fromrev, torev
modified = elmt.find_modified_entries [ fromrev + ':' + torev ]
modified.collect { |m| m.name }.sort.uniq
end
|
#has_revisions?(elmt, fromrev, torev) ⇒ Boolean
28
29
30
|
# File 'lib/pvn/pct/repository_differ.rb', line 28
def has_revisions? elmt, fromrev, torev
elmt.has_revision?(fromrev) && elmt.has_revision?(torev)
end
|