annotate hg-browse @ 3:f05a6c7471fa

tweak
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sat, 06 Apr 2019 17:34:35 +0900
parents 3656bdd46f54
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #!/usr/bin/env perl
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 use strict;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 use warnings;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 use IPC::Run3;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 # hg config経由でhgrcにかかれているpush先を確認する
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 my @cmd = ('hg','config','paths.default');
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 my ($stdout,$stderr);
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 eval { run3 \@cmd,undef,\$stdout,\$stderr;};
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 if ($@){
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 print "error! >> $stderr";
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 exit 1;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 }
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 # 無かったら特に何もしない
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 exit 1 unless ($stdout);
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 # yomitanはパスで開けないので別枠
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 if ($stdout =~ /yomitan/){
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 yomitan($stdout);
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 } elsif ($stdout =~ /firefly/){
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 firefly($stdout);
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 }
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 if ( $stdout =~ m[(https?|ssh)://(\w+@)?(.*)]){
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 my $url = "http://$3";
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 @cmd = ('open',$url);
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 eval { run3 \@cmd,undef,\$stdout,\$stderr;};
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 if ($@){
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 print "error! >> $stderr";
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 exit 1;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 }
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 }
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 sub yomitan {
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 my $input = shift;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 my $http_domain = 'https://ie.u-ryukyu.ac.jp/hg/';
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 my $mid_path = 'index.cgi/home/hg/';
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 my $url;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
1
85f5eada6707 fix regex for yomitan
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
44 if ($input =~ m[.*//home/hg/y(\d+)(.+)]){
0
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 $url = $http_domain . "y$1/".$mid_path."y$1".$2;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 }
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 @cmd = ('open',$url);
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 eval { run3 \@cmd,undef,\$stdout,\$stderr;};
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 exit 0;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 }
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 sub firefly {
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 my $input = shift;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 my $http_domain = 'http://www.cr.ie.u-ryukyu.ac.jp/';
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 my $url;
3
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
56 if (($input =~ m[.*?firefly.cr.ie.u-ryukyu.ac.jp/(.*)] )||($input =~ m[.*firefly/(.*)])){
0
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 $url = $http_domain.$1;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 }
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 @cmd = ('open',$url);
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 eval { run3 \@cmd,undef,\$stdout,\$stderr;};
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 exit 0;
78df974566a7 initial commit
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 }