Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / js / landbranch.pl
blob369b74d43e032a5d1147cb705a3af59e8d375e97
1 #! /usr/local/bin/perl5
3 use File::Path;
5 # The development branch is where primary development and checkins
6 # are done on a day-to-day basis.
7 $development_branch_prefix = "SpiderMonkey140";
9 # Space-separated list of CVS-controlled directories to tag/merge
10 $merge_dirs =
11 "mozilla/js/src " ;
13 # When line below uncommented, don't recurse into subdirs
14 #$recurse_flag = '-l';
16 #----------------------------------------------------------------------------
18 # The merge branch is itself a branch off of the development branch
19 # at a point where the development branch is thought to be stable.
20 # (A branch is used rather than a static tag because, inevitably,
21 # the development branch is not quite as stable/buildable as was
22 # thought.) The contents of the merge branch will be copied to
23 # the trunk when merging takes place.
26 # The following tags are created automatically by this script:
28 # JS_STABLE_DROP
30 # A static tag on the development branch (or a branch off the
31 # development branch) that indicates the code that should be merged
32 # into the trunk. This is a "variable" tag in the sense that it is
33 # redefined after each merge.
35 # JS_LAST_STABLE_DROP
37 # A static tag that is a copy of what the JS_STABLE_DROP tag was in
38 # the previous merge cycle. This is a "variable" tag that is
39 # redefined after each merge. Changes in the branch can be merged
40 # to the trunk by using:
42 # cvs up -jJS_LAST_STABLE_DROP -jJS_STABLE_DROP
44 # JS_LANDING
46 # A static tag that identifies the code on the trunk after the merge
47 # from the branch to the trunk takes place. This is a "variable"
48 # tag that is redefined after each merge. Changes on the trunk
49 # since the last branch landing can be seen by using:
51 # cvs diff -rJS_LANDING -rHEAD
53 # JS_LANDING_mmddyyyy
55 # This is a tag on the trunk which may be used for archaeological
56 # purposes. This tag is made from the JS_LANDING tag.
59 $development_branch = $development_branch_prefix . "_BRANCH";
60 $development_base = $development_branch_prefix . "_BASE";
62 sub help {
63 print <<"END";
64 $0: A tool for merging stable snapshots of JavaScript from a CVS
65 development branch onto the trunk
67 Landing a snapshot of the development branch consists of
68 the following steps:
70 1) Tag all/some files on the branch to identify files to be merged.
71 2) Merge files from the branch into the trunk using a temporary
72 working directory.
73 3) Resolve any conflicts that arise as a result of the merge.
74 4) Commit merged changes to the trunk.
75 5) Make changes to resolve (build) difficulties and re-commit.
76 Repeat as necessary.
77 6) Backpropagate changes on the trunk to the development branch.
79 This script will assist with steps #2, #4 and #6:
81 $0 -merge JS_STABLE_10131998
82 $0 -commit
83 $0 -backpatch
85 END
88 sub log {
89 local($msg) = @_;
90 print LOGFILE $msg if $logfile;
93 # Similar to die built-in
94 sub die {
95 local($msg) = @_;
96 &log($msg);
97 chomp($msg);
98 if ($logfile) {
99 $msg .= "\nSee $logfile for details.";
101 die "$msg\n";
104 # Similar to system() built-in
105 sub system {
106 local(@args) = @_;
107 local($cmd) = join(" ", @args);
108 &log("Executing: $cmd\n");
110 if ($logfile) {
111 $cmd .= " >> $logfile 2>&1";
112 close(LOGFILE);
115 local($result) = 0xffff & system($cmd);
117 if ($logfile) {
118 open(LOGFILE, ">>$logfile");
121 return unless ($result);
122 $msg = "Died while executing $cmd";
124 if ($result == 0xff00) {
125 &die("$msg\nWhile executExecution failed due to perl error: $!. ");
126 } else {
127 $result >>= 8;
128 &die("$msg\nExecution failed; exit status: $result. ");
132 chomp($root_dir = `pwd`);
134 # Default log file
135 $logfile = $root_dir . "/log";
137 while ($#ARGV >=0) {
138 $_ = shift;
140 if (/-merge/) {
141 $do_tag = 1;
142 $do_checkout = 1;
143 $do_merge = 1;
144 $tag = shift;
145 } elsif (/-commit/ || /-ci/) {
146 $do_commit = 1;
147 } elsif (/-backpatch/) {
148 $do_backpatch = 1;
149 } elsif (/-log/) {
150 $logfile = shift;
151 } elsif (/-tag/) { # Debugging option
152 $do_tag = 1;
153 $tag = shift;
154 } elsif (/-co/) { # Debugging option
155 $do_checkout = 1;
156 } else {
157 print STDERR "Illegal option: $_\n" unless (/-h/);
158 &help();
159 exit(1);
163 die "You must set your CVSROOT environment variable" if !$ENV{"CVSROOT"};
165 if ($logfile) {
166 open(LOGFILE, ">$logfile") || die "Couldn't open log file \"$logfile\"";
167 print("Logging to file \"$logfile\".\n");
170 $trunk_dir = $root_dir . "/trunk";
172 if ($do_tag) {
173 if (!$tag) {
174 &die("Must specify tag on command-line\n");
177 print("Tagging tree with tag JS_STABLE_DROP.\n");
178 &system("cvs rtag $recurse_flag -F -r $tag JS_STABLE_DROP $merge_dirs");
181 if ($do_checkout) {
183 # Delete trunk subdir if it already exists
184 if (-d $trunk_dir) {
185 &log("Deleting directory $trunk_dir\n");
186 rmtree ($trunk_dir, 0, 1);
188 &log("Creating directory $trunk_dir\n");
189 mkdir($trunk_dir, 0777) || die "Couldn't create directory $trunk_dir";
191 # Check out on trunk
192 print("Checking out $merge_dirs.\n");
193 chdir $trunk_dir;
194 &system("cvs co $recurse_flag -A $merge_dirs");
197 if ($do_merge) {
198 chdir $trunk_dir;
199 print("Merging from JS_STABLE_DROP into trunk\n");
200 &system("cvs up -jJS_LAST_STABLE_DROP -jJS_STABLE_DROP");
203 if ($do_commit) {
204 &die("No merged tree found. Wrong directory ?") if (!chdir $trunk_dir);
206 ($_,$_,$_,$day,$mon,$year,$_,$_) = localtime(time());
207 if ($year < 30) {
208 $year = "20" . $year;
209 } else {
210 $year = "19" . $year;
213 $mmddyyyy = sprintf("%02d%02d%s", $mon, $day, $year);
215 print("Checking in code on trunk");
216 &system("cvs ci -m 'Stable drop of JavaScript interpreter code from " .
217 "$development_branch'");
219 # Tag merged result
220 &system("cvs tag -F JS_LANDING");
221 &system("cvs tag -F JS_LANDING_$mmddyyyy");
223 # Move JS_LAST_STABLE_DROP tag forward
224 &system("cvs tag -F -rJS_STABLE_DROP JS_LAST_STABLE_DROP");