mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Canonicalize paths before linking in gclient-new-workdir.py
This fixes the case where a new workdir is created from a repository which was previously created with gclient-new-workdir.py and that repository is later deleted, rendering the symbolic links created by gclient-new-workdir.py invalid. It also fixes support_cow() returning 'True' in that case because 'cp --reflink' does not fail when copying a symlink. Bug: 721585 Change-Id: I84f4d80b8698af0da346be559d46a328ec0d0e9b Reviewed-on: https://chromium-review.googlesource.com/842402 Reviewed-by: Aaron Gable <agable@chromium.org> Commit-Queue: Dirk Pranke <dpranke@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
0f7b2007a5
commit
fd4ad24165
@@ -50,6 +50,8 @@ def parse_options():
|
||||
|
||||
|
||||
def support_cow(src, dest):
|
||||
# 'cp --reflink' always succeeds when 'src' is a symlink or a directory
|
||||
assert os.path.isfile(src) and not os.path.islink(src)
|
||||
try:
|
||||
subprocess.check_output(['cp', '-a', '--reflink', src, dest],
|
||||
stderr=subprocess.STDOUT)
|
||||
@@ -74,6 +76,8 @@ def main():
|
||||
args = parse_options()
|
||||
|
||||
gclient = os.path.join(args.repository, '.gclient')
|
||||
if os.path.islink(gclient):
|
||||
gclient = os.realpath(gclient)
|
||||
new_gclient = os.path.join(args.new_workdir, '.gclient')
|
||||
|
||||
if try_vol_snapshot(args.repository, args.new_workdir):
|
||||
|
||||
@@ -1047,4 +1047,7 @@ def clone_file(repository, new_workdir, link, operation):
|
||||
link_dir = os.path.dirname(os.path.join(new_workdir, link))
|
||||
if not os.path.exists(link_dir):
|
||||
os.makedirs(link_dir)
|
||||
operation(os.path.join(repository, link), os.path.join(new_workdir, link))
|
||||
src = os.path.join(repository, link)
|
||||
if os.path.islink(src):
|
||||
src = os.realpath(src)
|
||||
operation(src, os.path.join(new_workdir, link))
|
||||
|
||||
Reference in New Issue
Block a user