Пример #1
0
    def _InitHooks(self):
        hooks = self._gitdir_path('hooks')
        if not os.path.exists(hooks):
            os.makedirs(hooks)
        for stock_hook in repo_hooks():
            name = os.path.basename(stock_hook)

            if name in ('commit-msg') and not self.remote.review:
                # Don't install a Gerrit Code Review hook if this
                # project does not appear to use it for reviews.
                #
                continue

            dst = os.path.join(hooks, name)
            if os.path.islink(dst):
                continue
            if os.path.exists(dst):
                if filecmp.cmp(stock_hook, dst, shallow=False):
                    os.remove(dst)
                else:
                    _error("%s: Not replacing %s hook", self.relpath, name)
                    continue
            try:
                crossPlatformSymlink(stock_hook, dst)
            except OSError, e:
                if e.errno == errno.EPERM:
                    raise GitError('filesystem must support symlinks')
                else:
                    raise
Пример #2
0
    def _LinkWorkTree(self, relink=False):
        dotgit = os.path.join(self.worktree, ".git")
        if not relink:
            os.makedirs(dotgit)

        for name in [
            "config",
            "description",
            "hooks",
            "info",
            "logs",
            "objects",
            "packed-refs",
            "refs",
            "rr-cache",
            "svn",
        ]:
            try:
                src = os.path.join(self.gitdir, name)
                dst = os.path.join(dotgit, name)
                if relink:
                    os.remove(dst)
                if os.path.islink(dst) or not os.path.exists(dst):
                    crossPlatformSymlink(src, dst)
                else:
                    raise GitError("cannot overwrite a local work tree")
            except OSError, e:
                if e.errno == errno.EPERM:
                    raise GitError("filesystem must support symlinks")
                else:
                    raise
Пример #3
0
    def _InitHooks(self):
        hooks = self._gitdir_path("hooks")
        if not os.path.exists(hooks):
            os.makedirs(hooks)
        for stock_hook in repo_hooks():
            name = os.path.basename(stock_hook)

            if name in ("commit-msg") and not self.remote.review:
                # Don't install a Gerrit Code Review hook if this
                # project does not appear to use it for reviews.
                #
                continue

            dst = os.path.join(hooks, name)
            if os.path.islink(dst):
                continue
            if os.path.exists(dst):
                if filecmp.cmp(stock_hook, dst, shallow=False):
                    os.remove(dst)
                else:
                    _error("%s: Not replacing %s hook", self.relpath, name)
                    continue
            try:
                crossPlatformSymlink(stock_hook, dst)
            except OSError, e:
                if e.errno == errno.EPERM:
                    raise GitError("filesystem must support symlinks")
                else:
                    raise
Пример #4
0
  def testCreatesLinks(self):
    afile = open(os.path.join(self._sDir, 'a'), 'w')
    try:
      afile.write('a')
    finally:
      afile.close()

    crossPlatformSymlink(os.path.join(self._sDir, 'a'),
                         os.path.join(self._sDir, 'b'))

    self.assertTrue(os.path.exists(os.path.join(self._sDir, 'b')))
Пример #5
0
  def Link(self, name):
    """Update the repo metadata to use a different manifest.
    """
    self.Override(name)

    try:
      if os.path.exists(self._manifestFile):
        os.remove(self._manifestFile)
      manifest_dir = os.path.dirname(self._manifestFile)
      crossPlatformSymlink(os.path.join(manifest_dir, 'manifests', '%s' % name),
                           self._manifestFile)
    except OSError, e:
      raise ManifestParseError('cannot link manifest %s' % name)
Пример #6
0
    def Link(self, name):
        """Update the repo metadata to use a different manifest.
    """
        self.Override(name)

        try:
            if os.path.exists(self._manifestFile):
                os.remove(self._manifestFile)
            manifest_dir = os.path.dirname(self._manifestFile)
            crossPlatformSymlink(
                os.path.join(manifest_dir, 'manifests', '%s' % name),
                self._manifestFile)
        except OSError, e:
            raise ManifestParseError('cannot link manifest %s' % name)
Пример #7
0
    def _LinkWorkTree(self, relink=False):
        dotgit = os.path.join(self.worktree, '.git')
        if not relink:
            os.makedirs(dotgit)

        for name in [
                'config', 'description', 'hooks', 'info', 'logs', 'objects',
                'packed-refs', 'refs', 'rr-cache', 'svn'
        ]:
            try:
                src = os.path.join(self.gitdir, name)
                dst = os.path.join(dotgit, name)
                if relink:
                    os.remove(dst)
                if os.path.islink(dst) or not os.path.exists(dst):
                    crossPlatformSymlink(src, dst)
                else:
                    raise GitError('cannot overwrite a local work tree')
            except OSError, e:
                if e.errno == errno.EPERM:
                    raise GitError('filesystem must support symlinks')
                else:
                    raise