本文整理汇总了Python中util.hg.make_hg_url函数的典型用法代码示例。如果您正苦于以下问题:Python make_hg_url函数的具体用法?Python make_hg_url怎么用?Python make_hg_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_hg_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: verify_configs
def verify_configs(configs_dir, revision, hghost, configs_repo, changesets,
filename):
"""Check the release_configs and l10n-changesets against tagged
revisions"""
release_config_file = path.join(configs_dir, 'mozilla', filename)
l10n_changesets_file = path.join(configs_dir, 'mozilla', changesets)
configs_url = make_hg_url(hghost, configs_repo, revision=revision,
filename=path.join('mozilla', filename))
l10n_url = make_hg_url(hghost, configs_repo, revision=revision,
filename=path.join('mozilla', changesets))
success = True
try:
official_configs = urllib2.urlopen(configs_url)
log.info("Comparing tagged revision %s to on-disk %s ..." % (
configs_url, filename))
if not compare(official_configs, release_config_file):
log.error("local configs do not match tagged revisions in repo")
success = False
error_tally.add('verify_configs')
l10n_changesets = urllib2.urlopen(l10n_url)
log.info("Comparing tagged revision %s to on-disk %s ..." % (
l10n_url, changesets))
if not compare(l10n_changesets, l10n_changesets_file):
log.error("local l10n-changesets do not match tagged revisions"
" in repo")
success = False
error_tally.add('verify_configs')
except urllib2.HTTPError:
log.error("cannot find configs in repo %s" % configs_url)
log.error("cannot find configs in repo %s" % l10n_url)
success = False
error_tally.add('verify_configs')
return success
示例2: tagOtherRepo
def tagOtherRepo(config, repo, reponame, revision, pushAttempts):
remote = make_hg_url(HG, repo)
mercurial(remote, reponame)
def tagRepo(repo, attempt, config, revision, tags):
# set totalChangesets=1 because tag() generates exactly 1 commit
totalChangesets = 1
# update to the desired revision first, then to the tip of revision's
# branch to avoid new head creation
update(repo, revision=revision)
update(repo)
tag(repo, revision, tags, config['hgUsername'])
outgoingRevs = retry(out, kwargs=dict(src=reponame, remote=remote,
ssh_username=config[
'hgUsername'],
ssh_key=config['hgSshKey']))
if len(outgoingRevs) != totalChangesets:
raise Exception("Wrong number of outgoing revisions")
pushRepo = make_hg_url(HG, repo, protocol='ssh')
def tag_wrapper(r, n):
tagRepo(r, n, config, revision, tags)
def cleanup_wrapper():
cleanOutgoingRevs(reponame, pushRepo, config['hgUsername'],
config['hgSshKey'])
retry(apply_and_push, cleanup=cleanup_wrapper,
args=(reponame, pushRepo, tag_wrapper, pushAttempts),
kwargs=dict(ssh_username=config['hgUsername'],
ssh_key=config['hgSshKey']))
示例3: testMakeHGUrlNoRevisionNoFilename
def testMakeHGUrlNoRevisionNoFilename(self):
repo_url = make_hg_url(
"hg.mozilla.org",
"/build/tools"
)
expected_url = "https://hg.mozilla.org/build/tools"
self.assertEquals(repo_url, expected_url)
示例4: testMakeHGUrl
def testMakeHGUrl(self):
# construct an hg url specific to revision, branch and filename and try
# to pull it down
file_url = make_hg_url(
"hg.mozilla.org", "//build/tools/", revision="FIREFOX_3_6_12_RELEASE", filename="/lib/python/util/hg.py"
)
expected_url = "https://hg.mozilla.org/build/tools/raw-file/FIREFOX_3_6_12_RELEASE/lib/python/util/hg.py"
self.assertEquals(file_url, expected_url)
示例5: testMakeHGUrlDifferentProtocol
def testMakeHGUrlDifferentProtocol(self):
repo_url = make_hg_url(
"hg.mozilla.org",
"/build/tools",
protocol='ssh'
)
expected_url = "ssh://hg.mozilla.org/build/tools"
self.assertEquals(repo_url, expected_url)
示例6: testMakeHGUrlNoFilename
def testMakeHGUrlNoFilename(self):
file_url = make_hg_url(
"hg.mozilla.org",
"/build/tools",
revision="default"
)
expected_url = "https://hg.mozilla.org/build/tools/rev/default"
self.assertEquals(file_url, expected_url)
示例7: bump_configs
def bump_configs(server, username, sshKey, repo, repoPath, configsToBump,
configsToOverride):
reponame = get_repo_name(repo)
repo_url = make_hg_url(server, '%s/%s' % (repoPath, reponame))
pushRepo = make_hg_url(server, '%s/%s' % (repoPath, reponame),
protocol='ssh')
retry(mercurial, args=(repo_url, reponame))
def bump(repo, configsToBump, configsToOverride):
"""Process dynamic (version, buildNumber, etc.) variables in
configsToBump, then append overrides files to both configsToBump and
configsToOverride."""
# First pass. Bump variables in configsToBump.
configs = ['%s/%s' % (repo, x) for x in configsToBump.keys()]
cmd = ['python', BUMP_SCRIPT, '--bump-version', '--revision=tip']
cmd.extend(configs)
run_cmd(cmd)
# Second pass. Append override files to configsToBump and
# configsToOverride.
for config, overrides in \
configsToBump.items() + configsToOverride.items():
newContent = cat([path.join(repo, config)] +
[path.join(repo, x) for x in overrides])
fh = open(path.join(repo, config), 'wb')
fh.write(newContent)
fh.close()
run_cmd(['hg', 'commit', '-m', 'Automatic config bump'],
cwd=repo)
def bump_wrapper(r, n):
bump(r, configsToBump, configsToOverride)
def cleanup_wrapper():
cleanOutgoingRevs(reponame, pushRepo, username, sshKey)
retry(apply_and_push, cleanup=cleanup_wrapper,
args=(reponame, pushRepo, bump_wrapper),
kwargs=dict(ssh_username=username, ssh_key=sshKey))
tags = []
for configfile in configsToBump.keys():
config = readReleaseConfig(path.join(reponame, configfile))
tags.extend(getTags(config['baseTag'], config['buildNumber'],
buildTag=True))
return tags
示例8: tagRepo
def tagRepo(config, repo, reponame, revision, tags, bumpFiles, relbranch,
pushAttempts, defaultBranch='default'):
remote = make_hg_url(HG, repo)
mercurial(remote, reponame)
def bump_and_tag(repo, attempt, config, relbranch, revision, tags,
defaultBranch):
# set relbranchChangesets=1 because tag() generates exactly 1 commit
relbranchChangesets = 1
defaultBranchChangesets = 0
if relbranch in get_branches(reponame):
update(reponame, revision=relbranch)
else:
update(reponame, revision=revision)
run_cmd(['hg', 'branch', relbranch], cwd=reponame)
if len(bumpFiles) > 0:
# Bump files on the relbranch, if necessary
bump(reponame, bumpFiles, 'version')
run_cmd(['hg', 'diff'], cwd=repo)
try:
get_output(['hg', 'commit', '-u', config['hgUsername'],
'-m', getBumpCommitMessage(config['productName'], config['version'])],
cwd=reponame)
relbranchChangesets += 1
except subprocess.CalledProcessError, e:
# We only want to ignore exceptions caused by having nothing to
# commit, which are OK. We still want to raise exceptions caused
# by any other thing.
if e.returncode != 1 or "nothing changed" not in e.output:
raise
# We always want our tags pointing at the tip of the relbranch
# so we need to grab the current revision after we've switched
# branches and bumped versions.
revision = get_revision(reponame)
# Create the desired tags on the relbranch
tag(repo, revision, tags, config['hgUsername'])
# This is the bump of the version on the default branch
# We do it after the other one in order to get the tip of the
# repository back on default, thus avoiding confusion.
if len(bumpFiles) > 0:
update(reponame, revision=defaultBranch)
bump(reponame, bumpFiles, 'nextVersion')
run_cmd(['hg', 'diff'], cwd=repo)
try:
get_output(['hg', 'commit', '-u', config['hgUsername'],
'-m', getBumpCommitMessage(config['productName'], config['version'])],
cwd=reponame)
defaultBranchChangesets += 1
except subprocess.CalledProcessError, e:
if e.returncode != 1 or "nothing changed" not in e.output:
raise
示例9: tag_repo
def tag_repo(server, username, sshKey, repo, repoPath, tags):
reponame = get_repo_name(repo)
repo_url = make_hg_url(server, '%s/%s' % (repoPath, reponame))
pushRepo = make_hg_url(server, '%s/%s' % (repoPath, reponame),
protocol='ssh')
mercurial(repo_url, reponame)
def do_tag(repo, tags):
cmd = ['hg', 'tag', '-f', '-m', 'Automatic preproduction tag'] + tags
run_cmd(cmd, cwd=repo)
def do_tag_wrapper(r, n):
do_tag(r, tags)
def cleanup_wrapper():
cleanOutgoingRevs(reponame, pushRepo, username, sshKey)
retry(apply_and_push, cleanup=cleanup_wrapper,
args=(reponame, pushRepo, do_tag_wrapper),
kwargs=dict(ssh_username=username, ssh_key=sshKey))
示例10: maybe_delete_repo
def maybe_delete_repo(server, username, sshKey, repo, repoPath):
reponame = get_repo_name(repo)
repo_url = make_hg_url(server, '%s/%s' % (repoPath, reponame))
try:
log.info("Trying to open %s" % repo_url)
urlopen(repo_url)
except URLError:
log.info("%s doesn't exist, not deleting" % reponame)
else:
log.info('Deleting %s' % reponame)
retry(run_remote_cmd, args=('edit %s delete YES' % reponame, server,
username, sshKey))
示例11: tagOtherRepo
def tagOtherRepo(config, repo, reponame, revision, pushAttempts):
remote = make_hg_url(HG, repo)
retry(mercurial, args=(remote, reponame))
def tagRepo(repo, attempt, config, revision, tags):
totalChangesets = len(tags)
tag(repo, revision, tags, config['hgUsername'])
outgoingRevs = retry(out, kwargs=dict(src=reponame, remote=remote,
ssh_username=config['hgUsername'],
ssh_key=config['hgSshKey']))
if len(outgoingRevs) != totalChangesets:
raise Exception("Wrong number of outgoing revisions")
pushRepo = make_hg_url(HG, repo, protocol='ssh')
def tag_wrapper(r, n):
tagRepo(r, n, config, revision, tags)
def cleanup_wrapper():
cleanOutgoingRevs(reponame, pushRepo, config['hgUsername'],
config['hgSshKey'])
retry(apply_and_push, cleanup=cleanup_wrapper,
args=(reponame, pushRepo, tag_wrapper, pushAttempts),
kwargs=dict(ssh_username=config['hgUsername'],
ssh_key=config['hgSshKey']))
示例12: verify_repo
def verify_repo(branch, revision, hghost):
"""Poll the hgweb interface for a given branch and revision to
make sure it exists"""
repo_url = make_hg_url(hghost, branch, revision=revision)
log.info("Checking for existence of %s..." % repo_url)
success = True
try:
repo_page = urllib2.urlopen(repo_url)
log.info("Got: %s !" % repo_page.geturl())
except urllib2.HTTPError:
log.error("Repo does not exist with required revision. Check again, or use -b to bypass")
success = False
error_tally.add('verify_repo')
return success
示例13: verify_mozconfigs
def verify_mozconfigs(branch, revision, hghost, product, mozconfigs, appName, whitelist=None):
"""Compare nightly mozconfigs for branch to release mozconfigs and compare to whitelist of known differences"""
if whitelist:
mozconfigWhitelist = readConfig(whitelist, ['whitelist'])
else:
mozconfigWhitelist = {}
log.info("Comparing %s mozconfigs to nightly mozconfigs..." % product)
success = True
types = {'+': 'release', '-': 'nightly'}
for platform,mozconfig in mozconfigs.items():
urls = []
mozconfigs = []
# Create links to the two mozconfigs.
releaseConfig = make_hg_url(hghost, branch, 'http', revision, mozconfig)
urls.append(releaseConfig)
# The nightly one is the exact same URL, with the file part changed.
urls.append(releaseConfig.rstrip('release') + 'nightly')
for url in urls:
try:
mozconfigs.append(urllib2.urlopen(url).readlines())
except urllib2.HTTPError as e:
log.error("MISSING: %s - ERROR: %s" % (url, e.msg))
diffInstance = difflib.Differ()
if len(mozconfigs) == 2:
diffList = list(diffInstance.compare(mozconfigs[0],mozconfigs[1]))
for line in diffList:
clean_line = line[1:].strip()
if (line[0] == '-' or line[0] == '+') and len(clean_line) > 1:
# skip comment lines
if clean_line.startswith('#'):
continue
# compare to whitelist
if line[0] == '-' and mozconfigWhitelist.get(branch, {}).has_key(platform) \
and clean_line in mozconfigWhitelist[branch][platform]:
continue
if line[0] == '+' and mozconfigWhitelist.get('nightly', {}).has_key(platform) \
and clean_line in mozconfigWhitelist['nightly'][platform]:
continue
if line[0] == '-':
opposite = 'release'
else:
opposite = 'nightly'
log.error("not in %s mozconfig's whitelist (%s/%s/%s) : %s" % (opposite, branch, platform, types[line[0]], clean_line))
success = False
error_tally.add('verify_mozconfig')
else:
log.info("Missing mozconfigs to compare for %s" % platform)
error_tally.add("verify_mozconfigs: Confirm that %s does not have release/nightly mozconfigs to compare" % platform)
return success
示例14: verify_mozconfigs
def verify_mozconfigs(branch, version, hghost, product, platforms, whitelist=None):
"""Compare nightly mozconfigs for branch to release mozconfigs and compare to whitelist of known differences"""
if whitelist:
mozconfigWhitelist = readConfig(whitelist, ['whitelist'])
else:
mozconfigWhitelist = {}
log.info("Comparing %s mozconfigs to nightly mozconfigs..." % product)
success = True
types = {'+': 'release', '-': 'nightly'}
tag = ''.join([product.upper(), "_", version.replace('.','_'), "_RELEASE"])
for platform in platforms:
urls = []
mozconfigs = []
for type in types.values():
urls.append(make_hg_url(hghost, 'build/buildbot-configs', 'http',
tag, os.path.join('mozilla2', platform,
branch, type,'mozconfig')))
for url in urls:
try:
mozconfigs.append(urllib2.urlopen(url).readlines())
except urllib2.HTTPError as e:
log.error("MISSING: %s - ERROR: %s" % (url, e.msg))
diffInstance = difflib.Differ()
if len(mozconfigs) == 2:
diffList = list(diffInstance.compare(mozconfigs[0],mozconfigs[1]))
for line in diffList:
clean_line = line[1:].strip()
if (line[0] == '-' or line[0] == '+') and len(clean_line) > 1:
# skip comment lines
if clean_line.startswith('#'):
continue
# compare to whitelist
if line[0] == '-' and mozconfigWhitelist.get(branch, {}).has_key(platform) \
and clean_line in mozconfigWhitelist[branch][platform]:
continue
if line[0] == '+' and mozconfigWhitelist.get('nightly', {}).has_key(platform) \
and clean_line in mozconfigWhitelist['nightly'][platform]:
continue
if line[0] == '-':
opposite = 'release'
else:
opposite = 'nightly'
log.error("not in %s mozconfig's whitelist (%s/%s/%s) : %s" % (opposite, branch, platform, types[line[0]], clean_line))
success = False
error_tally.add('verify_mozconfig')
else:
log.info("Missing mozconfigs to compare for %s" % platform)
error_tally.add("verify_mozconfigs: Confirm that %s does not have release/nightly mozconfigs to compare" % platform)
return success
示例15: tagRepo
def tagRepo(config, repo, reponame, revision, tags, bumpFiles, relbranch,
pushAttempts):
remote = make_hg_url(HG, repo)
mercurial(remote, reponame)
def bump_and_tag(repo, attempt, config, relbranch, revision, tags):
# set relbranchChangesets=1 because tag() generates exactly 1 commit
relbranchChangesets = 1
if relbranch in get_branches(reponame):
update(reponame, revision=relbranch)
else:
update(reponame, revision=revision)
run_cmd(['hg', 'branch', relbranch], cwd=reponame)
if len(bumpFiles) > 0:
# Bump files on the relbranch, if necessary
bump(reponame, bumpFiles, 'version')
run_cmd(['hg', 'diff'], cwd=repo)
try:
get_output(['hg', 'commit', '-u', config['hgUsername'],
'-m', getBumpCommitMessage(config['productName'], config['version'])],
cwd=reponame)
relbranchChangesets += 1
except subprocess.CalledProcessError, e:
# We only want to ignore exceptions caused by having nothing to
# commit, which are OK. We still want to raise exceptions caused
# by any other thing.
if e.returncode != 1 or "nothing changed" not in e.output:
raise
# We always want our tags pointing at the tip of the relbranch
# so we need to grab the current revision after we've switched
# branches and bumped versions.
revision = get_revision(reponame)
# Create the desired tags on the relbranch
tag(repo, revision, tags, config['hgUsername'])
# Validate that the repository is only different from the remote in
# ways we expect.
outgoingRevs = out(src=reponame, remote=remote,
ssh_username=config['hgUsername'],
ssh_key=config['hgSshKey'])
if len([r for r in outgoingRevs if r[BRANCH] == relbranch]) != relbranchChangesets:
raise Exception("Incorrect number of revisions on %s" % relbranch)
if len(outgoingRevs) != relbranchChangesets:
raise Exception("Wrong number of outgoing revisions")