def main(): args = parse_options() gclient = os.path.join(args.repository, '.gclient') if os.path.islink(gclient): gclient = os.path.realpath(gclient) new_gclient = os.path.join(args.new_workdir, '.gclient') if try_vol_snapshot(args.repository, args.new_workdir): args.reflink = True else: os.makedirs(args.new_workdir) if args.reflink is None: args.reflink = support_cow(gclient, new_gclient) if args.reflink: print('Copy-on-write support is detected.') os.symlink(gclient, new_gclient) for root, dirs, _ in os.walk(args.repository): if '.git' in dirs: workdir = root.replace(args.repository, args.new_workdir, 1) print('Creating: %s' % workdir) if args.reflink: if not os.path.exists(workdir): print('Copying: %s' % workdir) subprocess.check_call( ['cp', '-a', '--reflink', root, workdir]) shutil.rmtree(os.path.join(workdir, '.git')) git_common.make_workdir(os.path.join(root, '.git'), os.path.join(workdir, '.git')) if args.reflink: subprocess.check_call([ 'cp', '-a', '--reflink', os.path.join(root, '.git', 'index'), os.path.join(workdir, '.git', 'index') ]) else: subprocess.check_call(['git', 'checkout', '-f'], cwd=workdir) if args.reflink: print( textwrap.dedent('''\ The repo was copied with copy-on-write, and the artifacts were retained. More details on http://crbug.com/721585. Depending on your usage pattern, you might want to do "gn gen" on the output directories. More details: http://crbug.com/723856.'''))
def main(): repository, new_workdir = parse_options() gclient = os.path.join(repository, '.gclient') if not os.path.exists(gclient): print_err('No .gclient file: ' + gclient) os.makedirs(new_workdir) os.symlink(gclient, os.path.join(new_workdir, '.gclient')) for root, dirs, _ in os.walk(repository): if '.git' in dirs: workdir = root.replace(repository, new_workdir, 1) print('Creating: %s' % workdir) git_common.make_workdir(os.path.join(root, '.git'), os.path.join(workdir, '.git')) subprocess.check_call(['git', 'checkout', '-f'], cwd=workdir)
def main(): args = parse_options() gclient = os.path.join(args.repository, '.gclient') if os.path.islink(gclient): gclient = os.path.realpath(gclient) new_gclient = os.path.join(args.new_workdir, '.gclient') if try_vol_snapshot(args.repository, args.new_workdir): args.reflink = True else: os.makedirs(args.new_workdir) if args.reflink is None: args.reflink = support_cow(gclient, new_gclient) if args.reflink: print('Copy-on-write support is detected.') os.symlink(gclient, new_gclient) for root, dirs, _ in os.walk(args.repository): if '.git' in dirs: workdir = root.replace(args.repository, args.new_workdir, 1) print('Creating: %s' % workdir) if args.reflink: if not os.path.exists(workdir): print('Copying: %s' % workdir) subprocess.check_call(['cp', '-a', '--reflink', root, workdir]) shutil.rmtree(os.path.join(workdir, '.git')) git_common.make_workdir(os.path.join(root, '.git'), os.path.join(workdir, '.git')) if args.reflink: subprocess.check_call(['cp', '-a', '--reflink', os.path.join(root, '.git', 'index'), os.path.join(workdir, '.git', 'index')]) else: subprocess.check_call(['git', 'checkout', '-f'], cwd=workdir) if args.reflink: print(textwrap.dedent('''\ The repo was copied with copy-on-write, and the artifacts were retained. More details on http://crbug.com/721585. Depending on your usage pattern, you might want to do "gn gen" on the output directories. More details: http://crbug.com/723856.'''))