# Path: testing_support/fake_repos.py
# def write(path, content):
# def read_tree(tree_root):
# def dict_diff(dict1, dict2):
# def commit_svn(repo, usr, pwd):
# def commit_git(repo):
# def test_port(host, port):
# def find_free_port(host, base_port):
# def wait_for_port_to_bind(host, port, process):
# def wait_for_port_to_free(host, port):
#   def __init__(self, host=None):
#   def root_dir(self):
#   def set_up(self):
#   def cleanup_dirt(self):
#   def tear_down(self):
#   def tear_down_svn(self):
#   def tear_down_git(self):
#   def _genTree(root, tree_dict):
#   def set_up_svn(self):
#   def set_up_git(self):
#   def _commit_svn(self, tree):
#   def _set_svn_commit_date(self, revision, date):
#   def _commit_git(self, repo, tree):
#   def check_port_is_free(self, port):
#   def populateSvn(self):
#   def populateGit(self):
#   def populateSvn(self):
#     def file_system(rev, DEPS, DEPS_ALT=None):
#   def populateGit(self):
#   def populateSvn(self):
#     def file_system(rev):
#   def populateGit(self):
#   def setUp(self):
#   def svn_base(self):
#   def git_base(self):
#   def checkString(self, expected, result, msg=None):
#   def check(self, expected, results):
#   def assertTree(self, tree, tree_root=None):
#   def mangle_svn_tree(self, *args):
#   def mangle_git_tree(self, *args):
#   def githash(self, repo, rev):
#   def gittree(self, repo, rev):
# def main(argv):
# class FakeReposBase(object):
# class FakeRepos(FakeReposBase):
# class FakeRepoTransitive(FakeReposBase):
# class FakeReposTestBase(trial_dir.TestCase):
#   NB_GIT_REPOS = 1
#   USERS = [
#       ('user1@example.com', 'foo'),
#       ('user2@example.com', 'bar'),
#   ]
#   NB_GIT_REPOS = 5
#     DEPS = """
# vars = {
#   'DummyVariable': 'third_party',
# }
# deps = {
#   'src/other': '%(svn_base)strunk/other@1',
#   'src/third_party/fpp': '/trunk/' + Var('DummyVariable') + '/foo',
# }
# deps_os = {
#   'mac': {
#     'src/third_party/prout': '/trunk/third_party/prout',
#   },
# }""" % { 'svn_base': self.svn_base }
#     DEPS_ALT = """
# deps = {
#   'src/other2': '%(svn_base)strunk/other@2'
# }
# """ % { 'svn_base': self.svn_base }
#       DEPS = """deps = {
#                 'src/different_repo': '%(svn_base)strunk/third_party',
#                 'src/different_repo_fixed': '%(svn_base)strunk/third_party@1',
#                 'src/same_repo': '/trunk/third_party',
#                 'src/same_repo_fixed': '/trunk/third_party@1',
#              }""" % { 'svn_base': self.svn_base }
#   CACHED_FAKE_REPOS = {}
#   FAKE_REPOS_CLASS = FakeRepos


import logging
import os
import sys
import unittest
import scm
import subprocess2
from testing_support import fake_repos
from testing_support.super_mox import SuperMoxTestBase
        'svn://svn.chromium.org/chrome/trunk/src',
        'svn://svn.chromium.org/chrome',
        'trunk/src:refs/remotes/origin/trunk',
        False), 'refs/remotes/origin/trunk')
    self.assertEquals(scm.GIT.MatchSvnGlob(
        'https://v8.googlecode.com/svn/branches/bleeding_edge',
        'https://v8.googlecode.com/svn',
        'branches/*:refs/remotes/*',
        True), 'refs/remotes/bleeding_edge')


class RealGitTest(fake_repos.FakeReposTestBase):
  def setUp(self):
    super(RealGitTest, self).setUp()
    self.enabled = self.FAKE_REPOS.set_up_git()
    if self.enabled:
      self.clone_dir = scm.os.path.join(self.FAKE_REPOS.git_root, 'repo_1')

  def testIsValidRevision(self):
    if not self.enabled:
      return
    # Sha1's are [0-9a-z]{32}, so starting with a 'z' or 'r' should always fail.
    self.assertFalse(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev='zebra'))
    self.assertFalse(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev='r123456'))
    # Valid cases
    first_rev = self.githash('repo_1', 1)
    self.assertTrue(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev=first_rev))
    self.assertTrue(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev='HEAD'))



