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":
"""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]
""",
@ -798,14 +798,21 @@ class GClient(object):
self._SaveEntries(entries)
def PrintRevInfo(self):
"""Output revision info mapping for the client and its dependencies. 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
"""Output revision info mapping for the client and its dependencies.
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)
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
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:
Error: If the client has conflicting entries.
"""
@ -827,21 +834,11 @@ class GClient(object):
if not solutions:
raise gclient_utils.Error("No solution specified")
# Inner helper to generate base url and rev tuple (including honoring
# |revision_overrides|)
# Inner helper to generate base url and rev tuple
def GetURLAndRev(name, original_url):
url, revision = gclient_utils.SplitUrlRevision(original_url)
if not revision:
if revision_overrides.has_key(name):
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)
url, _ = gclient_utils.SplitUrlRevision(original_url)
scm = gclient_scm.CreateSCM(original_url, self._root_dir, name)
return (url, scm.revinfo(self._options, [], None))
# text of the snapshot gclient file
new_gclient = ""

@ -806,7 +806,7 @@ class SVNWrapper(SCMWrapper):
def revinfo(self, options, args, file_list):
"""Display revision"""
__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):
self.status(options, args, file_list)

@ -493,6 +493,17 @@ class SVN(object):
dom = xml.dom.minidom.parseString(info)
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
def CaptureStatus(files):
"""Returns the svn 1.5 svn status emulated output.

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

Loading…
Cancel
Save