2010-10-20 Daniel Bates <dbates@rim.com>
Reviewed by Martin Robinson.
Add Git-support to do-file-rename
https://bugs.webkit.org/show_bug.cgi?id=48015
Also, abstracts the SCM move/rename functionality in do-file-rename and
do-webcore-rename into a common function VCSUtils::scmMoveOrRenameFile().
Currently, do-file-rename is hard coded to assume the SCM is Subversion.
Instead, we should abstract the rename logic to be SCM-independent. This
will allow us to add Git support as well move such functionality into
our SCM library VCSUtils, where it can be shared by do-webcore-rename.
* Scripts/VCSUtils.pm:
- Added function scmMoveOrRenameFile.
* Scripts/do-file-rename: Modified to call VCSUtils::scmMoveOrRenameFile().
* Scripts/do-webcore-rename: Ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 2449edb..1b23aae 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,23 @@
+2010-10-20 Daniel Bates <dbates@rim.com>
+
+ Reviewed by Martin Robinson.
+
+ Add Git-support to do-file-rename
+ https://bugs.webkit.org/show_bug.cgi?id=48015
+
+ Also, abstracts the SCM move/rename functionality in do-file-rename and
+ do-webcore-rename into a common function VCSUtils::scmMoveOrRenameFile().
+
+ Currently, do-file-rename is hard coded to assume the SCM is Subversion.
+ Instead, we should abstract the rename logic to be SCM-independent. This
+ will allow us to add Git support as well move such functionality into
+ our SCM library VCSUtils, where it can be shared by do-webcore-rename.
+
+ * Scripts/VCSUtils.pm:
+ - Added function scmMoveOrRenameFile.
+ * Scripts/do-file-rename: Modified to call VCSUtils::scmMoveOrRenameFile().
+ * Scripts/do-webcore-rename: Ditto.
+
2010-10-20 Adam Roben <aroben@apple.com>
Fix old-run-webkit-tests when there's a space in the path to DRT
diff --git a/WebKitTools/Scripts/VCSUtils.pm b/WebKitTools/Scripts/VCSUtils.pm
index 5b29bcf..8d7e766 100644
--- a/WebKitTools/Scripts/VCSUtils.pm
+++ b/WebKitTools/Scripts/VCSUtils.pm
@@ -1,5 +1,6 @@
# Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
# Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek@gmail.com)
+# Copyright (C) Research In Motion Limited 2010. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -136,6 +137,18 @@
return $text;
}
+# Note, this method will not error if the file corresponding to the $source path does not exist.
+sub scmMoveOrRenameFile
+{
+ my ($source, $destination) = @_;
+ return if ! -e $source;
+ if (isSVN()) {
+ system("svn", "move", $source, $destination);
+ } elsif (isGit()) {
+ system("git", "mv", $source, $destination);
+ }
+}
+
# Note, this method will not error if the file corresponding to the path does not exist.
sub scmToggleExecutableBit
{
diff --git a/WebKitTools/Scripts/do-file-rename b/WebKitTools/Scripts/do-file-rename
index ac5099e..b81b9dc 100755
--- a/WebKitTools/Scripts/do-file-rename
+++ b/WebKitTools/Scripts/do-file-rename
@@ -29,10 +29,11 @@
# Script to do file renaming.
use strict;
+use File::Find;
use FindBin;
use lib $FindBin::Bin;
use webkitdirs;
-use File::Find;
+use VCSUtils;
setConfiguration();
chdirWebKit();
@@ -86,7 +87,7 @@
if ($newFile{$file}) {
my $newFile = $newFile{$file};
print "Renaming $file to $newFile\n";
- system "svn move $file $newFile";
+ scmMoveOrRenameFile($file, $newFile);
}
}
diff --git a/WebKitTools/Scripts/do-webcore-rename b/WebKitTools/Scripts/do-webcore-rename
index a1674de..6dcb719 100755
--- a/WebKitTools/Scripts/do-webcore-rename
+++ b/WebKitTools/Scripts/do-webcore-rename
@@ -207,18 +207,11 @@
}
}
-
-my $isGit = isGit();
-
for my $file (sort @paths) {
if ($newFile{$file}) {
my $newFile = $newFile{$file};
print "Renaming $file to $newFile\n";
- if ($isGit) {
- system "git mv $file $newFile";
- } else {
- system "svn move $file $newFile";
- }
+ scmMoveOrRenameFile($file, $newFile);
}
}