示例#1
0
  def config(self, cwd=None):
    if cwd is None:
      cwd = self.mirror_path

    # Don't run git-gc in a daemon.  Bad things can happen if it gets killed.
    try:
      self.RunGit(['config', 'gc.autodetach', '0'], cwd=cwd)
    except subprocess.CalledProcessError:
      # Hard error, need to clobber.
      raise ClobberNeeded()

    # Don't combine pack files into one big pack file.  It's really slow for
    # repositories, and there's no way to track progress and make sure it's
    # not stuck.
    self.RunGit(['config', 'gc.autopacklimit', '0'], cwd=cwd)

    # Allocate more RAM for cache-ing delta chains, for better performance
    # of "Resolving deltas".
    self.RunGit(['config', 'core.deltaBaseCacheLimit',
                 gclient_utils.DefaultDeltaBaseCacheLimit()], cwd=cwd)

    self.RunGit(['config', 'remote.origin.url', self.url], cwd=cwd)
    self.RunGit(['config', '--replace-all', 'remote.origin.fetch',
                 '+refs/heads/*:refs/heads/*', r'\+refs/heads/\*:.*'], cwd=cwd)
    for spec, value_regex in self.fetch_specs:
      self.RunGit(
          ['config', '--replace-all', 'remote.origin.fetch', spec, value_regex],
          cwd=cwd)
示例#2
0
  def config(self, cwd=None):
    if cwd is None:
      cwd = self.mirror_path

    # Don't run git-gc in a daemon.  Bad things can happen if it gets killed.
    self.RunGit(['config', 'gc.autodetach', '0'], cwd=cwd)

    # Don't combine pack files into one big pack file.  It's really slow for
    # repositories, and there's no way to track progress and make sure it's
    # not stuck.
    self.RunGit(['config', 'gc.autopacklimit', '0'], cwd=cwd)

    # Allocate more RAM for cache-ing delta chains, for better performance
    # of "Resolving deltas".
    self.RunGit(['config', 'core.deltaBaseCacheLimit',
                 gclient_utils.DefaultDeltaBaseCacheLimit()], cwd=cwd)

    self.RunGit(['config', 'remote.origin.url', self.url], cwd=cwd)
    self.RunGit(['config', '--replace-all', 'remote.origin.fetch',
                 '+refs/heads/*:refs/heads/*', r'\+refs/heads/\*:.*'], cwd=cwd)
    for ref in self.refs:
      ref = ref.lstrip('+').rstrip('/')
      if ref.startswith('refs/'):
        refspec = '+%s:%s' % (ref, ref)
        regex = r'\+%s:.*' % ref.replace('*', r'\*')
      else:
        refspec = '+refs/%s/*:refs/%s/*' % (ref, ref)
        regex = r'\+refs/heads/%s:.*' % ref.replace('*', r'\*')
      self.RunGit(
          ['config', '--replace-all', 'remote.origin.fetch', refspec, regex],
          cwd=cwd)
示例#3
0
    def config(self, cwd=None, reset_fetch_config=False):
        if cwd is None:
            cwd = self.mirror_path

        # Print diagnostics and ignore errors.
        try:
            self.print('git exe: %s' % (self.git_exe, ))
            self.RunGit(['version'], cwd=cwd)
            self.RunGit(['config', 'protocol.version'], cwd=cwd)
        except subprocess.CalledProcessError as e:
            pass

        if reset_fetch_config:
            try:
                self.RunGit(['config', '--unset-all', 'remote.origin.fetch'],
                            cwd=cwd)
            except subprocess.CalledProcessError as e:
                # If exit code was 5, it means we attempted to unset a config that
                # didn't exist. Ignore it.
                if e.returncode != 5:
                    raise

        # Don't run git-gc in a daemon.  Bad things can happen if it gets killed.
        try:
            self.RunGit(['config', 'gc.autodetach', '0'], cwd=cwd)
        except subprocess.CalledProcessError:
            # Hard error, need to clobber.
            raise ClobberNeeded()

        # Don't combine pack files into one big pack file.  It's really slow for
        # repositories, and there's no way to track progress and make sure it's
        # not stuck.
        if self.supported_project():
            self.RunGit(['config', 'gc.autopacklimit', '0'], cwd=cwd)

        # Allocate more RAM for cache-ing delta chains, for better performance
        # of "Resolving deltas".
        self.RunGit([
            'config', 'core.deltaBaseCacheLimit',
            gclient_utils.DefaultDeltaBaseCacheLimit()
        ],
                    cwd=cwd)

        self.RunGit(['config', 'remote.origin.url', self.url], cwd=cwd)
        self.RunGit([
            'config', '--replace-all', 'remote.origin.fetch',
            '+refs/heads/*:refs/heads/*', r'\+refs/heads/\*:.*'
        ],
                    cwd=cwd)
        for spec, value_regex in self.fetch_specs:
            self.RunGit([
                'config', '--replace-all', 'remote.origin.fetch', spec,
                value_regex
            ],
                        cwd=cwd)
示例#4
0
 def config(self, cwd=None):
     if cwd is None:
         cwd = self.mirror_path
     self.RunGit([
         'config', 'core.deltaBaseCacheLimit',
         gclient_utils.DefaultDeltaBaseCacheLimit()
     ],
                 cwd=cwd)
     self.RunGit(['config', 'remote.origin.url', self.url], cwd=cwd)
     self.RunGit([
         'config', '--replace-all', 'remote.origin.fetch',
         '+refs/heads/*:refs/heads/*'
     ],
                 cwd=cwd)
     for ref in self.refs:
         ref = ref.lstrip('+').rstrip('/')
         if ref.startswith('refs/'):
             refspec = '+%s:%s' % (ref, ref)
         else:
             refspec = '+refs/%s/*:refs/%s/*' % (ref, ref)
         self.RunGit(['config', '--add', 'remote.origin.fetch', refspec],
                     cwd=cwd)