Omit commit position for Blink lastchange / version

BUG=535268
R=dpranke@chromium.org, pfeldman@chromium.org

Review URL: https://codereview.chromium.org/1361203002 .

(cherry picked from commit f880f0071d47ec1aa9608245222ad0b6f350e48c)

Cr-Original-Commit-Position: refs/heads/master@{#350370}
Cr-Commit-Position: refs/branch-heads/2454@{#501}
Cr-Branched-From: 12bfc3360892ec53cd00fc239a47e5298beb063b-refs/heads/master@{#338390}
diff --git a/DEPS b/DEPS
index 065d300..cee16af 100644
--- a/DEPS
+++ b/DEPS
@@ -574,6 +574,7 @@
     'name': 'lastchange',
     'pattern': '.',
     'action': ['python', 'src/build/util/lastchange.py',
+               '--git-hash-only',
                '-s', 'src/third_party/WebKit',
                '-o', 'src/build/util/LASTCHANGE.blink'],
   },
diff --git a/build/util/lastchange.py b/build/util/lastchange.py
index 3f3ee4a..ce1926a 100755
--- a/build/util/lastchange.py
+++ b/build/util/lastchange.py
@@ -90,7 +90,7 @@
     return None
 
 
-def FetchGitRevision(directory):
+def FetchGitRevision(directory, hash_only):
   """
   Fetch the Git hash for a given directory.
 
@@ -116,7 +116,7 @@
         if line.startswith('Cr-Commit-Position:'):
           pos = line.rsplit()[-1].strip()
           break
-  if not pos:
+  if hash_only or not pos:
     return VersionInfo('git', hsh)
   return VersionInfo('git', '%s-%s' % (hsh, pos))
 
@@ -166,7 +166,7 @@
 
 def FetchVersionInfo(default_lastchange, directory=None,
                      directory_regex_prior_to_src_url='chrome|blink|svn',
-                     go_deeper=False):
+                     go_deeper=False, hash_only=False):
   """
   Returns the last change (in the form of a branch, revision tuple),
   from some appropriate revision control system.
@@ -176,7 +176,7 @@
 
   version_info = (FetchSVNRevision(directory, svn_url_regex) or
                   FetchGitSVNRevision(directory, svn_url_regex, go_deeper) or
-                  FetchGitRevision(directory))
+                  FetchGitRevision(directory, hash_only))
   if not version_info:
     if default_lastchange and os.path.exists(default_lastchange):
       revision = open(default_lastchange, 'r').read().strip()
@@ -263,6 +263,9 @@
   parser.add_option("--git-svn-go-deeper", action='store_true',
                     help="In a Git-SVN repo, dig down to the last committed " +
                     "SVN change (historic behaviour).")
+  parser.add_option("--git-hash-only", action="store_true",
+                    help="In a Git repo with commit positions, only report " +
+                    "the hash.")
   opts, args = parser.parse_args(argv[1:])
 
   out_file = opts.output
@@ -283,7 +286,8 @@
 
   version_info = FetchVersionInfo(opts.default_lastchange,
                                   directory=src_dir,
-                                  go_deeper=opts.git_svn_go_deeper)
+                                  go_deeper=opts.git_svn_go_deeper,
+                                  hash_only=opts.git_hash_only)
 
   if version_info.revision == None:
     version_info.revision = '0'