Commit Graph

128 Commits

Author SHA1 Message Date
Rob Prentiss
0f44c0c91d update-checkout: Explicitly use python3
This changes the shebangs for the update_checkout executable files to
specifically call Python 3. The code is already compatible and
functional with python3, so this removes any implied backward
compatibility, and removes any ambiguity based on the user's current
environment, especially since some systems, like macOS, still link
'python' to Python 2.

This also removes the now unnecessary 'from __future__' imports.
2021-11-10 15:29:38 -08:00
tbkka
d693ef017e Disable a hack that causes breakage on Python 3.8 (#33137)
Hacking sys.modules here was added unconditionally to fix an import problem on
Windows (with Python 2.7???).

This script works fine on Python 2.7 on macOS either with or without this hack.

This script breaks badly on Python 3.8 on macOS with this hack, so I've disabled
it here for all Python 3.
2020-07-27 16:28:50 -07:00
tbkka
3459fe8d3f [Python3] Make update-checkout work with Python 2 & 3 (#33081)
* Python3 compatibility for Benchmarks

Three issues addressed here:

1. Dependency on dictionary iteration order

 CharacterProperties.swift.gyb iterated a dictionary to produce its output.
 Changed this to a list of tuples to ensure the order is predictable.

2. Python3 `map` returns an iterator, not a list

 Changed a bunch of `map` calls to `list(map(...))` to ensure the result is a list

3. Python3 `int()` expects a string, won't accept a list of characters

 Added a concatenation step that is effectively a no-op on Python2

* Make update-checkout work with Python3

Python3 doesn't like to pickle local functions, so make the multiprocessing
initialization function be global.

Python3 multiprocessing also seems to require conditional execution of the
top-level code.  TBH, I'm not entirely sure why Python 2 didn't need this.

* Adjust whitespace per python-lint
2020-07-24 09:22:57 -07:00
Hugh Bellamy
36645a0976 Address FIXMES for cleaning up imports in build-script and friends 2017-04-01 09:54:01 +07:00
Hugh Bellamy
dfe3af81b2 Add forwarding script for update-checkout 2017-03-31 09:50:15 +07:00
Hugh Bellamy
d0cc071237 Move functionality of update-checkout to a update_checkout.py 2017-03-31 09:50:15 +07:00
practicalswift
e995022395 [gardening] Avoid flake8 warning "B901 blind except: statement" 2017-03-28 22:43:23 +02:00
Hugh Bellamy
ad4b338062 Fix python lint failures now not excluded as we provide custom exclusions
Looks like flake8 enables other rules when you add something to the
exclusion list. We added W291
2017-03-27 12:31:56 +07:00
Hugh Bellamy
f2ffcf7abd Fix update-checkout flake8 errors 2017-02-24 11:29:12 +07:00
Graydon Hoare
e617d110f1 [update-checkout] Add --match-timestamp mode to sync adjacent repos while bisecting. 2017-02-16 14:10:19 -08:00
Hugh Bellamy
36f07499df Python lint update-checkout 2017-02-09 18:15:06 +07:00
Colin Douglas Howell
fecbd22cb4 utils/update-checkout: Rework for more parallelism in updates
Reworks the update_all_repositories() and update_single_repository()
functions to benefit from more per-repo parallelism.

* Branch-scheme search loop is relocated from update_repository_to_scheme()
  to update_all_repositories().
* Functions update_repository_to_tag() and update_repository_to_scheme()
  are removed.
* Per-repo work of these functions is shifted to update_single_repository().
* Repeated work (repeated pushd's, etc.) has been eliminated.
* As much work as possible is performed within update_single_repository()'s
  outer try clause to catch more errors.
* Arguments passed to update_single_repository() have been changed
  appropriately.
* New helper functions confirm_tag_in_repo() and get_branch_for_repo() added
  to keep update_single_repository()'s length under control.
* Unnecessary setting of the cross_repo flag by the --tag argument has been
  removed, so repos which lack the tag are now properly rebased when updated.
2017-02-07 16:05:32 -08:00
Colin Douglas Howell
03125798f8 utils/update-checkout: Fix for mishandling detached HEAD in SR-3854 (#7232)
* utils/update-checkout: Fix for mishandling detached HEAD in SR-3854

In update_single_repository, before doing the rebase step, check whether
the current HEAD is a "detached HEAD", normally the result of checking
out a tag by previously invoking update-checkout with the --tag option.
If HEAD is a detached HEAD, skip the rebase (and print an explanatory
message), because rebasing would do the wrong thing and make a mess.

* utils/update-checkout: more robust error handling for SR-3854 fix

We now examine the exception raised by the "git symbolic-ref -q HEAD"
command to check whether the exception was indeed due to a detached HEAD.
If there was an actual error in the command, we re-raise the exception
so that it can be handled like errors from other commands.
2017-02-07 09:53:04 -08:00
Doug Coleman
309312d81c utils/update-checkout: Handle missing repository/tag combinations.
Fixes https://bugs.swift.org/browse/SR-3810
2017-02-01 13:01:04 -08:00
Doug Coleman
07ddf07f3b utils/update-checkout: Do any `git checkout before the git fetch`.
utils/update-checkout: Add a call to ``git rebase --abort`` when using the ``--clean`` option.
Calling ``git fetch`` updates .git/FETCH_HEAD and marks all branches
besides the currently checked out branch as not-for-merge. So tot
ensure that the branch we want to merge is available for merging, we
must do a checkout of that branch before updating the FETCH_HEAD file.

We also must ensure that we have fetched before optionally resetting to remote.

Fixes https://bugs.swift.org/browse/SR-3800.

The --clean option is meant to restore your repository to a pristine
condition, but there are cases where you can ``reset --hard`` and still be
in the middle of a rebase. This is annoying across 10+ repositories, so
if the user wants to --clean, then abort all rebases in progress.
2017-01-31 12:48:09 -08:00
swift-ci
da8f4151e6 Merge pull request #6781 from gmilos/master 2017-01-20 12:20:24 -08:00
Andy Bargh
631495ce30 Fix 'eixsts' typo 2017-01-20 14:45:22 +00:00
Maxim Moiseev
2c65c774d5 [update-checkout] Replace --branch with --scheme
...in an error message.
2017-01-19 12:09:24 -08:00
Michael Gottesman
f606dc5475 [update-checkout] Now that all of the bots use --scheme instead of --branch, remove --branch. 2017-01-13 12:59:40 -08:00
Grzegorz Miłoś
542fe0d4ef update-checkout supports --dump-hashes-config.
The config can stored and passed to update-checkout with --config
recreating the same set of repos as at the time of the dump.
2017-01-13 18:43:56 +00:00
Grzegorz Miłoś
34099d4ed8 Force branch-scheme aliases to include the scheme name. 2017-01-13 18:21:08 +00:00
Grzegorz Miłoś
b46ce6c341 Fix update-checkout --dump-hashes. 2017-01-13 16:36:20 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Doug Coleman
3753f59f52 utils: Make update-checkout run in parallel. 2017-01-04 14:23:22 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Aleksey Gaponov
ed865fc9c7 [utils][SR-2695] Add support for a specific tag checkout. 2016-09-29 10:46:18 +02:00
Michael Gottesman
a3990b93fe [update-checkout] Add an option '--dump-hashes' for dumping the checked out hashes for each repo.
I think update-checkout is growing to the point, we should probably rename it to
something like repo-tool.

The output of this command looks as follows:

clang                              973bd1a Merge remote-tracking branch 'origin/swift-3.1-branch' into stable
cmark                              5af77f3 Merge pull request #95 from kainjow/master
compiler-rt                        1f24bd0 Merge remote-tracking branch 'origin/swift-3.1-branch' into stable
llbuild                            c324ee3 Merge pull request #35 from tinysun212/pr-cygwin-1
lldb                               f6a5830 Adjust LLDB for changes to the layout of _SwiftTypePreservingNSNumber
llvm                               52482d0 Merge remote-tracking branch 'origin/swift-3.1-branch' into stable
swift                              45f3d2a [update-checkout] Add a small tool to dump hashes for all of the checkout repos.
swift-corelibs-foundation          cc5985e Loopback tests for URLSession (#613)
swift-corelibs-libdispatch         ba7802e Merge pull request #178 from dgrove-oss/depend-on-swiftc
swift-corelibs-xctest              51b419d Merge pull request #174 from modocache/sr-1901-remove-workarounds
swift-integration-tests            c95c832 Merge pull request #12 from abertelrud/fix-swift-package-init-lib-test
swift-xcode-playground-support     4b40c34 Merge pull request #10 from apple/stdlib-unittest-expect-nil
swiftpm                            65403f5 [ConventionTests] Collect all the diagnostics from PackageBuilder
2016-09-28 15:19:19 -07:00
practicalswift
ee871c7938 [python] Bring code base in line with PEP-8 again 2016-09-16 19:33:04 +02:00
Mishal Shah
27fd7f2c0d [utils] Update checkout should skip remote reset for PR branch (#4647) 2016-09-06 15:38:21 -07:00
Mishal Shah
93f7be26c3 [utils] Add support for URL in github comment regex 2016-09-06 13:45:07 -07:00
Mishal Shah
d790b5ffce [utils] Cross repositories pull request test support (#4583)
* [utils] Cross repositories pull request test support
2016-09-01 14:52:25 -07:00
Alex Blewitt
b120535d20 [build-script] Clean submodules where applicable (#4553)
When building Swift from a non-clean checkout, the `git reset` that
occurs on subprojects that include submodules may fail if the submodule
is deemed to have been changed (for example, by running the autoconf
scripts).

When cleaning the projects, ensure that `git submodule` is used to clean
submodules and reset them to their original state as well, so that the
project can be reset successfully.

Issue: SR-2524
2016-08-30 11:57:42 -07:00
Michael Gottesman
592999d188 [update-checkout] Accept scheme along side branch to set the scheme argument.
In order to not break the bots, I kept on accepting branch to specify the branch
scheme that defines the branches used for each repo. This now allows us to
accept both arguments to specify the branch scheme. Once the bots have migrated,
I will remove support for specifying the branch scheme via --branch.
2016-08-08 22:03:20 -07:00
Dave Abrahams
5e9895ebf1 [update-checkout] support submodules
swift-corelibs-libdispatch is using them.
2016-08-08 16:31:57 -07:00
Michael Gottesman
68661f9d1f [update-checkout] When cleaning, first do a reset --hard to HEAD. 2016-07-28 10:58:47 -07:00
Michael Gottesman
0fa1226828 [update-checkout] Add the --clean option that runs git clean -fdx on non-skipped repos.
This enables one to get pristine checkouts by using update-checkout --clean
--reset-to-remote --branch master. I need it for incremental buildbots.
2016-07-28 09:41:48 -07:00
Michael Gottesman
ecddf6bb93 [update-checkout] Add an option --reset-to-remote that can be used with --branch to reset a selected scheme's local branches to the remote branch state.
This is useful when one has done some quick prototyping work on the various
repos of a scheme that one wants to quickly get rid of.
2016-07-11 13:56:34 -07:00
Michael Gottesman
2c37f078c0 [update-checkout] Only use the default-branch-scheme when cloning.
We want to allow for people to use update-checkout to just update branches even
in the case where they are not using a scheme (for instance if they have a side
branch).

This means though that one can still clone and get all of the appropriate
repos/branches.

The only unfortunate thing about this change is that when cloning, already
cloned repositories that already are setup to a branch will have their branch
changed.

It would be good at some point to separate updating from cloning. It would make
update-checkout much cleaner.
2016-06-26 16:41:16 -07:00
Michael Gottesman
11b894d195 [gardening] Fix some flake8 failures. 2016-06-21 21:13:02 -07:00
Mishal Shah
b2903a9b3d [utils] Fix dir_name -> repo_name 2016-06-21 14:52:25 -07:00
Mishal Shah
9252b88593 [utils] Fix submodule logic for update-checkout script 2016-06-21 14:44:56 -07:00
Michael Gottesman
3f47dfadca [gardening] Improve error message. 2016-06-18 23:58:00 -07:00
Michael Gottesman
3907612f91 [update-checkout] Give the skip repository list a name (skip_repository_list) that makes it clear that it is many repositories. This does not change the script interface. 2016-06-18 23:56:04 -07:00
Michael Gottesman
e3de850624 [update-checkout] Small refactoring to make it clear that config['repos'] contains generic repo information, not just remote information.
I was trying to get this right a bit ago, but I remained unhappy with the
result. This at least makes it clear when reading the config file that
config['repos'].keys() serves in the code as the "source" of the names of
repositories.
2016-06-18 23:39:40 -07:00
Michael Gottesman
aec15faad8 [update-checkout] Rename the 'branch' concept to 'scheme'.
update-checkout as a script has two different concepts associated with the term
'branch':

1. A "real" git branch.
2. A dictionary of names mapped to lists of (repo, git branch) pairs.

The second concept is used to specify on the command line a "palette" of
branches in all of the repositories associated with things like "master",
"master-next", and the preview branches. This is far more than a "branch". This
commit gives a unique name, "scheme" to that concept.

Keep in mind that even though the internals have changed, the outside interface
(i.e. --branch) is still the same.

That will change at a later time since I would like to change the interface
slightly which may require bots to be updated.
2016-06-18 23:25:28 -07:00
Michael Gottesman
e9c2aa8fd9 [update-checkout] Perform following rename: config['repositories'][repo]['{name,remote-repo-name}']
This makes it absolutely clear when reading the config file that this is a name on the remote server.
2016-06-18 23:10:48 -07:00
Michael Gottesman
74b9206d2e [update-checkout] Refactor out the update working copy loop into its own function (update_all_repositories) and rename the old update_working_copy to update_single_repository (which is really what it does). 2016-06-18 22:38:44 -07:00
Michael Gottesman
b727977806 [gardening][py] Reduce indentation by creating an early exit. 2016-06-18 22:13:07 -07:00
Michael Gottesman
829ff3d38b [gardening] cd into SWIFT_SOURCE_ROOT once for all directories, instead of for each directory.
NFC.
2016-06-18 22:11:17 -07:00
Michael Gottesman
9a6e4f6124 [gardening] Instead of iterating over a dictionary's (k,v) and just using the key, just iterate over the keys! NFC. 2016-06-18 21:50:55 -07:00