Change CEF version number format to remove SVN dependency (issue #1580).
This commit is contained in:
commit
159f315483
4
cef.gyp
4
cef.gyp
|
@ -9,11 +9,11 @@
|
|||
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/cef',
|
||||
'about_credits_file': '<(SHARED_INTERMEDIATE_DIR)/about_credits.html',
|
||||
'framework_name': 'Chromium Embedded Framework',
|
||||
'revision': '<!(python tools/revision.py)',
|
||||
'commit_number': '<!(python tools/commit_number.py)',
|
||||
'chrome_version': '<!(python ../build/util/version.py -f ../chrome/VERSION -t "@MAJOR@.@MINOR@.@BUILD@.@PATCH@")',
|
||||
# Need to be creative to match dylib version formatting requirements.
|
||||
'version_mac_dylib':
|
||||
'<!(python ../build/util/version.py -f VERSION -f ../chrome/VERSION -t "@CEF_MAJOR@<(revision).@BUILD_HI@.@BUILD_LO@" -e "BUILD_HI=int(BUILD)/256" -e "BUILD_LO=int(BUILD)%256")',
|
||||
'<!(python ../build/util/version.py -f VERSION -f ../chrome/VERSION -t "@CEF_MAJOR@<(commit_number).@BUILD_HI@.@BUILD_LO@" -e "BUILD_HI=int(BUILD)/256" -e "BUILD_LO=int(BUILD)%256")',
|
||||
},
|
||||
'includes': [
|
||||
# Bring in the source file lists.
|
||||
|
|
|
@ -256,11 +256,7 @@ class Delegate : public InternalHandlerDelegate {
|
|||
|
||||
TemplateParser parser;
|
||||
parser.Add("YEAR", MAKE_STRING(COPYRIGHT_YEAR));
|
||||
parser.Add("CEF",
|
||||
base::StringPrintf("%d.%d.%d",
|
||||
CEF_VERSION_MAJOR,
|
||||
CHROME_VERSION_BUILD,
|
||||
CEF_REVISION));
|
||||
parser.Add("CEF", CEF_VERSION);
|
||||
parser.Add("CHROMIUM",
|
||||
base::StringPrintf("%d.%d.%d.%d",
|
||||
CHROME_VERSION_MAJOR,
|
||||
|
|
|
@ -24,24 +24,18 @@ void CefCrashReporterClient::GetProductNameAndVersion(
|
|||
base::string16* special_build,
|
||||
base::string16* channel_name) {
|
||||
*product_name = base::ASCIIToUTF16("cef");
|
||||
*version = base::UTF8ToUTF16(base::StringPrintf(
|
||||
"%d.%d.%d", CEF_VERSION_MAJOR, CHROME_VERSION_BUILD, CEF_REVISION));
|
||||
*version = base::ASCIIToUTF16(CEF_VERSION);
|
||||
*special_build = base::string16();
|
||||
*channel_name = base::string16();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
|
||||
#define PRODUCT_VERSION \
|
||||
MAKE_STRING(CEF_VERSION_MAJOR) "." \
|
||||
MAKE_STRING(CHROME_VERSION_BUILD) "." \
|
||||
MAKE_STRING(CEF_REVISION)
|
||||
|
||||
void CefCrashReporterClient::GetProductNameAndVersion(
|
||||
const char** product_name,
|
||||
const char** version) {
|
||||
*product_name = "cef";
|
||||
*version = PRODUCT_VERSION;
|
||||
*version = CEF_VERSION;
|
||||
}
|
||||
|
||||
base::FilePath CefCrashReporterClient::GetReporterLogFilename() {
|
||||
|
|
|
@ -95,8 +95,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0
|
||||
PRODUCTVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0
|
||||
FILEVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_COMMIT_NUMBER,0
|
||||
PRODUCTVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_COMMIT_NUMBER,0
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -112,12 +112,12 @@ BEGIN
|
|||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "Chromium Embedded Framework (CEF) Dynamic Link Library"
|
||||
VALUE "FileVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
|
||||
VALUE "FileVersion", CEF_VERSION
|
||||
VALUE "InternalName", "libcef"
|
||||
VALUE "LegalCopyright", "Copyright (C) " MAKE_STRING(COPYRIGHT_YEAR) " The Chromium Embedded Framework Authors"
|
||||
VALUE "OriginalFilename", "libcef.dll"
|
||||
VALUE "ProductName", "Chromium Embedded Framework (CEF) Dynamic Link Library"
|
||||
VALUE "ProductVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
|
||||
VALUE "ProductVersion", CEF_VERSION
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -6,14 +6,10 @@
|
|||
#include "include/cef_version.h"
|
||||
#include <cstddef>
|
||||
|
||||
CEF_EXPORT int cef_build_revision() {
|
||||
return CEF_REVISION;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_version_info(int entry) {
|
||||
switch (entry) {
|
||||
case 0: return CEF_VERSION_MAJOR;
|
||||
case 1: return CEF_REVISION;
|
||||
case 1: return CEF_COMMIT_NUMBER;
|
||||
case 2: return CHROME_VERSION_MAJOR;
|
||||
case 3: return CHROME_VERSION_MINOR;
|
||||
case 4: return CHROME_VERSION_BUILD;
|
||||
|
@ -26,6 +22,7 @@ CEF_EXPORT const char* cef_api_hash(int entry) {
|
|||
switch (entry) {
|
||||
case 0: return CEF_API_HASH_PLATFORM;
|
||||
case 1: return CEF_API_HASH_UNIVERSAL;
|
||||
case 2: return CEF_COMMIT_HASH;
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,8 +122,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0
|
||||
PRODUCTVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_REVISION,0
|
||||
FILEVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_COMMIT_NUMBER,0
|
||||
PRODUCTVERSION CEF_VERSION_MAJOR,CHROME_VERSION_BUILD,CEF_COMMIT_NUMBER,0
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -139,12 +139,12 @@ BEGIN
|
|||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "Chromium Embedded Framework (CEF) Client Application"
|
||||
VALUE "FileVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
|
||||
VALUE "FileVersion", CEF_VERSION
|
||||
VALUE "InternalName", "cefclient"
|
||||
VALUE "LegalCopyright", "Copyright (C) " MAKE_STRING(COPYRIGHT_YEAR) " The Chromium Embedded Framework Authors"
|
||||
VALUE "OriginalFilename", "cefclient.exe"
|
||||
VALUE "ProductName", "Chromium Embedded Framework (CEF) Client Application"
|
||||
VALUE "ProductVersion", MAKE_STRING(CEF_VERSION_MAJOR) "." MAKE_STRING(CHROME_VERSION_BUILD) "." MAKE_STRING(CEF_REVISION)
|
||||
VALUE "ProductVersion", CEF_VERSION
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -8,13 +8,9 @@
|
|||
#include "include/cef_version.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
TEST(VersionTest, BuildRevision) {
|
||||
EXPECT_EQ(CEF_REVISION, cef_build_revision());
|
||||
}
|
||||
|
||||
TEST(VersionTest, VersionInfo) {
|
||||
EXPECT_EQ(CEF_VERSION_MAJOR, cef_version_info(0));
|
||||
EXPECT_EQ(CEF_REVISION, cef_version_info(1));
|
||||
EXPECT_EQ(CEF_COMMIT_NUMBER, cef_version_info(1));
|
||||
EXPECT_EQ(CHROME_VERSION_MAJOR, cef_version_info(2));
|
||||
EXPECT_EQ(CHROME_VERSION_MINOR, cef_version_info(3));
|
||||
EXPECT_EQ(CHROME_VERSION_BUILD, cef_version_info(4));
|
||||
|
@ -24,4 +20,5 @@ TEST(VersionTest, VersionInfo) {
|
|||
TEST(VersionTest, ApiHash) {
|
||||
EXPECT_STREQ(CEF_API_HASH_PLATFORM, cef_api_hash(0));
|
||||
EXPECT_STREQ(CEF_API_HASH_UNIVERSAL, cef_api_hash(1));
|
||||
EXPECT_STREQ(CEF_COMMIT_HASH, cef_api_hash(2));
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
import os, re, string, sys
|
||||
from file_util import *
|
||||
import git_util as git
|
||||
import svn_util as svn
|
||||
|
||||
# script directory
|
||||
script_dir = os.path.dirname(__file__)
|
||||
|
@ -41,9 +40,9 @@ except ImportError, e:
|
|||
import cpplint_chromium
|
||||
|
||||
# The default implementation of FileInfo.RepositoryName looks for the top-most
|
||||
# directory that contains a .git or .svn folder. This is a problem for CEF
|
||||
# because the CEF root folder (which may have an arbitrary name) lives inside
|
||||
# the Chromium src folder. Reimplement in a dumb but sane way.
|
||||
# directory that contains a .git folder. This is a problem for CEF because the
|
||||
# CEF root folder (which may have an arbitrary name) lives inside the Chromium
|
||||
# src folder. Reimplement in a dumb but sane way.
|
||||
def patch_RepositoryName(self):
|
||||
fullname = self.FullName()
|
||||
project_dir = os.path.dirname(fullname)
|
||||
|
@ -87,13 +86,6 @@ def check_style(args, white_list = None, black_list = None):
|
|||
print "Total errors found: %d\n" % cpplint._cpplint_state.error_count
|
||||
return 1
|
||||
|
||||
def get_changed_files():
|
||||
""" Retrieve the list of changed files. """
|
||||
try:
|
||||
return svn.get_changed_files(cef_dir)
|
||||
except:
|
||||
return git.get_changed_files(cef_dir)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Start with the default parameters.
|
||||
args = [
|
||||
|
@ -115,7 +107,7 @@ if __name__ == "__main__":
|
|||
for arg in args:
|
||||
if arg == '--changed':
|
||||
# Add any changed files.
|
||||
changed = get_changed_files()
|
||||
changed = git.get_changed_files(cef_dir)
|
||||
elif arg[:2] == '--' or not os.path.isdir(arg):
|
||||
# Pass argument unchanged.
|
||||
new_args.append(arg)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# reserved. Use of this source code is governed by a BSD-style license that
|
||||
# can be found in the LICENSE file.
|
||||
|
||||
import svn_util as svn
|
||||
import git_util as git
|
||||
import os
|
||||
import sys
|
||||
|
@ -12,11 +11,7 @@ if __name__ != "__main__":
|
|||
sys.stderr.write('This file cannot be loaded as a module!')
|
||||
sys.exit()
|
||||
|
||||
if os.path.exists(os.path.join('.', '.svn')):
|
||||
sys.stdout.write(svn.get_revision())
|
||||
elif os.path.exists(os.path.join('.', '.git')):
|
||||
sys.stdout.write(git.get_svn_revision())
|
||||
if git.is_checkout('.'):
|
||||
sys.stdout.write(git.get_commit_number())
|
||||
else:
|
||||
raise Exception('Not a valid checkout')
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ def is_checkout(path):
|
|||
|
||||
def get_hash(path = '.', branch = 'HEAD'):
|
||||
""" Returns the git hash for the specified branch/tag/hash. """
|
||||
cmd = "git rev-parse %s" % (branch)
|
||||
cmd = "git rev-parse %s" % branch
|
||||
result = exec_cmd(cmd, path)
|
||||
if result['out'] != '':
|
||||
return result['out'].strip()
|
||||
|
@ -25,18 +25,13 @@ def get_url(path = '.'):
|
|||
return result['out'].strip()
|
||||
return 'Unknown'
|
||||
|
||||
def get_svn_revision(path = '.', branch = 'HEAD'):
|
||||
""" Returns the SVN revision associated with the specified path and git
|
||||
branch/tag/hash. """
|
||||
svn_rev = "None"
|
||||
cmd = "git log --grep=^git-svn-id: -n 1 %s" % (branch)
|
||||
def get_commit_number(path = '.', branch = 'HEAD'):
|
||||
""" Returns the number of commits in the specified branch/tag/hash. """
|
||||
cmd = "git rev-list --count %s" % branch
|
||||
result = exec_cmd(cmd, path)
|
||||
if result['err'] == '':
|
||||
for line in result['out'].split('\n'):
|
||||
if line.find("git-svn-id") > 0:
|
||||
svn_rev = line.split("@")[1].split()[0]
|
||||
break
|
||||
return svn_rev
|
||||
if result['out'] != '':
|
||||
return result['out'].strip()
|
||||
return '0'
|
||||
|
||||
def get_changed_files(path = '.'):
|
||||
""" Retrieves the list of changed files. """
|
||||
|
|
|
@ -10,7 +10,6 @@ import os
|
|||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import svn_util as svn
|
||||
import git_util as git
|
||||
import sys
|
||||
import zipfile
|
||||
|
@ -258,28 +257,21 @@ cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir))
|
|||
# src directory
|
||||
src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir))
|
||||
|
||||
# retrieve url and revision information for CEF
|
||||
if svn.is_checkout(cef_dir):
|
||||
cef_info = svn.get_svn_info(cef_dir)
|
||||
cef_url = cef_info['url']
|
||||
cef_rev = cef_info['revision']
|
||||
elif git.is_checkout(cef_dir):
|
||||
cef_url = git.get_url(cef_dir)
|
||||
cef_rev = git.get_svn_revision(cef_dir)
|
||||
else:
|
||||
if not git.is_checkout(cef_dir):
|
||||
raise Exception('Not a valid checkout: %s' % (cef_dir))
|
||||
|
||||
# retrieve url and revision information for Chromium
|
||||
if svn.is_checkout(src_dir):
|
||||
chromium_info = svn.get_svn_info(src_dir)
|
||||
chromium_url = chromium_info['url']
|
||||
chromium_rev = chromium_info['revision']
|
||||
elif git.is_checkout(src_dir):
|
||||
chromium_url = git.get_url(src_dir)
|
||||
chromium_rev = git.get_hash(src_dir)
|
||||
else:
|
||||
# retrieve information for CEF
|
||||
cef_url = git.get_url(cef_dir)
|
||||
cef_rev = git.get_hash(cef_dir)
|
||||
cef_commit_number = git.get_commit_number(cef_dir)
|
||||
|
||||
if not git.is_checkout(src_dir):
|
||||
raise Exception('Not a valid checkout: %s' % (src_dir))
|
||||
|
||||
# retrieve information for Chromium
|
||||
chromium_url = git.get_url(src_dir)
|
||||
chromium_rev = git.get_hash(src_dir)
|
||||
|
||||
date = get_date()
|
||||
|
||||
# Read and parse the version file (key=value pairs, one per line)
|
||||
|
@ -287,7 +279,7 @@ args = {}
|
|||
read_version_file(os.path.join(cef_dir, 'VERSION'), args)
|
||||
read_version_file(os.path.join(cef_dir, '../chrome/VERSION'), args)
|
||||
|
||||
cef_ver = args['CEF_MAJOR']+'.'+args['BUILD']+'.'+cef_rev
|
||||
cef_ver = '%s.%s.%s.g%s' % (args['CEF_MAJOR'], args['BUILD'], cef_commit_number, cef_rev[:7])
|
||||
chromium_ver = args['MAJOR']+'.'+args['MINOR']+'.'+args['BUILD']+'.'+args['PATCH']
|
||||
|
||||
# list of output directories to be archived
|
||||
|
|
|
@ -6,7 +6,6 @@ from date_util import *
|
|||
from file_util import *
|
||||
from optparse import OptionParser
|
||||
from cef_api_hash import cef_api_hash
|
||||
import svn_util as svn
|
||||
import git_util as git
|
||||
import sys
|
||||
|
||||
|
@ -40,7 +39,7 @@ if options.header is None or options.cef_version is None or options.chrome_versi
|
|||
parser.print_help(sys.stdout)
|
||||
sys.exit()
|
||||
|
||||
def write_svn_header(header, chrome_version, cef_version, cpp_header_dir):
|
||||
def write_version_header(header, chrome_version, cef_version, cpp_header_dir):
|
||||
""" Creates the header file for the current revision and Chrome version information
|
||||
if the information has changed or if the file doesn't already exist. """
|
||||
|
||||
|
@ -60,12 +59,12 @@ def write_svn_header(header, chrome_version, cef_version, cpp_header_dir):
|
|||
|
||||
year = get_year()
|
||||
|
||||
if svn.is_checkout('.'):
|
||||
revision = svn.get_revision()
|
||||
elif git.is_checkout('.'):
|
||||
revision = git.get_svn_revision()
|
||||
else:
|
||||
raise Exception('Not a valid checkout')
|
||||
if not git.is_checkout('.'):
|
||||
raise Exception('Not a valid checkout')
|
||||
|
||||
commit_number = git.get_commit_number()
|
||||
commit_hash = git.get_hash()
|
||||
version = '%s.%s.%s.g%s' % (args['CEF_MAJOR'], args['BUILD'], commit_number, commit_hash[:7])
|
||||
|
||||
# calculate api hashes
|
||||
api_hash_calculator = cef_api_hash(cpp_header_dir, verbose = False)
|
||||
|
@ -106,8 +105,10 @@ def write_svn_header(header, chrome_version, cef_version, cpp_header_dir):
|
|||
'//\n\n'+\
|
||||
'#ifndef CEF_INCLUDE_CEF_VERSION_H_\n'+\
|
||||
'#define CEF_INCLUDE_CEF_VERSION_H_\n\n'+\
|
||||
'#define CEF_VERSION "' + version + '"\n'+\
|
||||
'#define CEF_VERSION_MAJOR ' + args['CEF_MAJOR'] + '\n'+\
|
||||
'#define CEF_REVISION ' + revision + '\n'+\
|
||||
'#define CEF_COMMIT_NUMBER ' + commit_number + '\n'+\
|
||||
'#define CEF_COMMIT_HASH "' + commit_hash + '"\n'+\
|
||||
'#define COPYRIGHT_YEAR ' + year + '\n\n'+\
|
||||
'#define CHROME_VERSION_MAJOR ' + args['MAJOR'] + '\n'+\
|
||||
'#define CHROME_VERSION_MINOR ' + args['MINOR'] + '\n'+\
|
||||
|
@ -134,15 +135,10 @@ def write_svn_header(header, chrome_version, cef_version, cpp_header_dir):
|
|||
'#elif defined(OS_LINUX)\n'+\
|
||||
'#define CEF_API_HASH_PLATFORM "' + api_hashes['linux'] + '"\n'+\
|
||||
'#endif\n\n'+\
|
||||
'///\n'+\
|
||||
'// Returns the CEF build revision for the libcef library.\n'+\
|
||||
'///\n'+\
|
||||
'CEF_EXPORT int cef_build_revision();\n\n'+\
|
||||
'///\n'+\
|
||||
'// Returns CEF version information for the libcef library. The |entry|\n'+\
|
||||
'// parameter describes which version component will be returned:\n'+\
|
||||
'// 0 - CEF_VERSION_MAJOR\n'+\
|
||||
'// 1 - CEF_REVISION\n'+\
|
||||
'// 1 - CEF_COMMIT_NUMBER\n'+\
|
||||
'// 2 - CHROME_VERSION_MAJOR\n'+\
|
||||
'// 3 - CHROME_VERSION_MINOR\n'+\
|
||||
'// 4 - CHROME_VERSION_BUILD\n'+\
|
||||
|
@ -155,6 +151,7 @@ def write_svn_header(header, chrome_version, cef_version, cpp_header_dir):
|
|||
'// hash value will be returned:\n'+\
|
||||
'// 0 - CEF_API_HASH_PLATFORM\n'+\
|
||||
'// 1 - CEF_API_HASH_UNIVERSAL\n'+\
|
||||
'// 2 - CEF_COMMIT_HASH\n'+\
|
||||
'///\n'+\
|
||||
'CEF_EXPORT const char* cef_api_hash(int entry);\n\n'+\
|
||||
'#ifdef __cplusplus\n'+\
|
||||
|
@ -168,7 +165,7 @@ def write_svn_header(header, chrome_version, cef_version, cpp_header_dir):
|
|||
|
||||
return False
|
||||
|
||||
written = write_svn_header(options.header, options.chrome_version, options.cef_version, options.cpp_header_dir)
|
||||
written = write_version_header(options.header, options.chrome_version, options.cef_version, options.cpp_header_dir)
|
||||
if not options.quiet:
|
||||
if written:
|
||||
sys.stdout.write('File '+options.header+' updated.\n')
|
||||
|
|
|
@ -7,7 +7,6 @@ import os
|
|||
import re
|
||||
import sys
|
||||
from exec_util import exec_cmd
|
||||
import svn_util as svn
|
||||
import git_util as git
|
||||
|
||||
def msg(message):
|
||||
|
@ -62,11 +61,7 @@ cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
|||
src_dir = os.path.join(cef_dir, os.pardir)
|
||||
|
||||
# Determine the type of Chromium checkout.
|
||||
if svn.is_checkout(src_dir):
|
||||
src_is_git = False
|
||||
elif git.is_checkout(src_dir):
|
||||
src_is_git = True
|
||||
else:
|
||||
if not git.is_checkout(src_dir):
|
||||
raise Exception('Not a valid checkout: %s' % src_dir)
|
||||
|
||||
patch_dir = os.path.join(cef_dir, 'patch')
|
||||
|
@ -104,10 +99,7 @@ for patch in patches:
|
|||
patch_path))
|
||||
if os.path.exists(patch_path_abs):
|
||||
msg('Reverting changes to %s' % patch_path_abs)
|
||||
if src_is_git:
|
||||
cmd = 'git checkout -- %s' % (patch_path_abs)
|
||||
else:
|
||||
cmd = 'svn revert %s' % (patch_path_abs)
|
||||
cmd = 'git checkout -- %s' % (patch_path_abs)
|
||||
result = exec_cmd(cmd, patch_root_abs)
|
||||
if result['err'] != '':
|
||||
msg('Failed to revert file: %s' % result['err'])
|
||||
|
@ -134,7 +126,7 @@ for patch in patches:
|
|||
|
||||
if not options.revert:
|
||||
msg('Saving changes to %s' % patch_file)
|
||||
if src_is_git and added_paths:
|
||||
if added_paths:
|
||||
# Inform git of the added paths so they appear in the patch file.
|
||||
cmd = 'git add -N %s' % ' '.join(added_paths)
|
||||
result = exec_cmd(cmd, patch_root_abs)
|
||||
|
@ -143,10 +135,7 @@ for patch in patches:
|
|||
|
||||
# Re-create the patch file.
|
||||
patch_paths_str = ' '.join(patch_paths)
|
||||
if src_is_git:
|
||||
cmd = 'git diff --no-prefix --relative %s' % patch_paths_str
|
||||
else:
|
||||
cmd = 'svn diff %s' % patch_paths_str
|
||||
cmd = 'git diff --no-prefix --relative %s' % patch_paths_str
|
||||
result = exec_cmd(cmd, patch_root_abs)
|
||||
if result['err'] != '' and result['err'].find('warning:') != 0:
|
||||
raise Exception('Failed to create patch file: %s' % result['err'])
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
# Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
|
||||
# reserved. Use of this source code is governed by a BSD-style license that
|
||||
# can be found in the LICENSE file
|
||||
|
||||
from exec_util import exec_cmd
|
||||
import os
|
||||
import urllib
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
def is_checkout(path):
|
||||
""" Returns true if the path represents an svn checkout. """
|
||||
return os.path.exists(os.path.join(path, '.svn'))
|
||||
|
||||
def check_url(url):
|
||||
""" Check the URL and raise an exception if invalid. """
|
||||
if ':' in url[:7]:
|
||||
parts = url.split(':', 1)
|
||||
if (parts[0] == 'http' or parts[0] == 'https' or parts[0] == 'svn') and \
|
||||
parts[1] == urllib.quote(parts[1]):
|
||||
return url
|
||||
raise Exception('Invalid URL: %s' % (url))
|
||||
|
||||
def get_svn_info(path = '.'):
|
||||
""" Retrieves the URL and revision from svn info. """
|
||||
url = 'None'
|
||||
rev = 'None'
|
||||
cmd = "svn info --xml %s" % (path)
|
||||
is_http = path[0:4] == 'http'
|
||||
if is_http or os.path.exists(path):
|
||||
result = exec_cmd(cmd, path if not is_http else '.')
|
||||
if result['err'] == '':
|
||||
tree = ET.ElementTree(ET.fromstring(result['out']))
|
||||
entry = tree.getroot().find('entry')
|
||||
url = entry.find('url').text
|
||||
rev = entry.attrib['revision']
|
||||
else:
|
||||
raise Exception("Failed to execute svn info: %s" % (result['err']))
|
||||
return {'url': url, 'revision': rev}
|
||||
|
||||
def get_revision(path = '.'):
|
||||
""" Retrieves the revision from svn info. """
|
||||
info = get_svn_info(path)
|
||||
if info['revision'] == 'None':
|
||||
raise Exception('Unable to retrieve SVN revision for %s' % (path))
|
||||
return info['revision']
|
||||
|
||||
def get_changed_files(path = '.'):
|
||||
""" Retrieves the list of changed files from svn status. """
|
||||
files = []
|
||||
if os.path.exists(path):
|
||||
try:
|
||||
stream = os.popen('svn status '+path)
|
||||
for line in stream:
|
||||
status = line[0]
|
||||
# Return paths with add, modify and switch status.
|
||||
if status == 'A' or status == 'M' or status == 'S':
|
||||
files.append(line[8:].strip())
|
||||
except IOError, (errno, strerror):
|
||||
raise
|
||||
return files
|
Loading…
Reference in New Issue