mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Support btrfs snapshot in gclient-new-workdir.py
If the repo is a btrfs subvolume, take a snapshot instead of using "cp --reflink". Taking a snapshot is much faster, and uses less disk space for metadata. Bug: 721585 Change-Id: I97753dc30d46ff56d84d65f8d815c19d09cf104b Reviewed-on: https://chromium-review.googlesource.com/513586 Reviewed-by: Robbie Iannucci <iannucci@chromium.org> Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
b02daf0bf9
commit
56664461ae
@@ -60,18 +60,30 @@ def support_cow(src, dest):
|
||||
return True
|
||||
|
||||
|
||||
def try_vol_snapshot(src, dest):
|
||||
try:
|
||||
subprocess.check_call(['btrfs', 'subvol', 'snapshot', src, dest],
|
||||
stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_options()
|
||||
|
||||
gclient = os.path.join(args.repository, '.gclient')
|
||||
new_gclient = os.path.join(args.new_workdir, '.gclient')
|
||||
|
||||
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)
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user