mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-07-04 20:17:16 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
37128b6f70 | |||
143b4cc992 | |||
53263d873d | |||
7487992bd3 | |||
b25ea555c3 | |||
3bfd72158c | |||
59b31cb6e0 | |||
1e7ab2a63f | |||
3a2a59eb87 |
@ -51,6 +51,12 @@ class _Default(object):
|
|||||||
sync_c = False
|
sync_c = False
|
||||||
sync_s = False
|
sync_s = False
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
|
def __ne__(self, other):
|
||||||
|
return self.__dict__ != other.__dict__
|
||||||
|
|
||||||
class _XmlRemote(object):
|
class _XmlRemote(object):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
name,
|
name,
|
||||||
@ -91,6 +97,8 @@ class _XmlRemote(object):
|
|||||||
def ToRemoteSpec(self, projectName):
|
def ToRemoteSpec(self, projectName):
|
||||||
url = self.resolvedFetchUrl.rstrip('/') + '/' + projectName
|
url = self.resolvedFetchUrl.rstrip('/') + '/' + projectName
|
||||||
remoteName = self.name
|
remoteName = self.name
|
||||||
|
if self.remoteAlias:
|
||||||
|
remoteName = self.remoteAlias
|
||||||
return RemoteSpec(remoteName, url, self.reviewUrl)
|
return RemoteSpec(remoteName, url, self.reviewUrl)
|
||||||
|
|
||||||
class XmlManifest(object):
|
class XmlManifest(object):
|
||||||
@ -145,6 +153,8 @@ class XmlManifest(object):
|
|||||||
root.appendChild(e)
|
root.appendChild(e)
|
||||||
e.setAttribute('name', r.name)
|
e.setAttribute('name', r.name)
|
||||||
e.setAttribute('fetch', r.fetchUrl)
|
e.setAttribute('fetch', r.fetchUrl)
|
||||||
|
if r.remoteAlias is not None:
|
||||||
|
e.setAttribute('alias', r.remoteAlias)
|
||||||
if r.reviewUrl is not None:
|
if r.reviewUrl is not None:
|
||||||
e.setAttribute('review', r.reviewUrl)
|
e.setAttribute('review', r.reviewUrl)
|
||||||
|
|
||||||
@ -223,7 +233,8 @@ class XmlManifest(object):
|
|||||||
e.setAttribute('name', name)
|
e.setAttribute('name', name)
|
||||||
if relpath != name:
|
if relpath != name:
|
||||||
e.setAttribute('path', relpath)
|
e.setAttribute('path', relpath)
|
||||||
if not d.remote or p.remote.name != d.remote.name:
|
remoteName = d.remote.remoteAlias or d.remote.name
|
||||||
|
if not d.remote or p.remote.name != remoteName:
|
||||||
e.setAttribute('remote', p.remote.name)
|
e.setAttribute('remote', p.remote.name)
|
||||||
if peg_rev:
|
if peg_rev:
|
||||||
if self.IsMirror:
|
if self.IsMirror:
|
||||||
@ -422,11 +433,13 @@ class XmlManifest(object):
|
|||||||
|
|
||||||
for node in itertools.chain(*node_list):
|
for node in itertools.chain(*node_list):
|
||||||
if node.nodeName == 'default':
|
if node.nodeName == 'default':
|
||||||
if self._default is not None:
|
new_default = self._ParseDefault(node)
|
||||||
raise ManifestParseError(
|
if self._default is None:
|
||||||
'duplicate default in %s' %
|
self._default = new_default
|
||||||
(self.manifestFile))
|
elif new_default != self._default:
|
||||||
self._default = self._ParseDefault(node)
|
raise ManifestParseError('duplicate default in %s' %
|
||||||
|
(self.manifestFile))
|
||||||
|
|
||||||
if self._default is None:
|
if self._default is None:
|
||||||
self._default = _Default()
|
self._default = _Default()
|
||||||
|
|
||||||
|
4
repo
4
repo
@ -739,7 +739,7 @@ def main(orig_args):
|
|||||||
repo_main = my_main
|
repo_main = my_main
|
||||||
|
|
||||||
ver_str = '.'.join(map(str, VERSION))
|
ver_str = '.'.join(map(str, VERSION))
|
||||||
me = [repo_main,
|
me = [sys.executable, repo_main,
|
||||||
'--repo-dir=%s' % rel_repo_dir,
|
'--repo-dir=%s' % rel_repo_dir,
|
||||||
'--wrapper-version=%s' % ver_str,
|
'--wrapper-version=%s' % ver_str,
|
||||||
'--wrapper-path=%s' % wrapper_path,
|
'--wrapper-path=%s' % wrapper_path,
|
||||||
@ -747,7 +747,7 @@ def main(orig_args):
|
|||||||
me.extend(orig_args)
|
me.extend(orig_args)
|
||||||
me.extend(extra_args)
|
me.extend(extra_args)
|
||||||
try:
|
try:
|
||||||
os.execv(repo_main, me)
|
os.execv(sys.executable, me)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
_print("fatal: unable to start %s" % repo_main, file=sys.stderr)
|
_print("fatal: unable to start %s" % repo_main, file=sys.stderr)
|
||||||
_print("fatal: %s" % e, file=sys.stderr)
|
_print("fatal: %s" % e, file=sys.stderr)
|
||||||
|
@ -21,6 +21,7 @@ import sys
|
|||||||
from command import InteractiveCommand
|
from command import InteractiveCommand
|
||||||
from editor import Editor
|
from editor import Editor
|
||||||
from error import HookError, UploadError
|
from error import HookError, UploadError
|
||||||
|
from git_command import GitCommand
|
||||||
from project import RepoHook
|
from project import RepoHook
|
||||||
|
|
||||||
from pyversion import is_python3
|
from pyversion import is_python3
|
||||||
@ -344,7 +345,20 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
|||||||
key = 'review.%s.uploadtopic' % branch.project.remote.review
|
key = 'review.%s.uploadtopic' % branch.project.remote.review
|
||||||
opt.auto_topic = branch.project.config.GetBoolean(key)
|
opt.auto_topic = branch.project.config.GetBoolean(key)
|
||||||
|
|
||||||
destination = opt.dest_branch or branch.project.dest_branch or branch.project.revisionExpr
|
destination = opt.dest_branch or branch.project.dest_branch
|
||||||
|
|
||||||
|
# Make sure our local branch is not setup to track a different remote branch
|
||||||
|
merge_branch = self._GetMergeBranch(branch.project)
|
||||||
|
full_dest = 'refs/heads/%s' % destination
|
||||||
|
if not opt.dest_branch and merge_branch and merge_branch != full_dest:
|
||||||
|
print('merge branch %s does not match destination branch %s'
|
||||||
|
% (merge_branch, full_dest))
|
||||||
|
print('skipping upload.')
|
||||||
|
print('Please use `--destination %s` if this is intentional'
|
||||||
|
% destination)
|
||||||
|
branch.uploaded = False
|
||||||
|
continue
|
||||||
|
|
||||||
branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft, dest_branch=destination)
|
branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft, dest_branch=destination)
|
||||||
branch.uploaded = True
|
branch.uploaded = True
|
||||||
except UploadError as e:
|
except UploadError as e:
|
||||||
@ -379,6 +393,21 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
|
|||||||
if have_errors:
|
if have_errors:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def _GetMergeBranch(self, project):
|
||||||
|
p = GitCommand(project,
|
||||||
|
['rev-parse', '--abbrev-ref', 'HEAD'],
|
||||||
|
capture_stdout = True,
|
||||||
|
capture_stderr = True)
|
||||||
|
p.Wait()
|
||||||
|
local_branch = p.stdout.strip()
|
||||||
|
p = GitCommand(project,
|
||||||
|
['config', '--get', 'branch.%s.merge' % local_branch],
|
||||||
|
capture_stdout = True,
|
||||||
|
capture_stderr = True)
|
||||||
|
p.Wait()
|
||||||
|
merge_branch = p.stdout.strip()
|
||||||
|
return merge_branch
|
||||||
|
|
||||||
def Execute(self, opt, args):
|
def Execute(self, opt, args):
|
||||||
project_list = self.GetProjects(args)
|
project_list = self.GetProjects(args)
|
||||||
pending = []
|
pending = []
|
||||||
|
Reference in New Issue
Block a user