<feed xmlns='http://www.w3.org/2005/Atom'>
<title>tools/git-repo.git/platform_utils.py, branch v2.66</title>
<subtitle>Mirror of gerrit.googlesource.com/git-repo</subtitle>
<id>https://git.enea.com/cgit/tools/git-repo.git/atom?h=v2.66</id>
<link rel='self' href='https://git.enea.com/cgit/tools/git-repo.git/atom?h=v2.66'/>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/'/>
<updated>2026-05-12T18:10:43+00:00</updated>
<entry>
<title>linkfile: Handle directory-to-symlink transitions safely</title>
<updated>2026-05-12T18:10:43+00:00</updated>
<author>
<name>Carlos Fernandez</name>
<email>carlosfsanz@meta.com</email>
</author>
<published>2026-05-07T16:00:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=5534f164d6aff567f7ea0b5b41e2e5bb35a0212c'/>
<id>urn:sha1:5534f164d6aff567f7ea0b5b41e2e5bb35a0212c</id>
<content type='text'>
When a manifest changes from individual linkfiles inside a directory
(e.g. dest=".llms/rules", dest=".llms/skills") to a single linkfile
for the whole directory (e.g. dest=".llms", src="dot-llms"), two
things need to happen:

1. __linkIt must replace a real directory with a symlink.  Use
   os.rmdir() instead of platform_utils.remove() for real directories.
   rmdir only removes empty directories, so user-created content is
   never deleted.

2. UpdateCopyLinkfileList must handle the cleanup correctly:
   - Use os.rmdir() for directories (safe for non-empty)
   - Remove empty parent directories after cleaning old dests
   - Retry _CopyAndLinkFiles for all projects, since in interleaved
     sync mode _CopyAndLinkFiles runs before cleanup and may have
     failed because the directory was not yet empty

Change-Id: I0437b80beab98bce064cea81c11c47d699be91aa
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/569243
Tested-by: Carlos Fernandez &lt;carlosfsanz@meta.com&gt;
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
Reviewed-by: Gavin Mak &lt;gavinmak@google.com&gt;
Commit-Queue: Carlos Fernandez &lt;carlosfsanz@meta.com&gt;
</content>
</entry>
<entry>
<title>Fix EROFS error when root fs is mounted read-only</title>
<updated>2025-04-02T13:43:06+00:00</updated>
<author>
<name>Egor Duda</name>
<email>egor.duda@gmail.com</email>
</author>
<published>2025-03-06T07:14:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=f070331a4c9993f4eedcc7fcb1c4b4807db69d02'/>
<id>urn:sha1:f070331a4c9993f4eedcc7fcb1c4b4807db69d02</id>
<content type='text'>
repo attempts to create /etc/.repo_gitconfig.json file, and fails if
root file system is mounted read-only. Removing non-existing file on
read-only filesystem results in EROFS instead of ENOENT.

Bug: 401018409
Change-Id: I64edc0567fb88649f3fd8cacb65a8780744640d4
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/458821
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
Tested-by: Egor Duda &lt;egor.duda@gmail.com&gt;
Commit-Queue: Egor Duda &lt;egor.duda@gmail.com&gt;
</content>
</entry>
<entry>
<title>Remove platform_utils.realpath</title>
<updated>2024-03-27T17:13:58+00:00</updated>
<author>
<name>Kaiyi Li</name>
<email>kaiyili@google.com</email>
</author>
<published>2024-03-27T14:21:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=46819a78a1b34f30edba209e15d9922f84f11c09'/>
<id>urn:sha1:46819a78a1b34f30edba209e15d9922f84f11c09</id>
<content type='text'>
... since it's just a simple wrapper of os.path.realpath now.

