# Path: vcstool/executor.py
# USE_COLOR = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
# 
# Path: vcstool/clients/vcs_base.py
# class VcsClientBase(object):
# 
#     type = None
# 
#     def __init__(self, path):
#         self.path = path
# 
#     def __getattribute__(self, name):
#         if name == 'import':
#             try:
#                 return self.import_
#             except AttributeError:
#                 pass
#         return super(VcsClientBase, self).__getattribute__(name)
# 
#     def _not_applicable(self, command, message=None):
#         return {
#             'cmd': '%s.%s(%s)' % (
#                 self.__class__.type, 'push', command.__class__.command),
#             'output': "Command '%s' not applicable for client '%s'%s" % (
#                 command.__class__.command, self.__class__.type,
#                 ': ' + message if message else ''),
#             'returncode': NotImplemented
#         }
# 
#     def _run_command(self, cmd, env=None, retry=0):
#         for i in range(retry + 1):
#             result = run_command(cmd, os.path.abspath(self.path), env=env)
#             if not result['returncode']:
#                 # return successful result
#                 break
#             if i >= retry:
#                 # return the failure after retries
#                 break
#             # increasing sleep before each retry
#             time.sleep(i + 1)
#         return result
# 
#     def _create_path(self):
#         if not os.path.exists(self.path):
#             try:
#                 os.makedirs(self.path)
#             except os.error as e:
#                 return {
#                     'cmd': 'os.makedirs(%s)' % self.path,
#                     'cwd': self.path,
#                     'output':
#                         "Could not create directory '%s': %s" % (self.path, e),
#                     'returncode': 1
#                 }
#         return None
# 
# Path: vcstool/util.py
# def rmtree(path):
#     kwargs = {}
#     if sys.platform == 'win32':
#         kwargs['onerror'] = _onerror_windows
#     return shutil_rmtree(path, **kwargs)


import os
import subprocess
from shutil import which
from vcstool.executor import USE_COLOR
from .vcs_base import VcsClientBase
from ..util import rmtree
                        'cwd': self.path,
                        'output':
                            'Skipped existing repository with different URL',
                        'returncode': 0
                    }
                if not command.force:
                    return {
                        'cmd': '',
                        'cwd': self.path,
                        'output':
                            'Path already exists and contains a different '
                            'repository',
                        'returncode': 1
                    }
                try:
                    rmtree(self.path)
                except OSError:
                    os.remove(self.path)

        elif command.skip_existing and os.path.exists(self.path):
            return {
                'cmd': '',
                'cwd': self.path,
                'output': 'Skipped existing directory',
                'returncode': 0
            }

        elif command.force and os.path.exists(self.path):
            # Not empty, not a git repository
            try:

# Path: vcstool/executor.py
# USE_COLOR = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
# 
# Path: vcstool/clients/vcs_base.py
# class VcsClientBase(object):
# 
#     type = None
# 
#     def __init__(self, path):
#         self.path = path
# 
#     def __getattribute__(self, name):
#         if name == 'import':
#             try:
#                 return self.import_
#             except AttributeError:
#                 pass
#         return super(VcsClientBase, self).__getattribute__(name)
# 
#     def _not_applicable(self, command, message=None):
#         return {
#             'cmd': '%s.%s(%s)' % (
#                 self.__class__.type, 'push', command.__class__.command),
#             'output': "Command '%s' not applicable for client '%s'%s" % (
#                 command.__class__.command, self.__class__.type,
#                 ': ' + message if message else ''),
#             'returncode': NotImplemented
#         }
# 
#     def _run_command(self, cmd, env=None, retry=0):
#         for i in range(retry + 1):
#             result = run_command(cmd, os.path.abspath(self.path), env=env)
#             if not result['returncode']:
#                 # return successful result
#                 break
#             if i >= retry:
#                 # return the failure after retries
#                 break
#             # increasing sleep before each retry
#             time.sleep(i + 1)
#         return result
# 
#     def _create_path(self):
#         if not os.path.exists(self.path):
#             try:
#                 os.makedirs(self.path)
#             except os.error as e:
#                 return {
#                     'cmd': 'os.makedirs(%s)' % self.path,
#                     'cwd': self.path,
#                     'output':
#                         "Could not create directory '%s': %s" % (self.path, e),
#                     'returncode': 1
#                 }
#         return None
# 
# Path: vcstool/util.py
# def rmtree(path):
#     kwargs = {}
#     if sys.platform == 'win32':
#         kwargs['onerror'] = _onerror_windows
#     return shutil_rmtree(path, **kwargs)


# Path: vcstool/clients/git.py
import os
import subprocess
from shutil import which
from vcstool.executor import USE_COLOR
from .vcs_base import VcsClientBase
from ..util import rmtree

                        'cwd': self.path,
                        'output':
                            'Skipped existing repository with different URL',
                        'returncode': 0
                    }
                if not command.force:
                    return {
                        'cmd': '',
                        'cwd': self.path,
                        'output':
                            'Path already exists and contains a different '
                            'repository',
                        'returncode': 1
                    }
                try:
                    rmtree(self.path)
                except OSError:
                    os.remove(self.path)

        elif command.skip_existing and os.path.exists(self.path):
            return {
                'cmd': '',
                'cwd': self.path,
                'output': 'Skipped existing directory',
                'returncode': 0
            }

        elif command.force and os.path.exists(self.path):
            # Not empty, not a git repository
            try:

                rmtree(self.path)