From 9453a32c50a02a2155053b53d3c8a27f5ace362c Mon Sep 17 00:00:00 2001
From: "evan@chromium.org"
 <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Tue, 15 Sep 2009 22:44:08 +0000
Subject: [PATCH] sync-webkit-git: link to wiki, do some of Tony's review
 comments

I had committed before I got Tony's feedback.  This change does
some of his suggestions and migrates some info to the wiki.

Review URL: http://codereview.chromium.org/195098

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26286 0039d316-1c4b-4281-b951-d872f2087c98
---
 tools/sync-webkit-git.py | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/tools/sync-webkit-git.py b/tools/sync-webkit-git.py
index 5e41116443d84..280923353e9a4 100755
--- a/tools/sync-webkit-git.py
+++ b/tools/sync-webkit-git.py
@@ -8,22 +8,8 @@
 Under the assumption third_party/WebKit is a clone of git.webkit.org,
 we can use git commands to make it match the version requested by DEPS.
 
-To use this:
-1) rm -rf third_party/WebKit
-2) git clone git://git.webkit.org/WebKit.git third_party/WebKit
-3) edit your .gclient "custom_deps" section to exclude components underneath
-   third_party/WebKit:
-     "src/third_party/WebKit/LayoutTests": None,
-     "src/third_party/WebKit/JavaScriptCore": None,
-     "src/third_party/WebKit/WebCore": None,
-4) run ./tools/sync-webkit-git.py now, and again whenever you run gclient
-   sync.
-
-FAQ:
-Q. Why not add this functionality to gclient itself?
-A. DEPS actually specifies to only pull some subdirectories of
-   third_party/WebKit.  So even if gclient supported git, we'd still need
-   to special-case this.
+See http://code.google.com/p/chromium/wiki/UsingWebKitGit for details on
+how to use this.
 """
 
 import os
@@ -48,7 +34,8 @@ def GetWebKitRev():
 def FindSVNRev(rev):
   """Map an SVN revision to a git hash.
   Like 'git svn find-rev' but without the git-svn bits."""
-  return RunGit(['rev-list', '-n', '1', '--grep=^git-svn-id: .*@%s' % rev,
+  # We find r123 by grepping for a line with "git-svn-id: blahblahblah@123".
+  return RunGit(['rev-list', '-n', '1', '--grep=^git-svn-id: .*@%s$' % rev,
                  'origin'])
 
 def UpdateGClientBranch(webkit_rev):
@@ -76,7 +63,8 @@ def UpdateCurrentCheckoutIfAppropriate():
   """Reset the current gclient branch if that's what we have checked out."""
   branch = RunGit(['symbolic-ref', '-q', 'HEAD'])
   if branch != MAGIC_GCLIENT_BRANCH:
-    print "Directory has some other branch ('%s') checked out." % branch
+    print ("third_party/WebKit has some other branch ('%s') checked out." %
+           branch)
     print "Run 'git checkout gclient' to put this under control of gclient."
     return
 
@@ -86,12 +74,20 @@ def UpdateCurrentCheckoutIfAppropriate():
     subprocess.check_call(['git', 'reset', '--hard'])
 
 def main():
+  if not os.path.exists('third_party/WebKit/.git'):
+    print "ERROR: third_party/WebKit appears to not be under git control."
+    print "See http://code.google.com/p/chromium/wiki/UsingWebKitGit for"
+    print "setup instructions."
+    return
+
   webkit_rev = GetWebKitRev()
   print 'Desired revision: r%s.' % webkit_rev
   os.chdir('third_party/WebKit')
   changed = UpdateGClientBranch(webkit_rev)
   if changed:
     UpdateCurrentCheckoutIfAppropriate()
+  else:
+    print "Already on correct revision."
 
 if __name__ == '__main__':
   main()
-- 
GitLab