diff options
| -rw-r--r-- | manifest_xml.py | 7 | ||||
| -rwxr-xr-x | repo | 4 | ||||
| -rw-r--r-- | subcmds/upload.py | 31 |
3 files changed, 38 insertions, 4 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index eb4908da..c5e2e345 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -97,6 +97,8 @@ class _XmlRemote(object): | |||
| 97 | def ToRemoteSpec(self, projectName): | 97 | def ToRemoteSpec(self, projectName): |
| 98 | url = self.resolvedFetchUrl.rstrip('/') + '/' + projectName | 98 | url = self.resolvedFetchUrl.rstrip('/') + '/' + projectName |
| 99 | remoteName = self.name | 99 | remoteName = self.name |
| 100 | if self.remoteAlias: | ||
| 101 | remoteName = self.remoteAlias | ||
| 100 | return RemoteSpec(remoteName, url, self.reviewUrl) | 102 | return RemoteSpec(remoteName, url, self.reviewUrl) |
| 101 | 103 | ||
| 102 | class XmlManifest(object): | 104 | class XmlManifest(object): |
| @@ -151,6 +153,8 @@ class XmlManifest(object): | |||
| 151 | root.appendChild(e) | 153 | root.appendChild(e) |
| 152 | e.setAttribute('name', r.name) | 154 | e.setAttribute('name', r.name) |
| 153 | e.setAttribute('fetch', r.fetchUrl) | 155 | e.setAttribute('fetch', r.fetchUrl) |
| 156 | if r.remoteAlias is not None: | ||
| 157 | e.setAttribute('alias', r.remoteAlias) | ||
| 154 | if r.reviewUrl is not None: | 158 | if r.reviewUrl is not None: |
| 155 | e.setAttribute('review', r.reviewUrl) | 159 | e.setAttribute('review', r.reviewUrl) |
| 156 | 160 | ||
| @@ -229,7 +233,8 @@ class XmlManifest(object): | |||
| 229 | e.setAttribute('name', name) | 233 | e.setAttribute('name', name) |
| 230 | if relpath != name: | 234 | if relpath != name: |
| 231 | e.setAttribute('path', relpath) | 235 | e.setAttribute('path', relpath) |
| 232 | if not d.remote or p.remote.name != d.remote.name: | 236 | remoteName = d.remote.remoteAlias or d.remote.name |
| 237 | if not d.remote or p.remote.name != remoteName: | ||
| 233 | e.setAttribute('remote', p.remote.name) | 238 | e.setAttribute('remote', p.remote.name) |
| 234 | if peg_rev: | 239 | if peg_rev: |
| 235 | if self.IsMirror: | 240 | if self.IsMirror: |
| @@ -739,7 +739,7 @@ def main(orig_args): | |||
| 739 | repo_main = my_main | 739 | repo_main = my_main |
| 740 | 740 | ||
| 741 | ver_str = '.'.join(map(str, VERSION)) | 741 | ver_str = '.'.join(map(str, VERSION)) |
| 742 | me = [repo_main, | 742 | me = [sys.executable, repo_main, |
| 743 | '--repo-dir=%s' % rel_repo_dir, | 743 | '--repo-dir=%s' % rel_repo_dir, |
| 744 | '--wrapper-version=%s' % ver_str, | 744 | '--wrapper-version=%s' % ver_str, |
| 745 | '--wrapper-path=%s' % wrapper_path, | 745 | '--wrapper-path=%s' % wrapper_path, |
| @@ -747,7 +747,7 @@ def main(orig_args): | |||
| 747 | me.extend(orig_args) | 747 | me.extend(orig_args) |
| 748 | me.extend(extra_args) | 748 | me.extend(extra_args) |
| 749 | try: | 749 | try: |
| 750 | os.execv(repo_main, me) | 750 | os.execv(sys.executable, me) |
| 751 | except OSError as e: | 751 | except OSError as e: |
| 752 | _print("fatal: unable to start %s" % repo_main, file=sys.stderr) | 752 | _print("fatal: unable to start %s" % repo_main, file=sys.stderr) |
| 753 | _print("fatal: %s" % e, file=sys.stderr) | 753 | _print("fatal: %s" % e, file=sys.stderr) |
diff --git a/subcmds/upload.py b/subcmds/upload.py index f5833dd3..8d801e08 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -21,6 +21,7 @@ import sys | |||
| 21 | from command import InteractiveCommand | 21 | from command import InteractiveCommand |
| 22 | from editor import Editor | 22 | from editor import Editor |
| 23 | from error import HookError, UploadError | 23 | from error import HookError, UploadError |
| 24 | from git_command import GitCommand | ||
| 24 | from project import RepoHook | 25 | from project import RepoHook |
| 25 | 26 | ||
| 26 | from pyversion import is_python3 | 27 | from pyversion import is_python3 |
| @@ -344,7 +345,20 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 344 | key = 'review.%s.uploadtopic' % branch.project.remote.review | 345 | key = 'review.%s.uploadtopic' % branch.project.remote.review |
| 345 | opt.auto_topic = branch.project.config.GetBoolean(key) | 346 | opt.auto_topic = branch.project.config.GetBoolean(key) |
| 346 | 347 | ||
| 347 | destination = opt.dest_branch or branch.project.dest_branch or branch.project.revisionExpr | 348 | destination = opt.dest_branch or branch.project.dest_branch |
| 349 | |||
| 350 | # Make sure our local branch is not setup to track a different remote branch | ||
| 351 | merge_branch = self._GetMergeBranch(branch.project) | ||
| 352 | full_dest = 'refs/heads/%s' % destination | ||
| 353 | if not opt.dest_branch and merge_branch and merge_branch != full_dest: | ||
| 354 | print('merge branch %s does not match destination branch %s' | ||
| 355 | % (merge_branch, full_dest)) | ||
| 356 | print('skipping upload.') | ||
| 357 | print('Please use `--destination %s` if this is intentional' | ||
| 358 | % destination) | ||
| 359 | branch.uploaded = False | ||
| 360 | continue | ||
| 361 | |||
| 348 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft, dest_branch=destination) | 362 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft, dest_branch=destination) |
| 349 | branch.uploaded = True | 363 | branch.uploaded = True |
| 350 | except UploadError as e: | 364 | except UploadError as e: |
| @@ -379,6 +393,21 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 379 | if have_errors: | 393 | if have_errors: |
| 380 | sys.exit(1) | 394 | sys.exit(1) |
| 381 | 395 | ||
| 396 | def _GetMergeBranch(self, project): | ||
| 397 | p = GitCommand(project, | ||
| 398 | ['rev-parse', '--abbrev-ref', 'HEAD'], | ||
| 399 | capture_stdout = True, | ||
| 400 | capture_stderr = True) | ||
| 401 | p.Wait() | ||
| 402 | local_branch = p.stdout.strip() | ||
| 403 | p = GitCommand(project, | ||
| 404 | ['config', '--get', 'branch.%s.merge' % local_branch], | ||
| 405 | capture_stdout = True, | ||
| 406 | capture_stderr = True) | ||
| 407 | p.Wait() | ||
| 408 | merge_branch = p.stdout.strip() | ||
| 409 | return merge_branch | ||
| 410 | |||
| 382 | def Execute(self, opt, args): | 411 | def Execute(self, opt, args): |
| 383 | project_list = self.GetProjects(args) | 412 | project_list = self.GetProjects(args) |
| 384 | pending = [] | 413 | pending = [] |
