revinfo: Properly use git HEAD or svn BASE revisions

BUG=http://crosbug.com/1658

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@42555 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
nasser@codeaurora.org 15 years ago
parent 6fb1090c8e
commit 5d63eb8382

@ -248,7 +248,7 @@ Valid options:
""", """,
"revinfo": "revinfo":
"""Outputs source path, server URL and revision information for every """Outputs source path, server URL and revision information for every
dependency in all solutions (no local checkout required). dependency in all solutions.
usage: revinfo [options] usage: revinfo [options]
""", """,
@ -798,14 +798,21 @@ class GClient(object):
self._SaveEntries(entries) self._SaveEntries(entries)
def PrintRevInfo(self): def PrintRevInfo(self):
"""Output revision info mapping for the client and its dependencies. This """Output revision info mapping for the client and its dependencies.
allows the capture of an overall "revision" for the source tree that can
be used to reproduce the same tree in the future. The actual output This allows the capture of an overall "revision" for the source tree that
can be used to reproduce the same tree in the future. The actual output
contains enough information (source paths, svn server urls and revisions) contains enough information (source paths, svn server urls and revisions)
that it can be used either to generate external svn commands (without that it can be used either to generate external svn/git commands (without
gclient) or as input to gclient's --rev option (with some massaging of gclient) or as input to gclient's --rev option (with some massaging of
the data). the data).
Since we care about the revision of the current source tree, for git
repositories this command uses the revision of the HEAD. For subversion we
use BASE.
The --snapshot option allows creating a .gclient file to reproduce the tree.
Raises: Raises:
Error: If the client has conflicting entries. Error: If the client has conflicting entries.
""" """
@ -827,21 +834,11 @@ class GClient(object):
if not solutions: if not solutions:
raise gclient_utils.Error("No solution specified") raise gclient_utils.Error("No solution specified")
# Inner helper to generate base url and rev tuple (including honoring # Inner helper to generate base url and rev tuple
# |revision_overrides|)
def GetURLAndRev(name, original_url): def GetURLAndRev(name, original_url):
url, revision = gclient_utils.SplitUrlRevision(original_url) url, _ = gclient_utils.SplitUrlRevision(original_url)
if not revision: scm = gclient_scm.CreateSCM(original_url, self._root_dir, name)
if revision_overrides.has_key(name): return (url, scm.revinfo(self._options, [], None))
return (url, revision_overrides[name])
else:
scm = gclient_scm.CreateSCM(solution["url"], self._root_dir, name)
return (url, scm.revinfo(self._options, [], None))
else:
if revision_overrides.has_key(name):
return (url, revision_overrides[name])
else:
return (url, revision)
# text of the snapshot gclient file # text of the snapshot gclient file
new_gclient = "" new_gclient = ""

@ -806,7 +806,7 @@ class SVNWrapper(SCMWrapper):
def revinfo(self, options, args, file_list): def revinfo(self, options, args, file_list):
"""Display revision""" """Display revision"""
__pychecker__ = 'unusednames=args,file_list,options' __pychecker__ = 'unusednames=args,file_list,options'
return scm.SVN.CaptureHeadRevision(self.url) return scm.SVN.CaptureBaseRevision(self.checkout_path)
def runhooks(self, options, args, file_list): def runhooks(self, options, args, file_list):
self.status(options, args, file_list) self.status(options, args, file_list)

@ -493,6 +493,17 @@ class SVN(object):
dom = xml.dom.minidom.parseString(info) dom = xml.dom.minidom.parseString(info)
return dom.getElementsByTagName('entry')[0].getAttribute('revision') return dom.getElementsByTagName('entry')[0].getAttribute('revision')
@staticmethod
def CaptureBaseRevision(cwd):
"""Get the base revision of a SVN repository.
Returns:
Int base revision
"""
info = SVN.Capture(["info", "--xml"], cwd)
dom = xml.dom.minidom.parseString(info)
return dom.getElementsByTagName('entry')[0].getAttribute('revision')
@staticmethod @staticmethod
def CaptureStatus(files): def CaptureStatus(files):
"""Returns the svn 1.5 svn status emulated output. """Returns the svn 1.5 svn status emulated output.

@ -146,9 +146,9 @@ class SVNTestCase(BaseSCMTestCase):
def testMembersChanged(self): def testMembersChanged(self):
self.mox.ReplayAll() self.mox.ReplayAll()
members = [ members = [
'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo', 'COMMAND', 'Capture', 'CaptureBaseRevision', 'CaptureHeadRevision',
'CaptureStatus', 'DiffItem', 'GenerateDiff', 'GetCheckoutRoot', 'CaptureInfo', 'CaptureStatus', 'DiffItem', 'GenerateDiff',
'GetEmail', 'GetFileProperty', 'IsMoved', 'GetCheckoutRoot', 'GetEmail', 'GetFileProperty', 'IsMoved',
'ReadSimpleAuth', 'Run', 'RunAndFilterOutput', 'RunAndGetFileList', 'ReadSimpleAuth', 'Run', 'RunAndFilterOutput', 'RunAndGetFileList',
] ]
# If this test fails, you should add the relevant test. # If this test fails, you should add the relevant test.

Loading…
Cancel
Save