Change-Id: I7433e5fe09c64b130f06e2541151dce1961772c9
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/416637
Tested-by: Kaiyi Li &lt;kaiyili@google.com&gt;
Reviewed-by: Greg Edelston &lt;gredelston@google.com&gt;
Commit-Queue: Kaiyi Li &lt;kaiyili@google.com&gt;
</content>
</entry>
<entry>
<title>Fix drive mounted directory on Windows</title>
<updated>2024-03-27T14:00:47+00:00</updated>
<author>
<name>Kaiyi Li</name>
<email>kaiyili@google.com</email>
</author>
<published>2024-03-27T08:53:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=159389f0da91e893962923f4aca951f8e6d9a451'/>
<id>urn:sha1:159389f0da91e893962923f4aca951f8e6d9a451</id>
<content type='text'>
On my Windows machine, I mount drive D: to the directory C:\src.

The old implementation returns the incorrect 'C:\\??\\Volume{ad2eb15e-f293-4d48-a448-54757d95a97c}' result, which breaks the repo init command.

With the use of os.path.realpath, it can return 'D:\\' correctly.

Change-Id: Ia5f53989055125cb282d4123cf55d060718aa1ff
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/416580
Reviewed-by: Greg Edelston &lt;gredelston@google.com&gt;
Tested-by: Kaiyi Li &lt;kaiyili@google.com&gt;
Commit-Queue: Kaiyi Li &lt;kaiyili@google.com&gt;
</content>
</entry>
<entry>
<title>cleanup: Update codebase to expect Python 3.6</title>
<updated>2023-10-31T16:03:54+00:00</updated>
<author>
<name>Jason R. Coombs</name>
<email>jaraco@google.com</email>
</author>
<published>2023-09-29T15:04:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=b32ccbb66bb16965ecb8b4e266c4e45186636c1b'/>
<id>urn:sha1:b32ccbb66bb16965ecb8b4e266c4e45186636c1b</id>
<content type='text'>
- Bump minimum version to Python 3.6.
- Use f-strings in a lot of places.

Change-Id: I2aa70197230fcec2eff8e7c8eb754f20c08075bb
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/389034
Tested-by: Jason R. Coombs &lt;jaraco@google.com&gt;
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
Commit-Queue: Jason R. Coombs &lt;jaraco@google.com&gt;
</content>
</entry>
<entry>
<title>cleanup: leverage yield from in more places</title>
<updated>2023-10-20T17:33:03+00:00</updated>
<author>
<name>Jason R. Coombs</name>
<email>jaraco@jaraco.com</email>
</author>
<published>2023-10-20T10:48:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=8dd85218541f66b5c6740e46ebb3ebbcfc585af1'/>
<id>urn:sha1:8dd85218541f66b5c6740e46ebb3ebbcfc585af1</id>
<content type='text'>
Change-Id: I4f9cb27d89241d3738486764817b51981444a903
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390274
Reviewed-by: Aravind Vasudevan &lt;aravindvasudev@google.com&gt;
Commit-Queue: Mike Frysinger &lt;vapier@google.com&gt;
Tested-by: Mike Frysinger &lt;vapier@google.com&gt;
</content>
</entry>
<entry>
<title>Format codebase with black and check formatting in CQ</title>
<updated>2023-03-22T17:46:28+00:00</updated>
<author>
<name>Gavin Mak</name>
<email>gavinmak@google.com</email>
</author>
<published>2023-03-11T06:46:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1'/>
<id>urn:sha1:ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1</id>
<content type='text'>
Apply rules set by https://gerrit-review.googlesource.com/c/git-repo/+/362954/ across the codebase and fix any lingering errors caught
by flake8. Also check black formatting in run_tests (and CQ).

Bug: b/267675342
Change-Id: I972d77649dac351150dcfeb1cd1ad0ea2efc1956
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/363474
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
Tested-by: Gavin Mak &lt;gavinmak@google.com&gt;
Commit-Queue: Gavin Mak &lt;gavinmak@google.com&gt;
</content>
</entry>
<entry>
<title>make file removal a bit more robust</title>
<updated>2021-09-28T16:06:50+00:00</updated>
<author>
<name>Mike Frysinger</name>
<email>vapier@google.com</email>
</author>
<published>2021-09-28T15:27:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=9d96f58f5fcec101c612e61c3e2526ca071d89ea'/>
<id>urn:sha1:9d96f58f5fcec101c612e61c3e2526ca071d89ea</id>
<content type='text'>
Some of the file removal calls are subject to race conditions (if
something else deletes the file), so extend our remove API to have
an option to ignore ENOENT errors.  Then update a bunch of random
call sites to use this new functionality.

