# 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
    self.mox.ReplayAll()
    info = scm.SVN.CaptureStatus(None, '.')
    expected = [
      ('?      ', 'unversionned_file.txt'),
      ('M      ', 'build\\internal\\essential.vsprops'),
      ('A  +   ', 'chrome\\app\\d'),
      ('MM     ', 'chrome\\app\\DEPS'),
      ('C      ', 'scripts\\master\\factory\\gclient_factory.py'),
    ]
    self.assertEquals(sorted(info), sorted(expected))

  def testCaptureStatusEmpty(self):
    text = r"""<?xml version="1.0"?>
    <status>
    <target
       path="perf">
       </target>
       </status>"""
    scm.SVN.Capture(['status', '--xml'], None).AndReturn(text)
    self.mox.ReplayAll()
    info = scm.SVN.CaptureStatus(None, None)
    self.assertEquals(info, [])


class RealSvnTest(fake_repos.FakeReposTestBase):
  # Tests that work with a checkout.
  def setUp(self):
    super(RealSvnTest, self).setUp()
    self.enabled = self.FAKE_REPOS.set_up_svn()
    if self.enabled:

# 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

    self.mox.ReplayAll()
    info = scm.SVN.CaptureStatus(None, '.')
    expected = [
      ('?      ', 'unversionned_file.txt'),
      ('M      ', 'build\\internal\\essential.vsprops'),
      ('A  +   ', 'chrome\\app\\d'),
      ('MM     ', 'chrome\\app\\DEPS'),
      ('C      ', 'scripts\\master\\factory\\gclient_factory.py'),
    ]
    self.assertEquals(sorted(info), sorted(expected))

  def testCaptureStatusEmpty(self):
    text = r"""<?xml version="1.0"?>
    <status>
    <target
       path="perf">
       </target>
       </status>"""
    scm.SVN.Capture(['status', '--xml'], None).AndReturn(text)
    self.mox.ReplayAll()
    info = scm.SVN.CaptureStatus(None, None)
    self.assertEquals(info, [])


class RealSvnTest(fake_repos.FakeReposTestBase):
  # Tests that work with a checkout.
  def setUp(self):
    super(RealSvnTest, self).setUp()
    self.enabled = self.FAKE_REPOS.set_up_svn()
    if self.enabled:

      self.svn_root = scm.os.path.join(self.root_dir, 'base')