author | Daniel Diniz <ajaksu@gmail.com> |
Fri, 03 Jul 2009 15:21:44 +0200 | |
changeset 2507 | 4a6b8d6674b6 |
parent 300 | d36b597ef29d |
permissions | -rwxr-xr-x |
64
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/perl -w |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
3 |
# $HeadURL$ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
4 |
# $LastChangedDate$ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
5 |
# $LastChangedBy$ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
6 |
# $LastChangedRevision$ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
7 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
8 |
$| = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
9 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
10 |
use strict; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
11 |
use Carp; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
12 |
use Cwd; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
13 |
use Digest::MD5 2.20; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
14 |
use File::Copy 2.03; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
15 |
use File::Find; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
16 |
use File::Path 1.0404; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
17 |
use File::Temp 0.12 qw(tempdir tempfile); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
18 |
use Getopt::Long 2.25; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
19 |
use Text::Wrap; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
20 |
use URI 1.17; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
21 |
use English; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
22 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
23 |
$Text::Wrap::columns = 72; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
24 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
25 |
# Specify the location of the svn command. |
300
d36b597ef29d
Changed location of the svn command in svn_load_dirs.pl script from '/usr/bin/svn' to 'svn'. That makes the script more universal and it should work on Linux, Windows and Mac OS X if the svn is in the PATH.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
106
diff
changeset
|
26 |
my $svn = 'svn'; |
64
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
27 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
28 |
# Process the command line options. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
29 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
30 |
# The base URL for the portion of the repository to work in. Note |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
31 |
# that this does not have to be the root of the subversion repository, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
32 |
# it can point to a subdirectory in the repository. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
33 |
my $repos_base_url; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
34 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
35 |
# The relative path from the repository base URL to work in to the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
36 |
# directory to load the input directories into. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
37 |
my $repos_load_rel_path; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
38 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
39 |
# To specify where tags, which are simply copies of the imported |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
40 |
# directory, should be placed relative to the repository base URL, use |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
41 |
# the -t command line option. This value must contain regular |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
42 |
# expressions that match portions of the input directory names to |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
43 |
# create an unique tag for each input directory. The regular |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
44 |
# expressions are surrounded by a specified character to distinguish |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
45 |
# the regular expression from the normal directory path. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
46 |
my $opt_import_tag_location; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
47 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
48 |
# Do not ask for any user input. Just go ahead and do everything. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
49 |
my $opt_no_user_input; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
50 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
51 |
# Do not automatically set the svn:executable property based on the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
52 |
# file's exe bit. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
53 |
my $opt_no_auto_exe; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
54 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
55 |
# Username to use for commits. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
56 |
my $opt_svn_username; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
57 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
58 |
# Password to use for commits. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
59 |
my $opt_svn_password; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
60 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
61 |
# Verbosity level. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
62 |
my $opt_verbose; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
63 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
64 |
# Path to already checked-out working copy. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
65 |
my $opt_existing_wc_dir; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
66 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
67 |
# List of filename patterns to ignore (as in .subversion/config's |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
68 |
# "global-ignores" option). |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
69 |
my $opt_glob_ignores; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
70 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
71 |
# This is the character used to separate regular expressions occuring |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
72 |
# in the tag directory path from the path itself. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
73 |
my $REGEX_SEP_CHAR = '@'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
74 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
75 |
# This specifies a configuration file that contains a list of regular |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
76 |
# expressions to check against a file and the properties to set on |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
77 |
# matching files. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
78 |
my $property_config_filename; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
79 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
80 |
GetOptions('no_user_input' => \$opt_no_user_input, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
81 |
'no_auto_exe' => \$opt_no_auto_exe, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
82 |
'property_cfg_filename=s' => \$property_config_filename, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
83 |
'svn_password=s' => \$opt_svn_password, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
84 |
'svn_username=s' => \$opt_svn_username, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
85 |
'tag_location=s' => \$opt_import_tag_location, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
86 |
'verbose+' => \$opt_verbose, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
87 |
'wc=s' => \$opt_existing_wc_dir, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
88 |
'glob_ignores=s' => \$opt_glob_ignores) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
89 |
or &usage; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
90 |
&usage("$0: too few arguments") if @ARGV < 2; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
91 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
92 |
$repos_base_url = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
93 |
$repos_load_rel_path = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
94 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
95 |
# Check that the repository base URL and the import directories do not |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
96 |
# contain any ..'s. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
97 |
if ($repos_base_url =~ /\.{2}/) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
98 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
99 |
die "$0: repos base URL $repos_base_url cannot contain ..'s.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
100 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
101 |
if ($repos_load_rel_path =~ /\.{2}/) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
102 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
103 |
die "$0: repos import relative directory path $repos_load_rel_path ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
104 |
"cannot contain ..'s.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
105 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
106 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
107 |
# If there are no directories listed on the command line, then the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
108 |
# directories are read from standard input. In this case, the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
109 |
# -no_user_input command line option must be specified. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
110 |
if (!@ARGV and !$opt_no_user_input) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
111 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
112 |
&usage("$0: must use -no_user_input if no dirs listed on command line."); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
113 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
114 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
115 |
# The tag option cannot be used when directories are read from |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
116 |
# standard input because tags may collide and no user input can be |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
117 |
# taken to verify that the input is ok. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
118 |
if (!@ARGV and $opt_import_tag_location) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
119 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
120 |
&usage("$0: cannot use -tag_location when dirs are read from stdin."); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
121 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
122 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
123 |
# If the tag directory is set, then the import directory cannot be '.'. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
124 |
if (defined $opt_import_tag_location and $repos_load_rel_path eq '.') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
125 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
126 |
&usage("$0: cannot set import_dir to '.' and use -t command line option."); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
127 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
128 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
129 |
# Set the svn command line options that are used anytime svn connects |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
130 |
# to the repository. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
131 |
my @svn_use_repos_cmd_opts; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
132 |
&set_svn_use_repos_cmd_opts($opt_svn_username, $opt_svn_password); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
133 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
134 |
# Check that the tag directories do not contain any ..'s. Also, the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
135 |
# import and tag directories cannot be absolute. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
136 |
if (defined $opt_import_tag_location and $opt_import_tag_location =~ /\.{2}/) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
137 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
138 |
die "$0: repos tag relative directory path $opt_import_tag_location ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
139 |
"cannot contain ..'s.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
140 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
141 |
if ($repos_load_rel_path =~ m|^/|) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
142 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
143 |
die "$0: repos import relative directory path $repos_load_rel_path ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
144 |
"cannot start with /.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
145 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
146 |
if (defined $opt_import_tag_location and $opt_import_tag_location =~ m|^/|) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
147 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
148 |
die "$0: repos tagrelative directory path $opt_import_tag_location ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
149 |
"cannot start with /.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
150 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
151 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
152 |
if (defined $opt_existing_wc_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
153 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
154 |
unless (-e $opt_existing_wc_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
155 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
156 |
die "$0: working copy '$opt_existing_wc_dir' does not exist.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
157 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
158 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
159 |
unless (-d _) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
160 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
161 |
die "$0: working copy '$opt_existing_wc_dir' is not a directory.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
162 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
163 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
164 |
unless (-d "$opt_existing_wc_dir/.svn") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
165 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
166 |
die "$0: working copy '$opt_existing_wc_dir' does not have .svn ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
167 |
"directory.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
168 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
169 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
170 |
$opt_existing_wc_dir = Cwd::abs_path($opt_existing_wc_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
171 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
172 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
173 |
# If no glob_ignores specified, try to deduce from config file, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
174 |
# or use the default below. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
175 |
my $ignores_str = |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
176 |
'*.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
177 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
178 |
if ( defined $opt_glob_ignores) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
179 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
180 |
$ignores_str = $opt_glob_ignores; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
181 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
182 |
elsif ( -f "$ENV{HOME}/.subversion/config" ) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
183 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
184 |
open my $conf, "$ENV{HOME}/.subversion/config"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
185 |
while (<$conf>) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
186 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
187 |
if ( /^global-ignores\s*=\s*(.*?)\s*$/ ) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
188 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
189 |
$ignores_str = $1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
190 |
last; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
191 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
192 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
193 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
194 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
195 |
my @glob_ignores = map |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
196 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
197 |
s/\./\\\./g; s/\*/\.\*/g; "^$_\$"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
198 |
} split(/\s+/, $ignores_str); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
199 |
unshift @glob_ignores, '\.svn$'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
200 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
201 |
# Convert the string URL into a URI object. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
202 |
$repos_base_url =~ s|/*$||; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
203 |
my $repos_base_uri = URI->new($repos_base_url); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
204 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
205 |
# Check that $repos_load_rel_path is not a directory here implying |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
206 |
# that a command line option was forgotten. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
207 |
if ($repos_load_rel_path ne '.' and -d $repos_load_rel_path) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
208 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
209 |
die "$0: import_dir '$repos_load_rel_path' is a directory.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
210 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
211 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
212 |
# The remaining command line arguments should be directories. Check |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
213 |
# that they all exist and that there are no duplicates. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
214 |
if (@ARGV) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
215 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
216 |
my %dirs; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
217 |
foreach my $dir (@ARGV) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
218 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
219 |
unless (-e $dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
220 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
221 |
die "$0: directory '$dir' does not exist.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
222 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
223 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
224 |
unless (-d _) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
225 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
226 |
die "$0: directory '$dir' is not a directory.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
227 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
228 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
229 |
if ($dirs{$dir}) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
230 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
231 |
die "$0: directory '$dir' is listed more than once on command ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
232 |
"line.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
233 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
234 |
$dirs{$dir} = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
235 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
236 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
237 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
238 |
# Create the tag locations and print them for the user to review. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
239 |
# Check that there are no duplicate tags. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
240 |
my %load_tags; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
241 |
if (@ARGV and defined $opt_import_tag_location) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
242 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
243 |
my %seen_tags; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
244 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
245 |
foreach my $load_dir (@ARGV) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
246 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
247 |
my $load_tag = &get_tag_dir($load_dir); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
248 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
249 |
print "Directory $load_dir will be tagged as $load_tag\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
250 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
251 |
if ($seen_tags{$load_tag}) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
252 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
253 |
die "$0: duplicate tag generated.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
254 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
255 |
$seen_tags{$load_tag} = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
256 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
257 |
$load_tags{$load_dir} = $load_tag; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
258 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
259 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
260 |
exit 0 unless &get_answer("Please examine identified tags. Are they " . |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
261 |
"acceptable? (Y/n) ", 'ny', 1); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
262 |
print "\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
263 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
264 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
265 |
# Load the property configuration filename, if one was specified, into |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
266 |
# an array of hashes, where each hash contains a regular expression |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
267 |
# and a property to apply to the file if the regular expression |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
268 |
# matches. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
269 |
my @property_settings; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
270 |
if (defined $property_config_filename and length $property_config_filename) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
271 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
272 |
open(CFG, $property_config_filename) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
273 |
or die "$0: cannot open '$property_config_filename' for reading: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
274 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
275 |
my $ok = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
276 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
277 |
while (my $line = <CFG>) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
278 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
279 |
next if $line =~ /^\s*$/; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
280 |
next if $line =~ /^\s*#/; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
281 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
282 |
# Split the input line into words taking into account that |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
283 |
# single or double quotes may define a single word with |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
284 |
# whitespace in it. The format for the file is |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
285 |
# regex control property_name property_value |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
286 |
my @line = &split_line($line); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
287 |
next if @line == 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
288 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
289 |
unless (@line == 2 or @line == 4) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
290 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
291 |
warn "$0: line $. of '$property_config_filename' has to have 2 ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
292 |
"or 4 columns.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
293 |
$ok = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
294 |
next; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
295 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
296 |
my ($regex, $control, $property_name, $property_value) = @line; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
297 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
298 |
unless ($control eq 'break' or $control eq 'cont') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
299 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
300 |
warn "$0: line $. of '$property_config_filename' has illegal ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
301 |
"value for column 3 '$control', must be 'break' or 'cont'.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
302 |
$ok = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
303 |
next; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
304 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
305 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
306 |
# Compile the regular expression. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
307 |
my $re; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
308 |
eval { $re = qr/$regex/i }; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
309 |
if ($@) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
310 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
311 |
warn "$0: line $. of '$property_config_filename' regex '$regex' ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
312 |
"does not compile:\n$@\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
313 |
$ok = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
314 |
next; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
315 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
316 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
317 |
push(@property_settings, {name => $property_name, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
318 |
value => $property_value, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
319 |
control => $control, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
320 |
re => $re}); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
321 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
322 |
close(CFG) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
323 |
or warn "$0: error in closing '$property_config_filename' for ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
324 |
"reading: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
325 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
326 |
exit 1 unless $ok; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
327 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
328 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
329 |
# Check that the svn base URL works by running svn log on it. Only |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
330 |
# get the HEAD revision log message; there's no need to waste |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
331 |
# bandwidth seeing all of the log messages. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
332 |
print "Checking that the base URL is a Subversion repository.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
333 |
read_from_process($svn, 'log', '-r', 'HEAD', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
334 |
@svn_use_repos_cmd_opts, $repos_base_uri); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
335 |
print "\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
336 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
337 |
my $orig_cwd = cwd; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
338 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
339 |
# The first step is to determine the root of the svn repository. Do |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
340 |
# this with the svn log command. Take the svn_url hostname and port |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
341 |
# as the initial url and append to it successive portions of the final |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
342 |
# path until svn log succeeds. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
343 |
print "Finding the root URL of the Subversion repository.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
344 |
my $repos_root_uri; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
345 |
my $repos_root_uri_path; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
346 |
my $repos_base_path_segment; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
347 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
348 |
my $r = $repos_base_uri->clone; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
349 |
my @path_segments = grep { length($_) } $r->path_segments; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
350 |
my @repos_base_path_segments = @path_segments; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
351 |
unshift(@path_segments, ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
352 |
$r->path(''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
353 |
my @r_path_segments; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
354 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
355 |
while (@path_segments) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
356 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
357 |
$repos_root_uri_path = shift @path_segments; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
358 |
push(@r_path_segments, $repos_root_uri_path); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
359 |
$r->path_segments(@r_path_segments); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
360 |
if (safe_read_from_pipe($svn, 'log', '-r', 'HEAD', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
361 |
@svn_use_repos_cmd_opts, $r) == 0) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
362 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
363 |
$repos_root_uri = $r; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
364 |
last; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
365 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
366 |
shift @repos_base_path_segments; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
367 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
368 |
$repos_base_path_segment = join('/', @repos_base_path_segments); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
369 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
370 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
371 |
if ($repos_root_uri) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
372 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
373 |
print "Determined that the svn root URL is $repos_root_uri.\n\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
374 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
375 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
376 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
377 |
die "$0: cannot determine root svn URL.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
378 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
379 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
380 |
# Create a temporary directory for svn to work in. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
381 |
my $temp_dir = tempdir( "svn_load_dirs_XXXXXXXXXX", TMPDIR => 1 ); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
382 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
383 |
# Put in a signal handler to clean up any temporary directories. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
384 |
sub catch_signal { |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
385 |
my $signal = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
386 |
warn "$0: caught signal $signal. Quitting now.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
387 |
exit 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
388 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
389 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
390 |
$SIG{HUP} = \&catch_signal; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
391 |
$SIG{INT} = \&catch_signal; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
392 |
$SIG{TERM} = \&catch_signal; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
393 |
$SIG{PIPE} = \&catch_signal; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
394 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
395 |
# Create an object that when DESTROY'ed will delete the temporary |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
396 |
# directory. The CLEANUP flag to tempdir should do this, but they |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
397 |
# call rmtree with 1 as the last argument which takes extra security |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
398 |
# measures that do not clean up the .svn directories. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
399 |
my $temp_dir_cleanup = Temp::Delete->new; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
400 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
401 |
# Determine the native end of line style for this system. Do this the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
402 |
# most portable way, by writing a file with a single \n in non-binary |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
403 |
# mode and then reading the file in binary mode. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
404 |
my $native_eol = &determine_native_eol; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
405 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
406 |
# Check if all the directories exist to load the directories into the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
407 |
# repository. If not, ask if they should be created. For tags, do |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
408 |
# not create the tag directory itself, that is done on the svn cp. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
409 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
410 |
print "Finding if any directories need to be created in repository.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
411 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
412 |
my @dirs_to_create; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
413 |
my @urls_to_create; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
414 |
my %seen_dir; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
415 |
my @load_tags_without_last_segment; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
416 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
417 |
# Assume that the last portion of the tag directory contains the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
418 |
# version number and remove it from the directories to create, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
419 |
# because the tag directory will be created by svn cp. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
420 |
foreach my $load_tag (sort values %load_tags) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
421 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
422 |
# Skip this tag if there is only one segment in its name. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
423 |
my $index = rindex($load_tag, '/'); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
424 |
next if $index == -1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
425 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
426 |
# Trim off the last segment and record the result. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
427 |
push(@load_tags_without_last_segment, substr($load_tag, 0, $index)); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
428 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
429 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
430 |
foreach my $dir ($repos_load_rel_path, @load_tags_without_last_segment) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
431 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
432 |
next unless length $dir; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
433 |
my $d = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
434 |
foreach my $segment (split('/', $dir)) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
435 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
436 |
$d = length $d ? "$d/$segment" : $segment; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
437 |
my $url = "$repos_base_url/$d"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
438 |
unless ($seen_dir{$d}) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
439 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
440 |
$seen_dir{$d} = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
441 |
if (safe_read_from_pipe($svn, 'log', '-r', 'HEAD', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
442 |
@svn_use_repos_cmd_opts, $url) != 0) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
443 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
444 |
push(@dirs_to_create, $d); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
445 |
push(@urls_to_create, $url); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
446 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
447 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
448 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
449 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
450 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
451 |
if (@dirs_to_create) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
452 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
453 |
print "The following directories do not exist and need to exist:\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
454 |
foreach my $dir (@dirs_to_create) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
455 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
456 |
print " $dir\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
457 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
458 |
exit 0 unless &get_answer("You must add them now to load the " . |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
459 |
"directories. Continue (Y/n)? ", 'ny', 1); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
460 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
461 |
my $message = "Create directories to load project into.\n\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
462 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
463 |
foreach my $dir (@dirs_to_create) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
464 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
465 |
if (length $repos_base_path_segment) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
466 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
467 |
$message .= "* $repos_base_path_segment/$dir: New directory.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
468 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
469 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
470 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
471 |
$message .= "* $dir: New directory.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
472 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
473 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
474 |
$message = wrap('', ' ', $message); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
475 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
476 |
read_from_process($svn, 'mkdir', @svn_use_repos_cmd_opts, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
477 |
'-m', $message, @urls_to_create); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
478 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
479 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
480 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
481 |
print "No directories need to be created to prepare repository.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
482 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
483 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
484 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
485 |
# Either checkout a new working copy from the repository or use an |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
486 |
# existing working copy. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
487 |
if (defined $opt_existing_wc_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
488 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
489 |
# Update an already existing working copy. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
490 |
print "Not checking out anything; using existing working directory at\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
491 |
print "$opt_existing_wc_dir\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
492 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
493 |
chdir($opt_existing_wc_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
494 |
or die "$0: cannot chdir '$opt_existing_wc_dir': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
495 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
496 |
read_from_process($svn, 'update', @svn_use_repos_cmd_opts); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
497 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
498 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
499 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
500 |
# Check out the svn repository starting at the svn URL into a |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
501 |
# fixed directory name. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
502 |
my $checkout_dir_name = 'my_import_wc'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
503 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
504 |
# Check out only the directory being imported to, otherwise the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
505 |
# checkout of the entire base URL can be very huge, if it contains |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
506 |
# a large number of tags. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
507 |
my $checkout_url; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
508 |
if ($repos_load_rel_path eq '.') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
509 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
510 |
$checkout_url = $repos_base_url; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
511 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
512 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
513 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
514 |
$checkout_url = "$repos_base_url/$repos_load_rel_path"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
515 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
516 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
517 |
print "Checking out $checkout_url into $temp_dir/$checkout_dir_name\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
518 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
519 |
chdir($temp_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
520 |
or die "$0: cannot chdir '$temp_dir': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
521 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
522 |
read_from_process($svn, 'checkout', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
523 |
@svn_use_repos_cmd_opts, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
524 |
$checkout_url, $checkout_dir_name); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
525 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
526 |
chdir($checkout_dir_name) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
527 |
or die "$0: cannot chdir '$checkout_dir_name': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
528 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
529 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
530 |
# At this point, the current working directory is the top level |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
531 |
# directory of the working copy. Record the absolute path to this |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
532 |
# location because the script will chdir back here later on. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
533 |
my $wc_import_dir_cwd = cwd; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
534 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
535 |
# Set up the names for the path to the import and tag directories. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
536 |
my $repos_load_abs_path; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
537 |
if ($repos_load_rel_path eq '.') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
538 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
539 |
$repos_load_abs_path = length($repos_base_path_segment) ? |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
540 |
$repos_base_path_segment : "/"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
541 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
542 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
543 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
544 |
$repos_load_abs_path = length($repos_base_path_segment) ? |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
545 |
"$repos_base_path_segment/$repos_load_rel_path" : |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
546 |
$repos_load_rel_path; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
547 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
548 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
549 |
# Now go through each source directory and copy each file from the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
550 |
# source directory to the target directory. For new target files, add |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
551 |
# them to svn. For files that no longer exist, delete them. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
552 |
my $print_rename_message = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
553 |
my @load_dirs = @ARGV; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
554 |
while (defined (my $load_dir = &get_next_load_dir)) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
555 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
556 |
my $load_tag = $load_tags{$load_dir}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
557 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
558 |
if (defined $load_tag) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
559 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
560 |
print "\nLoading $load_dir and will save in tag $load_tag.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
561 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
562 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
563 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
564 |
print "\nLoading $load_dir.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
565 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
566 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
567 |
# The first hash is keyed by the old name in a rename and the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
568 |
# second by the new name. The last variable contains a list of |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
569 |
# old and new filenames in a rename. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
570 |
my %rename_from_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
571 |
my %rename_to_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
572 |
my @renamed_filenames; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
573 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
574 |
unless ($opt_no_user_input) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
575 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
576 |
my $repeat_loop; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
577 |
do |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
578 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
579 |
$repeat_loop = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
580 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
581 |
my %add_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
582 |
my %del_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
583 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
584 |
# Get the list of files and directories in the repository |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
585 |
# working copy. This hash is called %del_files because |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
586 |
# each file or directory will be deleted from the hash |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
587 |
# using the list of files and directories in the source |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
588 |
# directory, leaving the files and directories that need |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
589 |
# to be deleted. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
590 |
%del_files = &recursive_ls_and_hash($wc_import_dir_cwd); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
591 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
592 |
# This anonymous subroutine finds all the files and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
593 |
# directories in the directory to load. It notes the file |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
594 |
# type and for each file found, it deletes it from |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
595 |
# %del_files. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
596 |
my $wanted = sub |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
597 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
598 |
s#^\./##; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
599 |
return if $_ eq '.'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
600 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
601 |
my $source_path = $_; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
602 |
my $dest_path = "$wc_import_dir_cwd/$_"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
603 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
604 |
my ($source_type) = &file_info($source_path); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
605 |
my ($dest_type) = &file_info($dest_path); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
606 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
607 |
# Fail if the destination type exists but is of a |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
608 |
# different type of file than the source type. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
609 |
if ($dest_type ne '0' and $source_type ne $dest_type) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
610 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
611 |
die "$0: does not handle changing source and destination ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
612 |
"type for '$source_path'.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
613 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
614 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
615 |
if ($source_type ne 'd' and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
616 |
$source_type ne 'f' and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
617 |
$source_type ne 'l') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
618 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
619 |
warn "$0: skipping loading file '$source_path' of type ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
620 |
"'$source_type'.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
621 |
unless ($opt_no_user_input) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
622 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
623 |
print STDERR "Press return to continue: "; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
624 |
<STDIN>; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
625 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
626 |
return; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
627 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
628 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
629 |
unless (defined delete $del_files{$source_path}) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
630 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
631 |
$add_files{$source_path}{type} = $source_type; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
632 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
633 |
}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
634 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
635 |
# Now change into the directory containing the files to |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
636 |
# load. First change to the original directory where this |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
637 |
# script was run so that if the specified directory is a |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
638 |
# relative directory path, then the script can change into |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
639 |
# it. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
640 |
chdir($orig_cwd) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
641 |
or die "$0: cannot chdir '$orig_cwd': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
642 |
chdir($load_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
643 |
or die "$0: cannot chdir '$load_dir': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
644 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
645 |
find({no_chdir => 1, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
646 |
preprocess => sub { sort { $b cmp $a } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
647 |
grep { $_ !~ /^[._]svn$/ } @_ }, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
648 |
wanted => $wanted |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
649 |
}, '.'); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
650 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
651 |
# At this point %add_files contains the list of new files |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
652 |
# and directories to be created in the working copy tree |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
653 |
# and %del_files contains the files and directories that |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
654 |
# need to be deleted. Because there may be renames that |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
655 |
# have taken place, give the user the opportunity to |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
656 |
# rename any deleted files and directories to ones being |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
657 |
# added. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
658 |
my @add_files = sort keys %add_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
659 |
my @del_files = sort keys %del_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
660 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
661 |
# Because the source code management system may keep the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
662 |
# original renamed file or directory in the working copy |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
663 |
# until a commit, remove them from the list of deleted |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
664 |
# files or directories. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
665 |
&filter_renamed_files(\@del_files, \%rename_from_files); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
666 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
667 |
# Now change into the working copy directory in case any |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
668 |
# renames need to be performed. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
669 |
chdir($wc_import_dir_cwd) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
670 |
or die "$0: cannot chdir '$wc_import_dir_cwd': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
671 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
672 |
# Only do renames if there are both added and deleted |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
673 |
# files and directories. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
674 |
if (@add_files and @del_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
675 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
676 |
my $max = @add_files > @del_files ? @add_files : @del_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
677 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
678 |
# Print the files that have been added and deleted. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
679 |
# Find the deleted file with the longest name and use |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
680 |
# that for the width of the filename column. Add one |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
681 |
# to the filename width to let the directory / |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
682 |
# character be appended to a directory name. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
683 |
my $line_number_width = 4; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
684 |
my $filename_width = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
685 |
foreach my $f (@del_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
686 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
687 |
my $l = length($f); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
688 |
$filename_width = $l if $l > $filename_width; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
689 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
690 |
++$filename_width; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
691 |
my $printf_format = "%${line_number_width}d"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
692 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
693 |
if ($print_rename_message) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
694 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
695 |
$print_rename_message = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
696 |
print "\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
697 |
"The following table lists files and directories that\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
698 |
"exist in either the Subversion repository or the\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
699 |
"directory to be imported but not both. You now have\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
700 |
"the opportunity to match them up as renames instead\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
701 |
"of deletes and adds. This is a Good Thing as it'll\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
702 |
"make the repository take less space.\n\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
703 |
"The left column lists files and directories that\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
704 |
"exist in the Subversion repository and do not exist\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
705 |
"in the directory being imported. The right column\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
706 |
"lists files and directories that exist in the\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
707 |
"directory being imported. Match up a deleted item\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
708 |
"from the left column with an added item from the\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
709 |
"right column. Note the line numbers on the left\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
710 |
"which you type into this script to have a rename\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
711 |
"performed.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
712 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
713 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
714 |
# Sort the added and deleted files and directories by |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
715 |
# the lowercase versions of their basenames instead of |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
716 |
# their complete path, which makes finding files that |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
717 |
# were moved into different directories easier to |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
718 |
# match up. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
719 |
@add_files = map { $_->[0] } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
720 |
sort { $a->[1] cmp $b->[1] } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
721 |
map { [$_->[0], lc($_->[1])] } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
722 |
map { [$_, m#([^/]+)$#] } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
723 |
@add_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
724 |
@del_files = map { $_->[0] } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
725 |
sort { $a->[1] cmp $b->[1] } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
726 |
map { [$_->[0], lc($_->[1])] } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
727 |
map { [$_, m#([^/]+)$#] } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
728 |
@del_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
729 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
730 |
RELIST: |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
731 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
732 |
for (my $i=0; $i<$max; ++$i) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
733 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
734 |
my $add_filename = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
735 |
my $del_filename = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
736 |
if ($i < @add_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
737 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
738 |
$add_filename = $add_files[$i]; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
739 |
if ($add_files{$add_filename}{type} eq 'd') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
740 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
741 |
$add_filename .= '/'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
742 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
743 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
744 |
if ($i < @del_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
745 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
746 |
$del_filename = $del_files[$i]; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
747 |
if ($del_files{$del_filename}{type} eq 'd') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
748 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
749 |
$del_filename .= '/'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
750 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
751 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
752 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
753 |
if ($i % 22 == 0) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
754 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
755 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
756 |
"\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
757 |
" " x $line_number_width, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
758 |
" ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
759 |
"Deleted", " " x ($filename_width-length("Deleted")), |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
760 |
" ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
761 |
"Added\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
762 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
763 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
764 |
printf $printf_format, $i; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
765 |
print " ", $del_filename, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
766 |
"_" x ($filename_width - length($del_filename)), |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
767 |
" ", $add_filename, "\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
768 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
769 |
if (($i+1) % 22 == 0) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
770 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
771 |
unless (&get_answer("Continue printing (Y/n)? ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
772 |
'ny', 1)) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
773 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
774 |
last; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
775 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
776 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
777 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
778 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
779 |
# Get the feedback from the user. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
780 |
my $line; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
781 |
my $add_filename; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
782 |
my $add_index; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
783 |
my $del_filename; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
784 |
my $del_index; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
785 |
my $got_line = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
786 |
do { |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
787 |
print "Enter two indexes for each column to rename, ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
788 |
"(R)elist, or (F)inish: "; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
789 |
$line = <STDIN>; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
790 |
$line = '' unless defined $line; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
791 |
if ($line =~ /^R$/i ) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
792 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
793 |
goto RELIST; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
794 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
795 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
796 |
if ($line =~ /^F$/i) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
797 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
798 |
$got_line = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
799 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
800 |
elsif ($line =~ /^(\d+)\s+(\d+)$/) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
801 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
802 |
print "\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
803 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
804 |
$del_index = $1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
805 |
$add_index = $2; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
806 |
if ($del_index >= @del_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
807 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
808 |
print "Delete index $del_index is larger than ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
809 |
"maximum index of ", scalar @del_files - 1, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
810 |
".\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
811 |
$del_index = undef; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
812 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
813 |
if ($add_index > @add_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
814 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
815 |
print "Add index $add_index is larger than maximum ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
816 |
"index of ", scalar @add_files - 1, ".\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
817 |
$add_index = undef; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
818 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
819 |
$got_line = defined $del_index && defined $add_index; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
820 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
821 |
# Check that the file or directory to be renamed |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
822 |
# has the same file type. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
823 |
if ($got_line) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
824 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
825 |
$add_filename = $add_files[$add_index]; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
826 |
$del_filename = $del_files[$del_index]; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
827 |
if ($add_files{$add_filename}{type} ne |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
828 |
$del_files{$del_filename}{type}) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
829 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
830 |
print "File types for $del_filename and ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
831 |
"$add_filename differ.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
832 |
$got_line = undef; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
833 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
834 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
835 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
836 |
} until ($got_line); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
837 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
838 |
if ($line !~ /^F$/i) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
839 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
840 |
print "Renaming $del_filename to $add_filename.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
841 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
842 |
$repeat_loop = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
843 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
844 |
# Because subversion cannot rename the same file |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
845 |
# or directory twice, which includes doing a |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
846 |
# rename of a file in a directory that was |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
847 |
# previously renamed, a commit has to be |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
848 |
# performed. Check if the file or directory being |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
849 |
# renamed now would cause such a problem and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
850 |
# commit if so. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
851 |
my $do_commit_now = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
852 |
foreach my $rename_to_filename (keys %rename_to_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
853 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
854 |
if (contained_in($del_filename, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
855 |
$rename_to_filename, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
856 |
$rename_to_files{$rename_to_filename}{type})) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
857 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
858 |
$do_commit_now = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
859 |
last; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
860 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
861 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
862 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
863 |
if ($do_commit_now) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
864 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
865 |
print "Now committing previously run renames.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
866 |
&commit_renames($load_dir, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
867 |
\@renamed_filenames, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
868 |
\%rename_from_files, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
869 |
\%rename_to_files); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
870 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
871 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
872 |
push(@renamed_filenames, $del_filename, $add_filename); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
873 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
874 |
my $d = $del_files{$del_filename}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
875 |
$rename_from_files{$del_filename} = $d; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
876 |
$rename_to_files{$add_filename} = $d; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
877 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
878 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
879 |
# Check that any required directories to do the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
880 |
# rename exist. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
881 |
my @add_segments = split('/', $add_filename); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
882 |
pop(@add_segments); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
883 |
my $add_dir = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
884 |
my @add_dirs; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
885 |
foreach my $segment (@add_segments) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
886 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
887 |
$add_dir = length($add_dir) ? "$add_dir/$segment" : |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
888 |
$segment; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
889 |
unless (-d $add_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
890 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
891 |
push(@add_dirs, $add_dir); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
892 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
893 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
894 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
895 |
if (@add_dirs) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
896 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
897 |
read_from_process($svn, 'mkdir', @add_dirs); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
898 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
899 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
900 |
read_from_process($svn, 'mv', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
901 |
$del_filename, $add_filename); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
902 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
903 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
904 |
} while ($repeat_loop); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
905 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
906 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
907 |
# If there are any renames that have not been committed, then do |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
908 |
# that now. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
909 |
if (@renamed_filenames) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
910 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
911 |
&commit_renames($load_dir, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
912 |
\@renamed_filenames, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
913 |
\%rename_from_files, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
914 |
\%rename_to_files); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
915 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
916 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
917 |
# At this point all renames have been performed. Now get the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
918 |
# final list of files and directories in the working copy |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
919 |
# directory. The %add_files hash will contain the list of files |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
920 |
# and directories to add to the working copy and %del_files starts |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
921 |
# with all the files already in the working copy and gets files |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
922 |
# removed that are in the imported directory, which results in a |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
923 |
# list of files that should be deleted. %upd_files holds the list |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
924 |
# of files that have been updated. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
925 |
my %add_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
926 |
my %del_files = &recursive_ls_and_hash($wc_import_dir_cwd); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
927 |
my %upd_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
928 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
929 |
# This anonymous subroutine copies files from the source directory |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
930 |
# to the working copy directory. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
931 |
my $wanted = sub |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
932 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
933 |
s#^\./##; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
934 |
return if $_ eq '.'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
935 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
936 |
my $source_path = $_; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
937 |
my $dest_path = "$wc_import_dir_cwd/$_"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
938 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
939 |
my ($source_type, $source_is_exe) = &file_info($source_path); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
940 |
my ($dest_type) = &file_info($dest_path); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
941 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
942 |
return if ($source_type ne 'd' and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
943 |
$source_type ne 'f' and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
944 |
$source_type ne 'l'); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
945 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
946 |
# Fail if the destination type exists but is of a different |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
947 |
# type of file than the source type. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
948 |
if ($dest_type ne '0' and $source_type ne $dest_type) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
949 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
950 |
die "$0: does not handle changing source and destination type ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
951 |
"for '$source_path'.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
952 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
953 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
954 |
# Determine if the file is being added or is an update to an |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
955 |
# already existing file using the file's digest. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
956 |
my $del_info = delete $del_files{$source_path}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
957 |
if (defined $del_info) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
958 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
959 |
if (defined (my $del_digest = $del_info->{digest})) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
960 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
961 |
my $new_digest = &digest_hash_file($source_path); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
962 |
if ($new_digest ne $del_digest) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
963 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
964 |
print "U $source_path\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
965 |
$upd_files{$source_path} = $del_info; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
966 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
967 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
968 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
969 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
970 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
971 |
print "A $source_path\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
972 |
$add_files{$source_path}{type} = $source_type; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
973 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
974 |
# Create an array reference to hold the list of properties |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
975 |
# to apply to this object. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
976 |
unless (defined $add_files{$source_path}{properties}) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
977 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
978 |
$add_files{$source_path}{properties} = []; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
979 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
980 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
981 |
# Go through the list of properties for a match on this |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
982 |
# file or directory and if there is a match, then apply |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
983 |
# the property to it. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
984 |
foreach my $property (@property_settings) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
985 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
986 |
my $re = $property->{re}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
987 |
if ($source_path =~ $re) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
988 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
989 |
my $property_name = $property->{name}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
990 |
my $property_value = $property->{value}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
991 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
992 |
# The property value may not be set in the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
993 |
# configuration file, since the user may just want |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
994 |
# to set the control flag. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
995 |
if (defined $property_name and defined $property_value) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
996 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
997 |
# Ignore properties that do not apply to |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
998 |
# directories. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
999 |
if ($source_type eq 'd') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1000 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1001 |
if ($property_name eq 'svn:eol-style' or |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1002 |
$property_name eq 'svn:executable' or |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1003 |
$property_name eq 'svn:keywords' or |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1004 |
$property_name eq 'svn:mime-type') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1005 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1006 |
next; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1007 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1008 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1009 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1010 |
# Ignore properties that do not apply to |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1011 |
# files. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1012 |
if ($source_type eq 'f') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1013 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1014 |
if ($property_name eq 'svn:externals' or |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1015 |
$property_name eq 'svn:ignore') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1016 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1017 |
next; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1018 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1019 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1020 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1021 |
print "Adding to '$source_path' property ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1022 |
"'$property_name' with value ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1023 |
"'$property_value'.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1024 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1025 |
push(@{$add_files{$source_path}{properties}}, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1026 |
$property); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1027 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1028 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1029 |
last if $property->{control} eq 'break'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1030 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1031 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1032 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1033 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1034 |
# Add svn:executable to files that have their executable bit |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1035 |
# set. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1036 |
if ($source_is_exe and !$opt_no_auto_exe) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1037 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1038 |
print "Adding to '$source_path' property 'svn:executable' with ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1039 |
"value '*'.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1040 |
my $property = {name => 'svn:executable', value => '*'}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1041 |
push (@{$add_files{$source_path}{properties}}, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1042 |
$property); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1043 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1044 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1045 |
# Now make sure the file or directory in the source directory |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1046 |
# exists in the repository. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1047 |
if ($source_type eq 'd') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1048 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1049 |
if ($dest_type eq '0') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1050 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1051 |
mkdir($dest_path) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1052 |
or die "$0: cannot mkdir '$dest_path': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1053 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1054 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1055 |
elsif |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1056 |
($source_type eq 'l') { |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1057 |
my $link_target = readlink($source_path) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1058 |
or die "$0: cannot readlink '$source_path': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1059 |
if ($dest_type eq 'l') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1060 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1061 |
my $old_target = readlink($dest_path) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1062 |
or die "$0: cannot readlink '$dest_path': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1063 |
return if ($old_target eq $link_target); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1064 |
unlink($dest_path) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1065 |
or die "$0: unlink '$dest_path' failed: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1066 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1067 |
symlink($link_target, $dest_path) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1068 |
or die "$0: cannot symlink '$dest_path' to '$link_target': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1069 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1070 |
elsif |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1071 |
($source_type eq 'f') { |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1072 |
# Only copy the file if the digests do not match. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1073 |
if ($add_files{$source_path} or $upd_files{$source_path}) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1074 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1075 |
copy($source_path, $dest_path) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1076 |
or die "$0: copy '$source_path' to '$dest_path': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1077 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1078 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1079 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1080 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1081 |
die "$0: does not handle copying files of type '$source_type'.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1082 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1083 |
}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1084 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1085 |
# Now change into the directory containing the files to load. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1086 |
# First change to the original directory where this script was run |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1087 |
# so that if the specified directory is a relative directory path, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1088 |
# then the script can change into it. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1089 |
chdir($orig_cwd) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1090 |
or die "$0: cannot chdir '$orig_cwd': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1091 |
chdir($load_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1092 |
or die "$0: cannot chdir '$load_dir': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1093 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1094 |
find({no_chdir => 1, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1095 |
preprocess => sub { sort { $b cmp $a } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1096 |
grep { $_ !~ /^[._]svn$/ } @_ }, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1097 |
wanted => $wanted |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1098 |
}, '.'); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1099 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1100 |
# The files and directories that are in %del_files are the files |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1101 |
# and directories that need to be deleted. Because svn will |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1102 |
# return an error if a file or directory is deleted in a directory |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1103 |
# that subsequently is deleted, first find all directories and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1104 |
# remove from the list any files and directories inside those |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1105 |
# directories from this list. Work through the list repeatedly |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1106 |
# working from short to long names so that directories containing |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1107 |
# other files and directories will be deleted first. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1108 |
my $repeat_loop; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1109 |
do |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1110 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1111 |
$repeat_loop = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1112 |
my @del_files = sort {length($a) <=> length($b) || $a cmp $b} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1113 |
keys %del_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1114 |
&filter_renamed_files(\@del_files, \%rename_from_files); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1115 |
foreach my $file (@del_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1116 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1117 |
if ($del_files{$file}{type} eq 'd') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1118 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1119 |
my $dir = "$file/"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1120 |
my $dir_length = length($dir); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1121 |
foreach my $f (@del_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1122 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1123 |
next if $file eq $f; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1124 |
if (length($f) >= $dir_length and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1125 |
substr($f, 0, $dir_length) eq $dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1126 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1127 |
print "d $f\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1128 |
delete $del_files{$f}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1129 |
$repeat_loop = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1130 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1131 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1132 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1133 |
# If there were any deletions of files and/or |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1134 |
# directories inside a directory that will be deleted, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1135 |
# then restart the entire loop again, because one or |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1136 |
# more keys have been deleted from %del_files. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1137 |
# Equally important is not to stop this loop if no |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1138 |
# deletions have been done, otherwise later |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1139 |
# directories that may contain files and directories |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1140 |
# to be deleted will not be deleted. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1141 |
last if $repeat_loop; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1142 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1143 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1144 |
} while ($repeat_loop); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1145 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1146 |
# What is left are files that are not in any directories to be |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1147 |
# deleted and directories to be deleted. To delete the files, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1148 |
# deeper files and directories must be deleted first. Because we |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1149 |
# have a hash keyed by remaining files and directories to be |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1150 |
# deleted, instead of trying to figure out which directories and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1151 |
# files are contained in other directories, just reverse sort by |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1152 |
# the path length and then alphabetically. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1153 |
my @del_files = sort {length($b) <=> length($a) || $a cmp $b } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1154 |
keys %del_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1155 |
&filter_renamed_files(\@del_files, \%rename_from_files); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1156 |
foreach my $file (@del_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1157 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1158 |
print "D $file\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1159 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1160 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1161 |
# Now change back to the trunk directory and run the svn commands. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1162 |
chdir($wc_import_dir_cwd) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1163 |
or die "$0: cannot chdir '$wc_import_dir_cwd': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1164 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1165 |
# If any of the added files have the svn:eol-style property set, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1166 |
# then pass -b to diff, otherwise diff may fail because the end of |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1167 |
# lines have changed and the source file and file in the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1168 |
# repository will not be identical. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1169 |
my @diff_ignore_space_changes; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1170 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1171 |
if (keys %add_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1172 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1173 |
my @add_files = sort {length($a) <=> length($b) || $a cmp $b} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1174 |
keys %add_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1175 |
my $target_filename = &make_targets_file(@add_files); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1176 |
read_from_process($svn, 'add', '-N', '--targets', $target_filename); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1177 |
unlink($target_filename); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1178 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1179 |
# Add properties on the added files. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1180 |
foreach my $add_file (@add_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1181 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1182 |
foreach my $property (@{$add_files{$add_file}{properties}}) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1183 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1184 |
my $property_name = $property->{name}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1185 |
my $property_value = $property->{value}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1186 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1187 |
if ($property_name eq 'svn:eol-style') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1188 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1189 |
@diff_ignore_space_changes = ('-b'); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1190 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1191 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1192 |
# Write the value to a temporary file in case it's multi-line |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1193 |
my ($handle, $tmpfile) = tempfile(DIR => $temp_dir); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1194 |
print $handle $property_value; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1195 |
close($handle); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1196 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1197 |
read_from_process($svn, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1198 |
'propset', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1199 |
$property_name, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1200 |
'--file', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1201 |
$tmpfile, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1202 |
$add_file); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1203 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1204 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1205 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1206 |
if (@del_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1207 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1208 |
my $target_filename = &make_targets_file(@del_files); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1209 |
read_from_process($svn, 'rm', '--targets', $target_filename); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1210 |
unlink($target_filename); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1211 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1212 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1213 |
# Go through the list of updated files and check the svn:eol-style |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1214 |
# property. If it is set to native, then convert all CR, CRLF and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1215 |
# LF's in the file to the native end of line characters. Also, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1216 |
# modify diff's command line so that it will ignore the change in |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1217 |
# end of line style. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1218 |
if (keys %upd_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1219 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1220 |
my @upd_files = sort {length($a) <=> length($b) || $a cmp $b} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1221 |
keys %upd_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1222 |
foreach my $upd_file (@upd_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1223 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1224 |
# Always append @BASE to a filename in case they contain a |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1225 |
# @ character, in which case the Subversion command line |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1226 |
# client will attempt to parse the characters after the @ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1227 |
# as a revision and most likely fail, or if the characters |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1228 |
# after the @ are a valid revision, then it'll possibly |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1229 |
# get the incorrect information. So always append @BASE |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1230 |
# and any preceding @'s will be treated normally and the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1231 |
# correct information will be retrieved. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1232 |
my @command = ($svn, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1233 |
'propget', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1234 |
'svn:eol-style', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1235 |
"$upd_file\@BASE"); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1236 |
my @lines = read_from_process(@command); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1237 |
next unless @lines; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1238 |
if (@lines > 1) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1239 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1240 |
warn "$0: '@command' returned more than one line of output: ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1241 |
"'@lines'.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1242 |
next; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1243 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1244 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1245 |
my $eol_style = $lines[0]; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1246 |
if ($eol_style eq 'native') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1247 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1248 |
@diff_ignore_space_changes = ('-b'); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1249 |
if (&convert_file_to_native_eol($upd_file)) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1250 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1251 |
print "Native eol-style conversion modified $upd_file.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1252 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1253 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1254 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1255 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1256 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1257 |
my $message = wrap('', '', "Load $load_dir into $repos_load_abs_path.\n"); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1258 |
read_from_process($svn, 'commit', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1259 |
@svn_use_repos_cmd_opts, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1260 |
'-m', $message); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1261 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1262 |
# If an update is not run now after a commit, then some file and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1263 |
# directory paths will have an older revisions associated with |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1264 |
# them and any future commits will fail because they are out of |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1265 |
# date. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1266 |
read_from_process($svn, 'update', @svn_use_repos_cmd_opts); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1267 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1268 |
# Now remove any files and directories to be deleted in the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1269 |
# repository. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1270 |
if (@del_files) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1271 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1272 |
rmtree(\@del_files, 1, 0); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1273 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1274 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1275 |
# Now make the tag by doing a copy in the svn repository itself. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1276 |
if (defined $load_tag) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1277 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1278 |
my $repos_tag_abs_path = length($repos_base_path_segment) ? |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1279 |
"$repos_base_path_segment/$load_tag" : |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1280 |
$load_tag; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1281 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1282 |
my $from_url = $repos_load_rel_path eq '.' ? |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1283 |
$repos_load_rel_path : |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1284 |
"$repos_base_url/$repos_load_rel_path"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1285 |
my $to_url = "$repos_base_url/$load_tag"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1286 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1287 |
$message = wrap("", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1288 |
"", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1289 |
"Tag $repos_load_abs_path as " . |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1290 |
"$repos_tag_abs_path.\n"); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1291 |
read_from_process($svn, 'cp', @svn_use_repos_cmd_opts, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1292 |
'-m', $message, $from_url, $to_url); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1293 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1294 |
# Now check out the tag and run a recursive diff between the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1295 |
# original source directory and the tag for a consistency |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1296 |
# check. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1297 |
my $checkout_dir_name = "my_tag_wc_named_$load_tag"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1298 |
print "Checking out $to_url into $temp_dir/$checkout_dir_name\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1299 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1300 |
chdir($temp_dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1301 |
or die "$0: cannot chdir '$temp_dir': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1302 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1303 |
read_from_process($svn, 'checkout', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1304 |
@svn_use_repos_cmd_opts, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1305 |
$to_url, $checkout_dir_name); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1306 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1307 |
chdir($checkout_dir_name) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1308 |
or die "$0: cannot chdir '$checkout_dir_name': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1309 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1310 |
chdir($orig_cwd) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1311 |
or die "$0: cannot chdir '$orig_cwd': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1312 |
read_from_process('diff', '-u', @diff_ignore_space_changes, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1313 |
'-x', '.svn', |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1314 |
'-r', $load_dir, "$temp_dir/$checkout_dir_name"); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1315 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1316 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1317 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1318 |
exit 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1319 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1320 |
sub usage |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1321 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1322 |
warn "@_\n" if @_; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1323 |
die "usage: $0 [options] svn_url svn_import_dir [dir_v1 [dir_v2 [..]]]\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1324 |
" svn_url is the file:// or http:// URL of the svn repository\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1325 |
" svn_import_dir is the path relative to svn_url where to load dirs\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1326 |
" dir_v1 .. list dirs to import otherwise read from stdin\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1327 |
"options are\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1328 |
" -no_user_input don't ask yes/no questions and assume yes answer\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1329 |
" -no_auto_exe don't set svn:executable for executable files\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1330 |
" -p filename table listing properties to apply to matching files\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1331 |
" -svn_username username to perform commits as\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1332 |
" -svn_password password to supply to svn commit\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1333 |
" -t tag_dir create a tag copy in tag_dir, relative to svn_url\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1334 |
" -v increase program verbosity, multiple -v's allowed\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1335 |
" -wc path use the already checked-out working copy at path\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1336 |
" instead of checkout out a fresh working copy\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1337 |
" -glob_ignores List of filename patterns to ignore (as in svn's\n", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1338 |
" global-ignores config option)\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1339 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1340 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1341 |
# Get the next directory to load, either from the command line or from |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1342 |
# standard input. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1343 |
my $get_next_load_dir_init = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1344 |
my @get_next_load_dirs; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1345 |
sub get_next_load_dir |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1346 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1347 |
if (@ARGV) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1348 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1349 |
unless ($get_next_load_dir_init) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1350 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1351 |
$get_next_load_dir_init = 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1352 |
@get_next_load_dirs = @ARGV; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1353 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1354 |
return shift @get_next_load_dirs; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1355 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1356 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1357 |
if ($opt_verbose) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1358 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1359 |
print "Waiting for next directory to import on standard input:\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1360 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1361 |
my $line = <STDIN>; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1362 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1363 |
print "\n" if $opt_verbose; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1364 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1365 |
chomp $line; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1366 |
if ($line =~ m|(\S+)\s+(\S+)|) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1367 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1368 |
$line = $1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1369 |
set_svn_use_repos_cmd_opts($2, $opt_svn_password); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1370 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1371 |
$line; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1372 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1373 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1374 |
# This constant stores the commonly used string to indicate that a |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1375 |
# subroutine has been passed an incorrect number of arguments. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1376 |
use vars qw($INCORRECT_NUMBER_OF_ARGS); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1377 |
$INCORRECT_NUMBER_OF_ARGS = "passed incorrect number of arguments.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1378 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1379 |
# Creates a temporary file in the temporary directory and stores the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1380 |
# arguments in it for use by the svn --targets command line option. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1381 |
# If any part of the file creation failed, exit the program, as |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1382 |
# there's no workaround. Use a unique number as a counter to the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1383 |
# files. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1384 |
my $make_targets_file_counter; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1385 |
sub make_targets_file |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1386 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1387 |
unless (@_) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1388 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1389 |
confess "$0: make_targets_file $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1390 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1391 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1392 |
$make_targets_file_counter = 1 unless defined $make_targets_file_counter; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1393 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1394 |
my $filename = sprintf "%s/targets.%05d", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1395 |
$temp_dir, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1396 |
$make_targets_file_counter; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1397 |
++$make_targets_file_counter; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1398 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1399 |
open(TARGETS, ">$filename") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1400 |
or die "$0: cannot open '$filename' for writing: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1401 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1402 |
foreach my $file (@_) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1403 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1404 |
print TARGETS "$file\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1405 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1406 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1407 |
close(TARGETS) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1408 |
or die "$0: error in closing '$filename' for writing: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1409 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1410 |
$filename; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1411 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1412 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1413 |
# Set the svn command line options that are used anytime svn connects |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1414 |
# to the repository. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1415 |
sub set_svn_use_repos_cmd_opts |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1416 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1417 |
unless (@_ == 2) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1418 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1419 |
confess "$0: set_svn_use_repos_cmd_opts $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1420 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1421 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1422 |
my $username = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1423 |
my $password = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1424 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1425 |
@svn_use_repos_cmd_opts = ('--non-interactive'); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1426 |
if (defined $username and length $username) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1427 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1428 |
push(@svn_use_repos_cmd_opts, '--username', $username); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1429 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1430 |
if (defined $password) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1431 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1432 |
push(@svn_use_repos_cmd_opts, '--password', $password); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1433 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1434 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1435 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1436 |
sub get_tag_dir |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1437 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1438 |
unless (@_ == 1) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1439 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1440 |
confess "$0: get_tag_dir $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1441 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1442 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1443 |
my $load_dir = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1444 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1445 |
# Take the tag relative directory, search for pairs of |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1446 |
# REGEX_SEP_CHAR's and use the regular expression inside the pair to |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1447 |
# put in the tag directory name. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1448 |
my $tag_location = $opt_import_tag_location; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1449 |
my $load_tag = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1450 |
while ((my $i = index($tag_location, $REGEX_SEP_CHAR)) >= 0) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1451 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1452 |
$load_tag .= substr($tag_location, 0, $i, ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1453 |
substr($tag_location, 0, 1, ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1454 |
my $j = index($tag_location, $REGEX_SEP_CHAR); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1455 |
if ($j < 0) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1456 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1457 |
die "$0: -t value '$opt_import_tag_location' does not have ", |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1458 |
"matching $REGEX_SEP_CHAR.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1459 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1460 |
my $regex = substr($tag_location, 0, $j, ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1461 |
$regex = "($regex)" unless ($regex =~ /\(.+\)/); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1462 |
substr($tag_location, 0, 1, ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1463 |
my @results = $load_dir =~ m/$regex/; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1464 |
$load_tag .= join('', @results); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1465 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1466 |
$load_tag .= $tag_location; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1467 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1468 |
$load_tag; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1469 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1470 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1471 |
# Return a two element array. The first element is a single character |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1472 |
# that represents the type of object the path points to. The second |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1473 |
# is a boolean (1 for true, '' for false) if the path points to a file |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1474 |
# and if the file is executable. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1475 |
sub file_info |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1476 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1477 |
lstat(shift) or return ('0', ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1478 |
-b _ and return ('b', ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1479 |
-c _ and return ('c', ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1480 |
-d _ and return ('d', ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1481 |
-f _ and return ('f', -x _); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1482 |
-l _ and return ('l', ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1483 |
-p _ and return ('p', ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1484 |
-S _ and return ('S', ''); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1485 |
return '?'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1486 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1487 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1488 |
# Start a child process safely without using /bin/sh. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1489 |
sub safe_read_from_pipe |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1490 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1491 |
unless (@_) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1492 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1493 |
croak "$0: safe_read_from_pipe $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1494 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1495 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1496 |
my $openfork_available = "MSWin32" ne $OSNAME; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1497 |
if ($openfork_available) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1498 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1499 |
print "Running @_\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1500 |
my $pid = open(SAFE_READ, "-|"); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1501 |
unless (defined $pid) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1502 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1503 |
die "$0: cannot fork: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1504 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1505 |
unless ($pid) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1506 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1507 |
# child |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1508 |
open(STDERR, ">&STDOUT") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1509 |
or die "$0: cannot dup STDOUT: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1510 |
exec(@_) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1511 |
or die "$0: cannot exec '@_': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1512 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1513 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1514 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1515 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1516 |
# Redirect the comment into a temp file and use that to work around |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1517 |
# Windoze's (non-)handling of multi-line commands. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1518 |
my @commandline = (); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1519 |
my $command; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1520 |
my $comment; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1521 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1522 |
while ($command = shift) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1523 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1524 |
if ("-m" eq $command) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1525 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1526 |
my $comment = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1527 |
my ($handle, $tmpfile) = tempfile(DIR => $temp_dir); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1528 |
print $handle $comment; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1529 |
close($handle); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1530 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1531 |
push(@commandline, "--file"); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1532 |
push(@commandline, $tmpfile); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1533 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1534 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1535 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1536 |
# Munge the command to protect it from the command line |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1537 |
$command =~ s/\"/\\\"/g; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1538 |
if ($command =~ m"\s") { $command = "\"$command\""; } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1539 |
if ($command eq "") { $command = "\"\""; } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1540 |
if ($command =~ m"\n") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1541 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1542 |
warn "$0: carriage return detected in command - may not work\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1543 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1544 |
push(@commandline, $command); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1545 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1546 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1547 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1548 |
print "Running @commandline\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1549 |
if ( $comment ) { print $comment; } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1550 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1551 |
# Now do the pipe. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1552 |
open(SAFE_READ, "@commandline |") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1553 |
or die "$0: cannot pipe to command: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1554 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1555 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1556 |
# parent |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1557 |
my @output; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1558 |
while (<SAFE_READ>) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1559 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1560 |
chomp; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1561 |
push(@output, $_); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1562 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1563 |
close(SAFE_READ); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1564 |
my $result = $?; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1565 |
my $exit = $result >> 8; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1566 |
my $signal = $result & 127; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1567 |
my $cd = $result & 128 ? "with core dump" : ""; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1568 |
if ($signal or $cd) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1569 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1570 |
warn "$0: pipe from '@_' failed $cd: exit=$exit signal=$signal\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1571 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1572 |
if (wantarray) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1573 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1574 |
return ($result, @output); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1575 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1576 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1577 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1578 |
return $result; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1579 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1580 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1581 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1582 |
# Use safe_read_from_pipe to start a child process safely and exit the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1583 |
# script if the child failed for whatever reason. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1584 |
sub read_from_process |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1585 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1586 |
unless (@_) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1587 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1588 |
croak "$0: read_from_process $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1589 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1590 |
my ($status, @output) = &safe_read_from_pipe(@_); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1591 |
if ($status) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1592 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1593 |
print STDERR "$0: @_ failed with this output:\n", join("\n", @output), |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1594 |
"\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1595 |
unless ($opt_no_user_input) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1596 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1597 |
print STDERR |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1598 |
"Press return to quit and clean up svn working directory: "; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1599 |
<STDIN>; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1600 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1601 |
exit 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1602 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1603 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1604 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1605 |
return @output; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1606 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1607 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1608 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1609 |
# Get a list of all the files and directories in the specified |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1610 |
# directory, the type of file and a digest hash of file types. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1611 |
sub recursive_ls_and_hash |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1612 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1613 |
unless (@_ == 1) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1614 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1615 |
croak "$0: recursive_ls_and_hash $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1616 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1617 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1618 |
# This is the directory to change into. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1619 |
my $dir = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1620 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1621 |
# Get the current directory so that the script can change into the |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1622 |
# current working directory after changing into the specified |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1623 |
# directory. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1624 |
my $return_cwd = cwd; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1625 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1626 |
chdir($dir) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1627 |
or die "$0: cannot chdir '$dir': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1628 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1629 |
my %files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1630 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1631 |
my $wanted = sub |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1632 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1633 |
s#^\./##; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1634 |
return if $_ eq '.'; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1635 |
my ($file_type) = &file_info($_); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1636 |
my $file_digest; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1637 |
if ($file_type eq 'f' or ($file_type eq 'l' and stat($_) and -f _)) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1638 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1639 |
$file_digest = &digest_hash_file($_); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1640 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1641 |
$files{$_} = {type => $file_type, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1642 |
digest => $file_digest}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1643 |
}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1644 |
find({no_chdir => 1, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1645 |
preprocess => sub |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1646 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1647 |
grep |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1648 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1649 |
my $ok=1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1650 |
foreach my $x (@glob_ignores) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1651 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1652 |
if ( $_ =~ /$x/ ) {$ok=0;last;} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1653 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1654 |
$ok |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1655 |
} @_ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1656 |
}, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1657 |
wanted => $wanted |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1658 |
}, '.'); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1659 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1660 |
chdir($return_cwd) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1661 |
or die "$0: cannot chdir '$return_cwd': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1662 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1663 |
%files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1664 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1665 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1666 |
# Given a list of files and directories which have been renamed but |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1667 |
# not commtited, commit them with a proper log message. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1668 |
sub commit_renames |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1669 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1670 |
unless (@_ == 4) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1671 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1672 |
croak "$0: commit_renames $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1673 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1674 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1675 |
my $load_dir = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1676 |
my $renamed_filenames = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1677 |
my $rename_from_files = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1678 |
my $rename_to_files = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1679 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1680 |
my $number_renames = @$renamed_filenames/2; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1681 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1682 |
my $message = "To prepare to load $load_dir into $repos_load_abs_path, " . |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1683 |
"perform $number_renames rename" . |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1684 |
($number_renames > 1 ? "s" : "") . ".\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1685 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1686 |
# Text::Wrap::wrap appears to replace multiple consecutive \n's with |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1687 |
# one \n, so wrap the text and then append the second \n. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1688 |
$message = wrap("", "", $message) . "\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1689 |
while (@$renamed_filenames) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1690 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1691 |
my $from = "$repos_load_abs_path/" . shift @$renamed_filenames; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1692 |
my $to = "$repos_load_abs_path/" . shift @$renamed_filenames; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1693 |
$message .= wrap("", " ", "* $to: Renamed from $from.\n"); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1694 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1695 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1696 |
# Change to the top of the working copy so that any |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1697 |
# directories will also be updated. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1698 |
my $cwd = cwd; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1699 |
chdir($wc_import_dir_cwd) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1700 |
or die "$0: cannot chdir '$wc_import_dir_cwd': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1701 |
read_from_process($svn, 'commit', @svn_use_repos_cmd_opts, '-m', $message); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1702 |
read_from_process($svn, 'update', @svn_use_repos_cmd_opts); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1703 |
chdir($cwd) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1704 |
or die "$0: cannot chdir '$cwd': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1705 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1706 |
# Some versions of subversion have a bug where renamed files |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1707 |
# or directories are not deleted after a commit, so do that |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1708 |
# here. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1709 |
my @del_files = sort {length($b) <=> length($a) || $a cmp $b } |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1710 |
keys %$rename_from_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1711 |
rmtree(\@del_files, 1, 0); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1712 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1713 |
# Empty the list of old and new renamed names. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1714 |
undef %$rename_from_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1715 |
undef %$rename_to_files; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1716 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1717 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1718 |
# Take a one file or directory and see if its name is equal to a |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1719 |
# second or is contained in the second if the second file's file type |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1720 |
# is a directory. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1721 |
sub contained_in |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1722 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1723 |
unless (@_ == 3) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1724 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1725 |
croak "$0: contain_in $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1726 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1727 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1728 |
my $contained = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1729 |
my $container = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1730 |
my $container_type = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1731 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1732 |
if ($container eq $contained) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1733 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1734 |
return 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1735 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1736 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1737 |
if ($container_type eq 'd') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1738 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1739 |
my $dirname = "$container/"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1740 |
my $dirname_length = length($dirname); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1741 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1742 |
if ($dirname_length <= length($contained) and |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1743 |
$dirname eq substr($contained, 0, $dirname_length)) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1744 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1745 |
return 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1746 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1747 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1748 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1749 |
return 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1750 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1751 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1752 |
# Take an array reference containing a list of files and directories |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1753 |
# and take a hash reference and remove from the array reference any |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1754 |
# files and directories and the files the directory contains listed in |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1755 |
# the hash. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1756 |
sub filter_renamed_files |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1757 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1758 |
unless (@_ == 2) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1759 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1760 |
croak "$0: filter_renamed_files $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1761 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1762 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1763 |
my $array_ref = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1764 |
my $hash_ref = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1765 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1766 |
foreach my $remove_filename (keys %$hash_ref) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1767 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1768 |
my $remove_file_type = $hash_ref->{$remove_filename}{type}; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1769 |
for (my $i=0; $i<@$array_ref;) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1770 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1771 |
if (contained_in($array_ref->[$i], |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1772 |
$remove_filename, |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1773 |
$remove_file_type)) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1774 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1775 |
splice(@$array_ref, $i, 1); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1776 |
next; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1777 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1778 |
++$i; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1779 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1780 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1781 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1782 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1783 |
# Get a digest hash of the specified filename. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1784 |
sub digest_hash_file |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1785 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1786 |
unless (@_ == 1) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1787 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1788 |
croak "$0: digest_hash_file $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1789 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1790 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1791 |
my $filename = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1792 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1793 |
my $ctx = Digest::MD5->new; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1794 |
if (open(READ, $filename)) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1795 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1796 |
binmode READ; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1797 |
$ctx->addfile(*READ); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1798 |
close(READ); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1799 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1800 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1801 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1802 |
die "$0: cannot open '$filename' for reading: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1803 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1804 |
$ctx->digest; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1805 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1806 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1807 |
# Read standard input until a line contains the required input or an |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1808 |
# empty line to signify the default answer. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1809 |
sub get_answer |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1810 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1811 |
unless (@_ == 3) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1812 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1813 |
croak "$0: get_answer $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1814 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1815 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1816 |
my $message = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1817 |
my $answers = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1818 |
my $def_ans = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1819 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1820 |
return $def_ans if $opt_no_user_input; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1821 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1822 |
my $char; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1823 |
do |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1824 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1825 |
print $message; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1826 |
$char = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1827 |
my $line = <STDIN>; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1828 |
if (defined $line and length $line) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1829 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1830 |
$char = substr($line, 0, 1); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1831 |
$char = '' if $char eq "\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1832 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1833 |
} until $char eq '' or $answers =~ /$char/ig; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1834 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1835 |
return $def_ans if $char eq ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1836 |
return pos($answers) - 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1837 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1838 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1839 |
# Determine the native end of line on this system by writing a \n in |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1840 |
# non-binary mode to an empty file and reading the same file back in |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1841 |
# binary mode. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1842 |
sub determine_native_eol |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1843 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1844 |
my $filename = "$temp_dir/svn_load_dirs_eol_test.$$"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1845 |
if (-e $filename) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1846 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1847 |
unlink($filename) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1848 |
or die "$0: cannot unlink '$filename': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1849 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1850 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1851 |
# Write the \n in non-binary mode. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1852 |
open(NL_TEST, ">$filename") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1853 |
or die "$0: cannot open '$filename' for writing: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1854 |
print NL_TEST "\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1855 |
close(NL_TEST) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1856 |
or die "$0: error in closing '$filename' for writing: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1857 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1858 |
# Read the \n in binary mode. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1859 |
open(NL_TEST, $filename) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1860 |
or die "$0: cannot open '$filename' for reading: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1861 |
binmode NL_TEST; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1862 |
local $/; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1863 |
undef $/; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1864 |
my $eol = <NL_TEST>; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1865 |
close(NL_TEST) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1866 |
or die "$0: cannot close '$filename' for reading: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1867 |
unlink($filename) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1868 |
or die "$0: cannot unlink '$filename': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1869 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1870 |
my $eol_length = length($eol); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1871 |
unless ($eol_length) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1872 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1873 |
die "$0: native eol length on this system is 0.\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1874 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1875 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1876 |
print "Native EOL on this system is "; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1877 |
for (my $i=0; $i<$eol_length; ++$i) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1878 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1879 |
printf "\\%03o", ord(substr($eol, $i, 1)); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1880 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1881 |
print ".\n\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1882 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1883 |
$eol; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1884 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1885 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1886 |
# Take a filename, open the file and replace all CR, CRLF and LF's |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1887 |
# with the native end of line style for this system. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1888 |
sub convert_file_to_native_eol |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1889 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1890 |
unless (@_ == 1) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1891 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1892 |
croak "$0: convert_file_to_native_eol $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1893 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1894 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1895 |
my $filename = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1896 |
open(FILE, $filename) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1897 |
or die "$0: cannot open '$filename' for reading: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1898 |
binmode FILE; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1899 |
local $/; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1900 |
undef $/; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1901 |
my $in = <FILE>; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1902 |
close(FILE) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1903 |
or die "$0: error in closing '$filename' for reading: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1904 |
my $out = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1905 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1906 |
# Go through the file and transform it byte by byte. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1907 |
my $i = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1908 |
while ($i < length($in)) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1909 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1910 |
my $cc = substr($in, $i, 2); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1911 |
if ($cc eq "\015\012") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1912 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1913 |
$out .= $native_eol; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1914 |
$i += 2; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1915 |
next; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1916 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1917 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1918 |
my $c = substr($cc, 0, 1); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1919 |
if ($c eq "\012" or $c eq "\015") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1920 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1921 |
$out .= $native_eol; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1922 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1923 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1924 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1925 |
$out .= $c; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1926 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1927 |
++$i; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1928 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1929 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1930 |
return 0 if $in eq $out; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1931 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1932 |
my $tmp_filename = ".svn/tmp/svn_load_dirs.$$"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1933 |
open(FILE, ">$tmp_filename") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1934 |
or die "$0: cannot open '$tmp_filename' for writing: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1935 |
binmode FILE; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1936 |
print FILE $out; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1937 |
close(FILE) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1938 |
or die "$0: cannot close '$tmp_filename' for writing: $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1939 |
rename($tmp_filename, $filename) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1940 |
or die "$0: cannot rename '$tmp_filename' to '$filename': $!\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1941 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1942 |
return 1; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1943 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1944 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1945 |
# Split the input line into words taking into account that single or |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1946 |
# double quotes may define a single word with whitespace in it. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1947 |
sub split_line |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1948 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1949 |
unless (@_ == 1) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1950 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1951 |
croak "$0: split_line $INCORRECT_NUMBER_OF_ARGS"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1952 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1953 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1954 |
my $line = shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1955 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1956 |
# Strip leading whitespace. Do not strip trailing whitespace which |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1957 |
# may be part of quoted text that was never closed. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1958 |
$line =~ s/^\s+//; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1959 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1960 |
my $line_length = length $line; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1961 |
my @words = (); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1962 |
my $current_word = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1963 |
my $in_quote = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1964 |
my $in_protect = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1965 |
my $in_space = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1966 |
my $i = 0; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1967 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1968 |
while ($i < $line_length) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1969 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1970 |
my $c = substr($line, $i, 1); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1971 |
++$i; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1972 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1973 |
if ($in_protect) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1974 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1975 |
if ($c eq $in_quote) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1976 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1977 |
$current_word .= $c; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1978 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1979 |
elsif ($c eq '"' or $c eq "'") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1980 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1981 |
$current_word .= $c; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1982 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1983 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1984 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1985 |
$current_word .= "$in_protect$c"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1986 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1987 |
$in_protect = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1988 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1989 |
elsif ($c eq '\\') |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1990 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1991 |
$in_protect = $c; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1992 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1993 |
elsif ($in_quote) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1994 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1995 |
if ($c eq $in_quote) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1996 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1997 |
$in_quote = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1998 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
1999 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2000 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2001 |
$current_word .= $c; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2002 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2003 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2004 |
elsif ($c eq '"' or $c eq "'") |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2005 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2006 |
$in_quote = $c; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2007 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2008 |
elsif ($c =~ m/^\s$/) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2009 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2010 |
unless ($in_space) |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2011 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2012 |
push(@words, $current_word); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2013 |
$current_word = ''; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2014 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2015 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2016 |
else |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2017 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2018 |
$current_word .= $c; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2019 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2020 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2021 |
$in_space = $c =~ m/^\s$/; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2022 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2023 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2024 |
# Handle any leftovers. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2025 |
$current_word .= $in_protect if $in_protect; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2026 |
push(@words, $current_word) if length $current_word; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2027 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2028 |
@words; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2029 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2030 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2031 |
# This package exists just to delete the temporary directory. |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2032 |
package Temp::Delete; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2033 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2034 |
sub new |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2035 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2036 |
bless {}, shift; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2037 |
} |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2038 |
|
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2039 |
sub DESTROY |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2040 |
{ |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2041 |
print "Cleaning up $temp_dir\n"; |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2042 |
File::Path::rmtree([$temp_dir], 0, 0); |
b73eec62825a
Remove last remnants of /thirdparty/.
Todd Larsen <tlarsen@google.com>
parents:
diff
changeset
|
2043 |
} |