Bug 579178 part D - When unifying as sorted-matching, keep version A as the unified version, not the sorted version, r=ted
authorBenjamin Smedberg <benjamin@smedbergs.us>
Thu, 05 Aug 2010 10:11:39 -0400
changeset 49208 4f342f8ddce0f035077c560402f2ebe102653dfa
parent 49207 25a0613fc7eeeef48e58cba576a27f5e93a1903a
child 49209 66e79b756b39be20232af47dcf382b2426b14e76
push idunknown
push userunknown
push dateunknown
reviewersted
bugs579178
milestone2.0b3pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 579178 part D - When unifying as sorted-matching, keep version A as the unified version, not the sorted version, r=ted
build/Makefile.in
build/macosx/universal/unify
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -181,17 +181,17 @@ check::
         else \
           echo "TEST-PASS | build/ | unify unified a Java class file!"; \
         fi
 # try unifying some files that differ only in line ordering
 	rm -rf unify-sort-test
 	mkdir unify-sort-test unify-sort-test/a unify-sort-test/b
 	printf "lmn\nabc\nxyz\n" > unify-sort-test/a/file.foo
 	printf "xyz\nlmn\nabc" > unify-sort-test/b/file.foo
-	printf "abc\nlmn\nxyz\n" > unify-sort-test/expected-result
+	printf "lmn\nabc\nxyz\n" > unify-sort-test/expected-result
 	@if ! $(srcdir)/macosx/universal/unify --unify-with-sort "\.foo$$" \
           ./unify-sort-test/a ./unify-sort-test/b \
           ./unify-sort-test/c; then \
           echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to unify files with differing line ordering!"; \
           false; \
         fi
 	@if ! diff -q ./unify-sort-test/expected-result ./unify-sort-test/c/file.foo; then \
           echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to unify files with differing line ordering!"; \
--- a/build/macosx/universal/unify
+++ b/build/macosx/universal/unify
@@ -196,17 +196,16 @@ my (%gConfig, $gDryRun, $gOnlyOne, $gVer
 sub argumentEscape(@);
 sub command(@);
 sub compareZipArchives($$);
 sub complain($$@);
 sub copyIfIdentical($$$);
 sub slurp($);
 sub get_sorted($);
 sub compare_sorted($$);
-sub copy_sorted($$);
 sub copyIfIdenticalWhenSorted($$$);
 sub createUniqueFile($$);
 sub makeUniversal($$$);
 sub makeUniversalDirectory($$$);
 sub makeUniversalInternal($$$$);
 sub makeUniversalFile($$$);
 sub usage();
 sub readZipCRCs($);
@@ -536,31 +535,16 @@ sub compare_sorted($$) {
   return 1 unless scalar @lines1 == scalar @lines2;
 
   for (my $i = 0; $i < scalar @lines1; $i++) {
     return 1 if $lines1[$i] ne $lines2[$i];
   }
   return 0;
 }
 
-# copy_sorted($source, $destination)
-#
-# $source and $destination are filenames. Read the contents of $source
-# into an array, sort it, and then write the sorted contents to $destination.
-# Returns 1 on success, and undef on failure.
-sub copy_sorted($$) {
-  my ($src, $dest) = @_;
-  my @lines = get_sorted($src);
-  return undef unless @lines;
-  open FILE, "> $dest" or return undef;
-  print FILE @lines;
-  close FILE;
-  return 1;
-}
-
 # copyIfIdenticalWhenSorted($source1, $source2, $target)
 #
 # $source1 and $source2 are FileAttrCache objects that are compared, and if
 # identical, copied to path string $target.  The comparison is done by
 # sorting the individual lines within the two files and comparing the results.
 #
 # Returns true on success, false for files that are not equivalent,
 # and undef if an error occurs.
@@ -600,18 +584,18 @@ sub copyIfIdenticalWhenSorted($$$) {
     $isExecutable = $source1->lIsExecutable() ||
                     (defined($source2) && $source2->lIsExecutable());
 
     if (!createUniqueFile($target, $isExecutable ? 0777 : 0666)) {
       # createUniqueFile printed an error.
       return 0;
     }
 
-    if (!copy_sorted($source1->path(), $target)) {
-      complain(1, 'copyIfIdenticalWhenSorted: copy_sorted: '.$!
+    if (!copy($source1->path(), $target)) {
+      complain(1, 'copyIfIdenticalWhenSorted: copy: '.$!
                .' while copying',
                $source1->path(),
                $target);
       unlink($target);
       return 0;
     }
   }