Add --transitive flag.
When specifying a revision (with -r) propagates the date of the revision to its children.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@83313 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_scm.py b/gclient_scm.py
index 6dc4da7..99461d1 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -126,6 +126,13 @@
 class GitWrapper(SCMWrapper):
   """Wrapper for Git"""
 
+  def GetRevisionDate(self, revision):
+    """Returns the given revision's date in ISO-8601 format (which contains the
+    time zone)."""
+    # TODO(floitsch): get the time-stamp of the given revision and not just the
+    # time-stamp of the currently checked out revision.
+    return self._Capture(['log', '-n', '1', '--format=%ai'])
+
   @staticmethod
   def cleanup(options, args, file_list):
     """'Cleanup' the repo.
@@ -186,6 +193,14 @@
     if not revision:
       revision = default_rev
 
+    if gclient_utils.IsDateRevision(revision):
+      # Date-revisions only work on git-repositories if the reflog hasn't
+      # expired yet. Use rev-list to get the corresponding revision.
+      #  git rev-list -n 1 --before='time-stamp' branchname
+      if options.transitive:
+        print('Warning: --transitive only works for SVN repositories.')
+        revision = default_rev
+
     rev_str = ' at %s' % revision
     files = []
 
@@ -668,6 +683,13 @@
 class SVNWrapper(SCMWrapper):
   """ Wrapper for SVN """
 
+  def GetRevisionDate(self, revision):
+    """Returns the given revision's date in ISO-8601 format (which contains the
+    time zone)."""
+    date = scm.SVN.Capture(['propget', '--revprop', 'svn:date', '-r', revision,
+                            os.path.join(self.checkout_path, '.')])
+    return date.strip()
+
   def cleanup(self, options, args, file_list):
     """Cleanup working copy."""
     self._Run(['cleanup'] + args, options)