summaryrefslogtreecommitdiffstats
path: root/platform_utils.py
Commit message (Collapse)AuthorAgeFilesLines
* Reland "Port _FileDescriptorStreamsNonBlocking to use poll()"Theodore Dubois2020-03-131-3/+15
| | | | | | | | | | | Now that repo 2 requires Python 3, we can reland this. This reverts commit 91d9587e45608a5f95cd842426b43452a60abb5e. Change-Id: Id5b178ebb53bdba04bfa79cbb5c698ae5080c957 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/258672 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Theodore Dubois <tbodt@google.com>
* platform_utils: have Windows select stream return "" at EOFMike Frysinger2020-02-181-1/+1
| | | | | | | | | | This matches *NIX behavior where the last read is '', not None. Bug: https://crbug.com/gerrit/12329 Change-Id: I48b026b4d1b8d7c6abbce198757b970931869e1a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255352 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* Fix blank line issues reported by flake8David Pursehouse2020-02-121-0/+4
| | | | | | | | | | | | | | | | | | | | - E301 expected 1 blank line - E302 expected 2 blank lines - E303 too many blank lines - E305 expected 2 blank lines after class or function definition - E306 expected 1 blank line before a nested definition Fixed automatically with autopep8: git ls-files | grep py$ | xargs autopep8 --in-place \ --select E301,E302,E303,E305,E306 Manually fix issues in project.py caused by misuse of block comments. Change-Id: Iee840fcaff48aae504ddac9c3e76d2acd484f6a9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254599 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: David Pursehouse <dpursehouse@collab.net>
* Revert "Port _FileDescriptorStreamsNonBlocking to use poll()"v1.13.9.1Mike Frysinger2020-02-031-15/+3
| | | | | | | | | | | | | | | | This reverts commit 1e01a7444536b4865feb94c398b68a936a463ddc. Not all platforms support select.poll() currently it seems. At least macOS's Python 2 doesn't (while macOS Python 3 does). Lets back this out for the existing release series and once we start repo-2 which is Python 3-only, we can put this back in. Change-Id: I205206b0fa4fe2d755f4fbc6ec683ad125f27cc2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253072 Reviewed-by: Michael Mortensen <mmortensen@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
* Fix method signature of platform_utils.FileDescriptorStreams._create_stream()Rostislav Krasny2020-01-251-1/+1
| | | | | | | Change-Id: Ib80e4ec5e540d97488e7564703ddbcb74350fdfd Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/251836 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Rostislav Krasny <rostigm@gmail.com>
* Port _FileDescriptorStreamsNonBlocking to use poll()Theodore Dubois2019-12-181-3/+15
| | | | | | | | | | | select() has a limit of FD_SETSIZE file descriptors. If you run repo sync -j500 you'll pretty quickly hit this limit and get "file descriptor out of range for select" errors. poll() has no such limit. Change-Id: I21f350e472bda1db03dcbcc437645c23dbc7a901 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/248852 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Theodore Dubois <tbodt@google.com>
* sync: make .git init more robustMike Frysinger2019-11-121-4/+5
| | | | | | | | | | | | | | | | Hitting Ctrl-C in the middle of this func will leave the .git in a bad state that requires manual recovery. The code tries to catch all exceptions and recover by deleting the incomplete .git dir, but it omits KeyboardInterrupt which Exception misses. We could add that to the recovery path, but we can make this more robust with a different approach: set up everything in .git.tmp/ and only move it to .git/ once we've fully initialized it. Change-Id: I0f5b97f2e19fc39cffc3e5e23993a2da7220f4e3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244733 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
* set default file encoding to utf-8Mike Frysinger2019-06-131-0/+1
| | | | | | | | There's no reason to support any other encoding in these files. This only affects the files themselves and not streams they open. Bug: https://crbug.com/gerrit/10418 Change-Id: I053cb40cd3666ce5c8a0689b9dd938f24ca765bf
* platform_utils: Fix exception handling in _walk_windows_implDavid Pursehouse2018-11-061-1/+1
| | | | Change-Id: I6b79cbc4c1bbbe17ffe8361fe1544434beaa9059
* Add support for long pathsRenaud Paquay2018-10-221-16/+110
| | | | | | | | | | | | | | | | | | | | * Add more file i/o wrappers in platform_utils to allow using long paths (length > MAX_PATH) on Windows. * Paths using the long path syntax ("\\?\" prefix) should never escape the platform_utils API surface area, so that this specific syntax is not visible to the rest of the repo code base. * Forward many calls from os.xxx to platform_utils.xxx in various place to ensure long paths support, specifically when repo decides to delete obsolete directories. * There are more places that need to be converted to support long paths, this commit is an initial effort to unblock a few common use cases. * Also, fix remove function to handle directory symlinks Change-Id: If82ccc408e516e96ff7260be25f8fd2fe3f9571a
* fix some sync error while using python3Dylan Deng2018-07-241-1/+6
| | | | Change-Id: I70925e48756c356d48359679d8ad1b9e33a68595
* Replace all os.remove callsRenaud Paquay2017-08-311-0/+17
| | | | | | | | os.remove raises an exception when deleting read-only files on Windows. Replace all calls with calls to platform_utils.remove, which deals with deals with that issue. Change-Id: I4dc9e0c9a36b4238880520c69f5075eca40f3e66
* Implement islink, readlink and realpath using Win32 apiRenaud Paquay2017-08-311-0/+54
| | | | Change-Id: I18452cbb32d24db73601ad10485dbe6bb278731c
* Port os.rename calls to work on WindowsRenaud Paquay2017-05-291-0/+17
| | | | | | | | os.rename fails on Windows if the destination exists, so replace os.rename to platform_utils.rename which handles the platform differences. Change-Id: I15a86f10f65eedee5b003b80f88a0c28a3e1aa48
* Workaround shutil.rmtree limitation on WindowsRenaud Paquay2017-05-291-0/+15
| | | | | | | | | | By default, shutil.rmtree raises an exception when deleting readonly files on Windows. Replace all shutil.rmtree with platform_utils.rmtree, which adds an error handler to make files read-write when they can't be deleted. Change-Id: I9cfea9a7b3703fb16a82cf69331540c2c179ed53
* Add support for creating symbolic links on WindowsRenaud Paquay2017-05-291-0/+43
| | | | | | | | | | | | Replace all calls to os.symlink with platform_utils.symlink. The Windows implementation calls into the CreateSymbolicLinkW Win32 API, as os.symlink is not supported. Separate the Win32 API definitions into a separate module platform_utils_win32 for clarity. Change-Id: I0714c598664c2df93383734e609d948692c17ec5
* Make "git command" and "forall" work on WindowsRenaud Paquay2017-05-291-0/+169
Python on Windows does not support non blocking file operations. To workaround this issue, we instead use Threads and a Queue to simulate non-blocking calls. This is happens only when running with the native Windows version of Python, meaning Linux and Cygwin are not affected by this change. Change-Id: I4ce23827b096c5138f67a85c721f58a12279bb6f