gclient: Make revinfo work on git.
* Add revinfo as part of SCMWrapper interface.
* Implement revinfo for git and svn.
* Add unit tests.
Review URL: http://codereview.chromium.org/362008
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@31280 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_scm.py b/gclient_scm.py
index 8cba540..b9625f9 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -78,7 +78,7 @@
if file_list is None:
file_list = []
- commands = ['cleanup', 'export', 'update', 'revert',
+ commands = ['cleanup', 'export', 'update', 'revert', 'revinfo',
'status', 'diff', 'pack', 'runhooks']
if not command in commands:
@@ -167,6 +167,10 @@
self._RunGit(['reset', '--hard', merge_base], redirect_stdout=False)
file_list.extend([os.path.join(self.checkout_path, f) for f in files])
+ def revinfo(self, options, args, file_list):
+ """Display revision"""
+ return self._RunGit(['rev-parse', 'HEAD'])
+
def runhooks(self, options, args, file_list):
self.status(options, args, file_list)
@@ -395,6 +399,10 @@
# exception.
logging.error('Failed to update:\n%s' % str(e))
+ def revinfo(self, options, args, file_list):
+ """Display revision"""
+ return CaptureSVNHeadRevision(self.url)
+
def runhooks(self, options, args, file_list):
self.status(options, args, file_list)