| Index: testing_support/fake_repos.py
|
| diff --git a/testing_support/fake_repos.py b/testing_support/fake_repos.py
|
| index 25e3a9be1c1be6b4ec8415a23f56214e15e979d5..3c5ac54fdbaa8d8e3f9c68edaadeba235c54dbb6 100755
|
| --- a/testing_support/fake_repos.py
|
| +++ b/testing_support/fake_repos.py
|
| @@ -88,6 +88,22 @@ def commit_svn(repo, usr, pwd):
|
| logging.debug('At revision %s' % rev)
|
| return rev
|
|
|
| +def update_ref_git(repo, ref, oldvalue, newvalue=None):
|
| + args = ['git', 'update-ref', ref, oldvalue]
|
| + if newvalue is not None:
|
| + args.append(newvalue)
|
| + subprocess2.check_call(args, cwd=repo)
|
| +
|
| +def checkout_git(repo, branch=None):
|
| + """Checks out (creating, if necessary) the target branch."""
|
| + if branch is None:
|
| + branch = 'master'
|
| + returncode = subprocess2.call(['git', 'show-ref', '-q', branch], cwd=repo)
|
| + if returncode == 0:
|
| + subprocess2.check_call(['git', 'checkout', '-q', branch], cwd=repo)
|
| + else:
|
| + subprocess2.check_call(['git', 'checkout', '-q', '-B', branch], cwd=repo)
|
| + return branch
|
|
|
| def commit_git(repo):
|
| """Commits the changes and returns the new hash."""
|
| @@ -408,10 +424,16 @@ class FakeReposBase(object):
|
| '--password', self.USERS[0][1],
|
| '--non-interactive'])
|
|
|
| - def _commit_git(self, repo, tree):
|
| + def _update_ref_git(self, repo, ref, oldvalue, newvalue=None):
|
| repo_root = join(self.git_root, repo)
|
| + update_ref_git(repo_root, ref, oldvalue, newvalue=newvalue)
|
| +
|
| + def _commit_git(self, repo, tree, branch=None):
|
| + repo_root = join(self.git_root, repo)
|
| + checkout_git(repo_root, branch)
|
| self._genTree(repo_root, tree)
|
| commit_hash = commit_git(repo_root)
|
| + checkout_git(repo_root)
|
| if self.git_hashes[repo][-1]:
|
| new_tree = self.git_hashes[repo][-1][1].copy()
|
| new_tree.update(tree)
|
| @@ -439,7 +461,7 @@ class FakeReposBase(object):
|
|
|
| class FakeRepos(FakeReposBase):
|
| """Implements populateSvn() and populateGit()."""
|
| - NB_GIT_REPOS = 5
|
| + NB_GIT_REPOS = 6
|
|
|
| def populateSvn(self):
|
| """Creates a few revisions of changes including DEPS files."""
|
| @@ -706,6 +728,14 @@ pre_deps_hooks = [
|
| 'origin': 'git/repo_5@3\n',
|
| })
|
|
|
| + # repo_6: basic repository that exists in a non-default Gerrit-like
|
| + # location on remote
|
| + self._commit_git('repo_6', {'origin': 'git/repo_6@1\n'})
|
| + self._commit_git('repo_6', {'origin': 'git/repo_6@alternate\n'},
|
| + branch='alternate')
|
| + self._update_ref_git('repo_6', 'refs/changes/12/1', 'alternate')
|
| + self._commit_git('repo_6', {'origin': 'git/repo_6@2\n'})
|
| +
|
|
|
| class FakeRepoTransitive(FakeReposBase):
|
| """Implements populateSvn()"""
|
|
|