Change-Id: I31a9090e135452033135337a202a4fc2dbf8b63c
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/319195
Reviewed-by: Sean McAllister &lt;smcallis@google.com&gt;
Tested-by: Mike Frysinger &lt;vapier@google.com&gt;
</content>
</entry>
<entry>
<title>platform_utils: os.rename exception when src and des on different file system</title>
<updated>2021-09-24T08:20:06+00:00</updated>
<author>
<name>wenchiching</name>
<email>wenchiching@gmail.com</email>
</author>
<published>2021-08-23T02:47:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=366824937c179c0ce7e316f6bbefce99eabab408'/>
<id>urn:sha1:366824937c179c0ce7e316f6bbefce99eabab408</id>
<content type='text'>
Symptom: repo sync exception
Root Cause: os.rename only works when source and destination are on the same file system
Solution: using shutil.move

to save disk usage, I create links for projects and project-objects, link to folder on another disk
lrwxrwxrwx  1 owenwen owenwen   47 Jun  9 16:40 project-objects -&gt; /disk3/AndroidLocalRepos/.repo/project-objects/
lrwxrwxrwx  1 owenwen owenwen   40 Jun  9 16:40 projects -&gt; /disk3/AndroidLocalRepos/.repo/projects/

below are exception I met:
"""
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/disk2/Android11/.repo/repo/subcmds/sync.py", line 550, in _CheckoutOne
    project.Sync_LocalHalf(syncbuf, force_sync=force_sync)
  File "/disk2/Android11/.repo/repo/project.py", line 1251, in Sync_LocalHalf
    self._InitWorkTree(force_sync=force_sync, submodules=submodules)
  File "/disk2/Android11/.repo/repo/project.py", line 2801, in _InitWorkTree
    self._CheckDirReference(self.gitdir, dotgit, share_refs=True)
  File "/disk2/Android11/.repo/repo/project.py", line 2674, in _CheckDirReference
    platform_utils.rename(dst_path, src_path)
  File "/disk2/Android11/.repo/repo/platform_utils.py", line 127, in rename
    os.rename(src, dst)
OSError: [Errno 18] Invalid cross-device link: '/disk2/Android11/system/libhidl/.git/packed-refs' -&gt; '/disk2/Android11/.repo/projects/system/libhidl.git/packed-refs'
"""

Change-Id: Ifda2f16530cc5a8f280169f482ee858f9e5241d3
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/316002
Tested-by: Mike Frysinger &lt;vapier@google.com&gt;
Reviewed-by: Mike Frysinger &lt;vapier@google.com&gt;
</content>
</entry>
<entry>
<title>platform_utils: delete unused FileDescriptorStreams APIs</title>
<updated>2021-02-24T01:45:57+00:00</updated>
<author>
<name>Mike Frysinger</name>
<email>vapier@google.com</email>
</author>
<published>2021-02-16T22:21:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.enea.com/cgit/tools/git-repo.git/commit/?id=f0925c482f4bd73aa1c6f8e0816955dedddbc678'/>
<id>urn:sha1:f0925c482f4bd73aa1c6f8e0816955dedddbc678</id>
<content type='text'>
Now that we've converted the few users of this over to subprocess APIs,
we don't need this anymore.  It's been a bit hairy to maintain across
different operating systems, so there's no desire to bring it back.

Using multiprocessing Pool to batch things has been working better in
general anyways.

Change-Id: I10769e96f60ecf27a80d8cc2aa0d1b199085252e
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297682
Reviewed-by: Michael Mortensen &lt;mmortensen@google.com&gt;
Tested-by: Mike Frysinger &lt;vapier@google.com&gt;
</content>
</entry>
</feed>
