Run hooks after writing .gclient_entries

The Cobalt hooks install-git-config-upstream relies on this file to
exist so it can recurse through all the dependencies.

Change-Id: Iee3d70b969fdae63ecd9c71eda8ff97ade74ee4b
diff --git a/gclient.py b/gclient.py
index 8de7e52..f1f4296 100755
--- a/gclient.py
+++ b/gclient.py
@@ -1522,11 +1522,6 @@
       print >> sys.stderr, ('Please fix your script, having invalid '
                             '--revision flags will soon considered an error.')
 
-    # Once all the dependencies have been processed, it's now safe to run the
-    # hooks.
-    if not self._options.nohooks:
-      self.RunHooksRecursively(self._options)
-
     if command == 'update':
       # Notify the user if there is an orphaned entry in their working copy.
       # Only delete the directory if there are no changes in it, and
@@ -1624,6 +1619,12 @@
             gclient_utils.rmtree(e_dir)
       # record the current list of entries for next time
       self._SaveEntries()
+
+    # Once all the dependencies have been processed, it's now safe to run the
+    # hooks.
+    if not self._options.nohooks:
+      self.RunHooksRecursively(self._options)
+
     return 0
 
   def PrintRevInfo(self):