Title: [185710] trunk/Tools
Revision
185710
Author
[email protected]
Date
2015-06-18 11:00:11 -0700 (Thu, 18 Jun 2015)

Log Message

Make webkitdirs::runGitUpdate() work when invoked in more than one Git checkout
https://bugs.webkit.org/show_bug.cgi?id=146082

Reviewed by Darin Adler.

The function webkitdirs::runGitUpdate may not update the Git checkout in the current
working directory after being invoked in a different Git checkout. In particular,
calling runGitUpdate() inside a Git SVN checkout and subsequently calling it inside
a pure Git checkout g will fail to update g.

Currently webkitdirs::runGitUpdate() calls VCSUtils::isGitSVN() to determine whether
the current working directory is a Git SVN checkout. And isGitSVN() caches its result
to speed up subsequent queries. This prevents runGitUpdate() from being used to update
an arbitrary Git checkout (since isGitSVN() may return a cached result for a directory
different than the current working directory). Instead runGitUpdate() should check
whether the current working directory is a Git SVN checkout on each invocation.

* Scripts/VCSUtils.pm: Export function isGitSVNDirectory so that it can be used from webkitdirs::runGitUpdate().
(isGitSVNDirectory): Extracted logic to determine whether a directory is a Git
SVN directory from isGitSVN().
(isGitSVN): Implemented in terms of isGitSVNDirectory().
* Scripts/webkitdirs.pm:
(runGitUpdate): Modified to use isGitSVNDirectory().

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (185709 => 185710)


--- trunk/Tools/ChangeLog	2015-06-18 17:58:33 UTC (rev 185709)
+++ trunk/Tools/ChangeLog	2015-06-18 18:00:11 UTC (rev 185710)
@@ -1,3 +1,29 @@
+2015-06-18  Daniel Bates  <[email protected]>
+
+        Make webkitdirs::runGitUpdate() work when invoked in more than one Git checkout
+        https://bugs.webkit.org/show_bug.cgi?id=146082
+
+        Reviewed by Darin Adler.
+
+        The function webkitdirs::runGitUpdate may not update the Git checkout in the current
+        working directory after being invoked in a different Git checkout. In particular,
+        calling runGitUpdate() inside a Git SVN checkout and subsequently calling it inside
+        a pure Git checkout g will fail to update g.
+
+        Currently webkitdirs::runGitUpdate() calls VCSUtils::isGitSVN() to determine whether
+        the current working directory is a Git SVN checkout. And isGitSVN() caches its result
+        to speed up subsequent queries. This prevents runGitUpdate() from being used to update
+        an arbitrary Git checkout (since isGitSVN() may return a cached result for a directory
+        different than the current working directory). Instead runGitUpdate() should check
+        whether the current working directory is a Git SVN checkout on each invocation.
+
+        * Scripts/VCSUtils.pm: Export function isGitSVNDirectory so that it can be used from webkitdirs::runGitUpdate().
+        (isGitSVNDirectory): Extracted logic to determine whether a directory is a Git
+        SVN directory from isGitSVN().
+        (isGitSVN): Implemented in terms of isGitSVNDirectory().
+        * Scripts/webkitdirs.pm:
+        (runGitUpdate): Modified to use isGitSVNDirectory().
+
 2015-06-18  Mark Lam  <[email protected]>
 
         Refactor CheckedArithmeticOperations.cpp to use templates instead of macros.

Modified: trunk/Tools/Scripts/VCSUtils.pm (185709 => 185710)


--- trunk/Tools/Scripts/VCSUtils.pm	2015-06-18 17:58:33 UTC (rev 185709)
+++ trunk/Tools/Scripts/VCSUtils.pm	2015-06-18 18:00:11 UTC (rev 185710)
@@ -66,6 +66,7 @@
         &isGitSVN
         &isGitBranchBuild
         &isGitDirectory
+        &isGitSVNDirectory
         &isSVN
         &isSVNDirectory
         &isSVNVersion16OrNewer
@@ -224,18 +225,30 @@
     return $isGit;
 }
 
-sub isGitSVN()
+sub isGitSVNDirectory($)
 {
-    return $isGitSVN if defined $isGitSVN;
+    my ($directory) = @_;
 
+    my $savedWorkingDirectory = Cwd::getcwd();
+    chdir($directory);
+
     # There doesn't seem to be an officially documented way to determine
     # if you're in a git-svn checkout. The best suggestions seen so far
     # all use something like the following:
     my $output = `git config --get svn-remote.svn.fetch 2>& 1`;
     $isGitSVN = $output ne '';
+    chdir($savedWorkingDirectory);
     return $isGitSVN;
 }
 
+sub isGitSVN()
+{
+    return $isGitSVN if defined $isGitSVN;
+
+    $isGitSVN = isGitSVNDirectory(".");
+    return $isGitSVN;
+}
+
 sub gitDirectory()
 {
     chomp(my $result = `git rev-parse --git-dir`);

Modified: trunk/Tools/Scripts/webkitdirs.pm (185709 => 185710)


--- trunk/Tools/Scripts/webkitdirs.pm	2015-06-18 17:58:33 UTC (rev 185709)
+++ trunk/Tools/Scripts/webkitdirs.pm	2015-06-18 18:00:11 UTC (rev 185710)
@@ -2494,7 +2494,7 @@
     # Doing a git fetch first allows setups with svn-remote.svn.fetch = trunk:refs/remotes/origin/master
     # to perform the rebase much much faster.
     system("git", "fetch");
-    if (isGitSVN()) {
+    if (isGitSVNDirectory(".")) {
         system("git", "svn", "rebase") == 0 or die;
     } else {
         # This will die if branch.$BRANCHNAME.merge isn't set, which is
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to