# Path: testing_support/fake_repos.py
# def write(path, content):
# def read_tree(tree_root):
# def dict_diff(dict1, dict2):
# def commit_svn(repo, usr, pwd):
# def commit_git(repo):
# def test_port(host, port):
# def find_free_port(host, base_port):
# def wait_for_port_to_bind(host, port, process):
# def wait_for_port_to_free(host, port):
#   def __init__(self, host=None):
#   def root_dir(self):
#   def set_up(self):
#   def cleanup_dirt(self):
#   def tear_down(self):
#   def tear_down_svn(self):
#   def tear_down_git(self):
#   def _genTree(root, tree_dict):
#   def set_up_svn(self):
#   def set_up_git(self):
#   def _commit_svn(self, tree):
#   def _set_svn_commit_date(self, revision, date):
#   def _commit_git(self, repo, tree):
#   def check_port_is_free(self, port):
#   def populateSvn(self):
#   def populateGit(self):
#   def populateSvn(self):
#     def file_system(rev, DEPS, DEPS_ALT=None):
#   def populateGit(self):
#   def populateSvn(self):
#     def file_system(rev):
#   def populateGit(self):
#   def setUp(self):
#   def svn_base(self):
#   def git_base(self):
#   def checkString(self, expected, result, msg=None):
#   def check(self, expected, results):
#   def assertTree(self, tree, tree_root=None):
#   def mangle_svn_tree(self, *args):
#   def mangle_git_tree(self, *args):
#   def githash(self, repo, rev):
#   def gittree(self, repo, rev):
# def main(argv):
# class FakeReposBase(object):
# class FakeRepos(FakeReposBase):
# class FakeRepoTransitive(FakeReposBase):
# class FakeReposTestBase(trial_dir.TestCase):
#   NB_GIT_REPOS = 1
#   USERS = [
#       ('user1@example.com', 'foo'),
#       ('user2@example.com', 'bar'),
#   ]
#   NB_GIT_REPOS = 5
#     DEPS = """
# vars = {
#   'DummyVariable': 'third_party',
# }
# deps = {
#   'src/other': '%(svn_base)strunk/other@1',
#   'src/third_party/fpp': '/trunk/' + Var('DummyVariable') + '/foo',
# }
# deps_os = {
#   'mac': {
#     'src/third_party/prout': '/trunk/third_party/prout',
#   },
# }""" % { 'svn_base': self.svn_base }
#     DEPS_ALT = """
# deps = {
#   'src/other2': '%(svn_base)strunk/other@2'
# }
# """ % { 'svn_base': self.svn_base }
#       DEPS = """deps = {
#                 'src/different_repo': '%(svn_base)strunk/third_party',
#                 'src/different_repo_fixed': '%(svn_base)strunk/third_party@1',
#                 'src/same_repo': '/trunk/third_party',
#                 'src/same_repo_fixed': '/trunk/third_party@1',
#              }""" % { 'svn_base': self.svn_base }
#   CACHED_FAKE_REPOS = {}
#   FAKE_REPOS_CLASS = FakeRepos


# Path: tests/scm_unittest.py
import logging
import os
import sys
import unittest
import scm
import subprocess2
from testing_support import fake_repos
from testing_support.super_mox import SuperMoxTestBase

        'svn://svn.chromium.org/chrome/trunk/src',
        'svn://svn.chromium.org/chrome',
        'trunk/src:refs/remotes/origin/trunk',
        False), 'refs/remotes/origin/trunk')
    self.assertEquals(scm.GIT.MatchSvnGlob(
        'https://v8.googlecode.com/svn/branches/bleeding_edge',
        'https://v8.googlecode.com/svn',
        'branches/*:refs/remotes/*',
        True), 'refs/remotes/bleeding_edge')


class RealGitTest(fake_repos.FakeReposTestBase):
  def setUp(self):
    super(RealGitTest, self).setUp()
    self.enabled = self.FAKE_REPOS.set_up_git()
    if self.enabled:
      self.clone_dir = scm.os.path.join(self.FAKE_REPOS.git_root, 'repo_1')

  def testIsValidRevision(self):
    if not self.enabled:
      return
    # Sha1's are [0-9a-z]{32}, so starting with a 'z' or 'r' should always fail.
    self.assertFalse(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev='zebra'))
    self.assertFalse(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev='r123456'))
    # Valid cases
    first_rev = self.githash('repo_1', 1)
    self.assertTrue(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev=first_rev))
    self.assertTrue(scm.GIT.IsValidRevision(cwd=self.clone_dir, rev='HEAD'))



class RealGitSvnTest(fake_repos.FakeReposTestBase):