Exemplo n.º 1
0
def main(argv):
  # No command line flags. Just use the parser to prevent people from trying
  # to pass flags that don't do anything, and to provide 'usage'.
  parser = argparse.ArgumentParser(
      description='Automatically set up git-svn for a repo mirrored from svn.')
  parser.parse_args(argv[1:])

  upstream = root()
  message = run_git('log', '-1', '--format=%B', upstream)
  footers = parse_footers(message)
  git_svn_id = get_unique(footers, 'git-svn-id')
  match = GIT_SVN_ID_PATTERN.match(git_svn_id)
  assert match, 'No valid git-svn-id footer found on %s.' % upstream
  print 'Found git-svn-id footer %s on %s' % (match.group(1), upstream)

  parsed_svn = urlparse.urlparse(match.group(1))
  path_components = parsed_svn.path.split('/')
  svn_repo = None
  svn_path = None
  for i in xrange(len(path_components)):
    try:
      maybe_repo = '%s://%s%s' % (
          parsed_svn.scheme, parsed_svn.netloc, '/'.join(path_components[:i+1]))
      print 'Checking ', maybe_repo
      run_svn('info', maybe_repo)
      svn_repo = maybe_repo
      svn_path = '/'.join(path_components[i+1:])
      break
    except subprocess2.CalledProcessError:
      continue
  assert svn_repo is not None, 'Unable to find svn repo for %s' % match.group(1)
  print 'Found upstream svn repo %s and path %s' % (svn_repo, svn_path)

  prefix = upstream.rsplit('/')[0]
  run_git('svn', 'init', '--prefix=%s' % prefix, '-T', svn_path, svn_repo)
  set_config('svn-remote.svn.fetch',
             '%s:refs/remotes/%s' % (svn_path, upstream))
  print 'Configured metadata, running "git svn fetch". This may take some time.'
  for line in run_git_stream('svn', 'fetch').xreadlines():
    print line.strip()
Exemplo n.º 2
0
def main(argv):
    # No command line flags. Just use the parser to prevent people from trying
    # to pass flags that don't do anything, and to provide 'usage'.
    parser = argparse.ArgumentParser(
        description='Automatically set up git-svn for a repo mirrored from svn.'
    )
    parser.parse_args(argv[1:])

    upstream = root()
    message = run_git('log', '-1', '--format=%B', upstream)
    footers = parse_footers(message)
    git_svn_id = get_unique(footers, 'git-svn-id')
    match = GIT_SVN_ID_PATTERN.match(git_svn_id)
    assert match, 'No valid git-svn-id footer found on %s.' % upstream
    print 'Found git-svn-id footer %s on %s' % (match.group(1), upstream)

    parsed_svn = urlparse.urlparse(match.group(1))
    path_components = parsed_svn.path.split('/')
    svn_repo = None
    svn_path = None
    for i in xrange(len(path_components)):
        try:
            maybe_repo = '%s://%s%s' % (parsed_svn.scheme, parsed_svn.netloc,
                                        '/'.join(path_components[:i + 1]))
            print 'Checking ', maybe_repo
            run_svn('info', maybe_repo)
            svn_repo = maybe_repo
            svn_path = '/'.join(path_components[i + 1:])
            break
        except subprocess2.CalledProcessError, e:
            if 'E170001' in str(e):
                print 'Authentication failed:'
                print e
                print(
                    'Try running "svn ls %s" with the password'
                    ' from https://chromium-access.appspot.com' % maybe_repo)
                print
            continue
Exemplo n.º 3
0
def main(argv):
  # No command line flags. Just use the parser to prevent people from trying
  # to pass flags that don't do anything, and to provide 'usage'.
  parser = argparse.ArgumentParser(
      description='Automatically set up git-svn for a repo mirrored from svn.')
  parser.parse_args(argv)

  upstream = root()
  message = run_git('log', '-1', '--format=%B', upstream)
  footers = parse_footers(message)
  git_svn_id = get_unique(footers, 'git-svn-id')
  match = GIT_SVN_ID_PATTERN.match(git_svn_id)
  assert match, 'No valid git-svn-id footer found on %s.' % upstream
  print 'Found git-svn-id footer %s on %s' % (match.group(1), upstream)

  parsed_svn = urlparse.urlparse(match.group(1))
  path_components = parsed_svn.path.split('/')
  svn_repo = None
  svn_path = None
  for i in xrange(len(path_components)):
    try:
      maybe_repo = '%s://%s%s' % (
          parsed_svn.scheme, parsed_svn.netloc, '/'.join(path_components[:i+1]))
      print 'Checking ', maybe_repo
      run_svn('info', maybe_repo)
      svn_repo = maybe_repo
      svn_path = '/'.join(path_components[i+1:])
      break
    except subprocess2.CalledProcessError, e:
      if 'E170001' in str(e):
        print 'Authentication failed:'
        print e
        print ('Try running "svn ls %s" with the password'
               ' from https://chromium-access.appspot.com' % maybe_repo)
        print
      continue
Exemplo n.º 4
0
            svn_repo = maybe_repo
            svn_path = '/'.join(path_components[i + 1:])
            break
        except subprocess2.CalledProcessError, e:
            if 'E170001' in str(e):
                print 'Authentication failed:'
                print e
                print(
                    'Try running "svn ls %s" with the password'
                    ' from https://chromium-access.appspot.com' % maybe_repo)
                print
            continue
    assert svn_repo is not None, 'Unable to find svn repo for %s' % svn_id
    print 'Found upstream svn repo %s and path %s' % (svn_repo, svn_path)

    run_git('config', '--local', '--replace-all', 'svn-remote.svn.url',
            svn_repo)
    run_git('config', '--local', '--replace-all', 'svn-remote.svn.fetch',
            '%s:refs/remotes/%s' % (svn_path, upstream),
            'refs/remotes/%s$' % upstream)
    print 'Configured metadata, running "git svn fetch". This may take some time.'
    with run_git_stream_with_retcode('svn', 'fetch') as stdout:
        for line in stdout.xreadlines():
            print line.strip()


if __name__ == '__main__':
    try:
        sys.exit(main(sys.argv[1:]))
    except KeyboardInterrupt:
        sys.stderr.write('interrupted\n')
        sys.exit(1)
Exemplo n.º 5
0
      run_svn('info', maybe_repo)
      svn_repo = maybe_repo
      svn_path = '/'.join(path_components[i+1:])
      break
    except subprocess2.CalledProcessError, e:
      if 'E170001' in str(e):
        print 'Authentication failed:'
        print e
        print ('Try running "svn ls %s" with the password'
               ' from https://chromium-access.appspot.com' % maybe_repo)
        print
      continue
  assert svn_repo is not None, 'Unable to find svn repo for %s' % svn_id
  print 'Found upstream svn repo %s and path %s' % (svn_repo, svn_path)

  run_git('config', '--local', '--replace-all', 'svn-remote.svn.url', svn_repo)
  run_git('config', '--local', '--replace-all', 'svn-remote.svn.fetch',
          '%s:refs/remotes/%s' % (svn_path, upstream),
          'refs/remotes/%s$' % upstream)
  print 'Configured metadata, running "git svn fetch". This may take some time.'
  with run_git_stream_with_retcode('svn', 'fetch') as stdout:
    for line in stdout.xreadlines():
      print line.strip()


if __name__ == '__main__':
  try:
    sys.exit(main(sys.argv[1:]))
  except KeyboardInterrupt:
    sys.stderr.write('interrupted\n')
    sys.exit(1)