line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::SCM::Digest::SCM::Hg; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
61720
|
use strict; |
|
8
|
|
|
|
|
27
|
|
|
8
|
|
|
|
|
231
|
|
4
|
8
|
|
|
8
|
|
38
|
use warnings; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
276
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
259
|
use App::SCM::Digest::Utils qw(system_ad); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
382
|
|
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
299
|
use autodie; |
|
8
|
|
|
|
|
9976
|
|
|
8
|
|
|
|
|
37
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
11
|
|
|
|
|
|
|
{ |
12
|
2
|
|
|
2
|
0
|
972
|
my ($class) = @_; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
|
|
5428
|
my $res = system("hg --version >/dev/null"); |
15
|
2
|
50
|
|
|
|
42
|
if ($res != 0) { |
16
|
2
|
|
|
|
|
48
|
die "Unable to find hg executable."; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $self = {}; |
20
|
0
|
|
|
|
|
|
bless $self, $class; |
21
|
0
|
|
|
|
|
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub clone |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
0
|
0
|
|
my ($self, $url, $name) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $res = system_ad("hg clone $url $name"); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub open_repository |
34
|
|
|
|
|
|
|
{ |
35
|
0
|
|
|
0
|
0
|
|
my ($self, $path) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
chdir $path; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
return 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub is_usable |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
0
|
0
|
|
return 1; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub pull |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $res = system_ad("hg pull"); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
return 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub branches |
57
|
|
|
|
|
|
|
{ |
58
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $current = $self->branch_name(); |
61
|
0
|
|
|
|
|
|
my @branch_infos = `hg branches`; |
62
|
0
|
|
|
|
|
|
my @results; |
63
|
0
|
|
|
|
|
|
for my $branch_info (@branch_infos) { |
64
|
0
|
|
|
|
|
|
chomp $branch_info; |
65
|
0
|
|
|
|
|
|
my ($entry, $commit) = ($branch_info =~ /^(\S+?)\s+(\S+)/); |
66
|
0
|
|
|
|
|
|
$self->checkout($entry); |
67
|
0
|
|
|
|
|
|
$commit = `hg log --limit 1 --template '{node}'`; |
68
|
0
|
|
|
|
|
|
chomp $commit; |
69
|
0
|
|
|
|
|
|
push @results, [ $entry => $commit ]; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
0
|
|
|
|
|
if ($current ne 'default') { |
72
|
0
|
|
|
|
|
|
$self->checkout($current); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return \@results; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub branch_name |
79
|
|
|
|
|
|
|
{ |
80
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $branch = `hg branch`; |
83
|
0
|
|
|
|
|
|
chomp $branch; |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return $branch; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub checkout |
89
|
|
|
|
|
|
|
{ |
90
|
0
|
|
|
0
|
0
|
|
my ($self, $branch) = @_; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
system_ad("hg checkout $branch"); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
return 1; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub commits_from |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
|
|
0
|
0
|
|
my ($self, $branch, $from) = @_; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my @new_commits = |
102
|
0
|
|
|
|
|
|
map { chomp; $_ } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
`hg log -b $branch --template "{node}\n" -r $from:tip`; |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
0
|
|
|
|
if (@new_commits and ($new_commits[0] eq $from)) { |
106
|
0
|
|
|
|
|
|
shift @new_commits; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return \@new_commits; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub has |
113
|
|
|
|
|
|
|
{ |
114
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $res = system("hg log --rev $id >/dev/null 2>&1"); |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
return ($res == 0); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub show |
122
|
|
|
|
|
|
|
{ |
123
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my @data = `hg log --rev $id`; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return \@data; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub show_all |
131
|
|
|
|
|
|
|
{ |
132
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
my @data = `hg log --patch --rev $id`; |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
return \@data; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 NAME |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
App::SCM::Digest::SCM::Git |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 DESCRIPTION |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Git L<App::SCM::Digest::SCM> implementation. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |