Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / v8 / tools / push-to-trunk / auto_roll.py
index 6e6c7fe..120e633 100755 (executable)
@@ -12,14 +12,6 @@ import urllib
 from common_includes import *
 import chromium_roll
 
-CLUSTERFUZZ_API_KEY_FILE = "CLUSTERFUZZ_API_KEY_FILE"
-
-CONFIG = {
-  PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile",
-  CLUSTERFUZZ_API_KEY_FILE: ".cf_api_key",
-}
-
-CR_DEPS_URL = 'http://src.chromium.org/svn/trunk/src/DEPS'
 
 class CheckActiveRoll(Step):
   MESSAGE = "Check active roll."
@@ -50,8 +42,9 @@ class DetectLastPush(Step):
   MESSAGE = "Detect commit ID of the last push to trunk."
 
   def RunStep(self):
-    push_hash = self.FindLastTrunkPush(include_patches=True)
-    self["last_push"] = self.GitSVNFindSVNRev(push_hash)
+    push_hash = self.FindLastTrunkPush(
+        branch="origin/master", include_patches=True)
+    self["last_push"] = self.GetCommitPositionNumber(push_hash)
 
 
 class DetectLastRoll(Step):
@@ -59,10 +52,14 @@ class DetectLastRoll(Step):
 
   def RunStep(self):
     # Interpret the DEPS file to retrieve the v8 revision.
+    # TODO(machenbach): This should be part or the roll-deps api of
+    # depot_tools.
     Var = lambda var: '%s'
-    exec(self.ReadURL(CR_DEPS_URL))
-    last_roll = vars['v8_revision']
-    if last_roll >= self["last_push"]:
+    exec(FileToText(os.path.join(self._options.chromium, "DEPS")))
+    last_roll = self.GetCommitPositionNumber(vars['v8_revision'])
+    # FIXME(machenbach): When rolling from bleeding edge and from trunk there
+    # be different commit numbers here. Better use version?
+    if int(last_roll) >= int(self["last_push"]):
       print("There is no newer v8 revision than the one in Chromium (%s)."
             % last_roll)
       return True
@@ -72,10 +69,10 @@ class CheckClusterFuzz(Step):
   MESSAGE = "Check ClusterFuzz api for new problems."
 
   def RunStep(self):
-    if not os.path.exists(self.Config(CLUSTERFUZZ_API_KEY_FILE)):
+    if not os.path.exists(self.Config("CLUSTERFUZZ_API_KEY_FILE")):
       print "Skipping ClusterFuzz check. No api key file found."
       return False
-    api_key = FileToText(self.Config(CLUSTERFUZZ_API_KEY_FILE))
+    api_key = FileToText(self.Config("CLUSTERFUZZ_API_KEY_FILE"))
     # Check for open, reproducible issues that have no associated bug.
     result = self._side_effect_handler.ReadClusterFuzzAPI(
         api_key, job_type="linux_asan_d8_dbg", reproducible="True",
@@ -95,16 +92,14 @@ class RollChromium(Step):
         "--author", self._options.author,
         "--reviewer", self._options.reviewer,
         "--chromium", self._options.chromium,
-        "--force",
         "--use-commit-queue",
       ]
       if self._options.sheriff:
         args.extend([
             "--sheriff", "--googlers-mapping", self._options.googlers_mapping])
-      R = chromium_roll.ChromiumRoll
-      self._side_effect_handler.Call(
-          R(chromium_roll.CONFIG, self._side_effect_handler).Run,
-          args)
+      if self._options.dry_run:
+        args.extend(["--dry-run"])
+      self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args)
 
 
 class AutoRoll(ScriptsBase):
@@ -112,8 +107,7 @@ class AutoRoll(ScriptsBase):
     parser.add_argument("-c", "--chromium", required=True,
                         help=("The path to your Chromium src/ "
                               "directory to automate the V8 roll."))
-    parser.add_argument("--roll",
-                        help="Make Chromium roll. Dry run if unspecified.",
+    parser.add_argument("--roll", help="Call Chromium roll script.",
                         default=False, action="store_true")
 
   def _ProcessOptions(self, options):  # pragma: no cover
@@ -125,6 +119,12 @@ class AutoRoll(ScriptsBase):
       return False
     return True
 
+  def _Config(self):
+    return {
+      "PERSISTFILE_BASENAME": "/tmp/v8-auto-roll-tempfile",
+      "CLUSTERFUZZ_API_KEY_FILE": ".cf_api_key",
+    }
+
   def _Steps(self):
     return [
       CheckActiveRoll,
@@ -136,4 +136,4 @@ class AutoRoll(ScriptsBase):
 
 
 if __name__ == "__main__":  # pragma: no cover
-  sys.exit(AutoRoll(CONFIG).Run())
+  sys.exit(AutoRoll().Run())