Merge lp://qastaging/~danilo/linaro-android-build-tools/no-seed into lp://qastaging/linaro-android-build-tools

Proposed by Данило Шеган
Status: Merged
Approved by: James Tunnicliffe
Approved revision: 546
Merged at revision: 537
Proposed branch: lp://qastaging/~danilo/linaro-android-build-tools/no-seed
Merge into: lp://qastaging/linaro-android-build-tools
Diff against target: 117 lines (+66/-8)
3 files modified
build-scripts/helpers (+9/-7)
build-scripts/rewrite-manifest.py (+56/-0)
control/setup-control-node (+1/-1)
To merge this branch: bzr merge lp://qastaging/~danilo/linaro-android-build-tools/no-seed
Reviewer Review Type Date Requested Status
James Tunnicliffe (community) Approve
Review via email: mp+135625@code.qastaging.launchpad.net

Description of the change

Use scalable git-over-http access
=================================

This branch introduces manifest rewriting to change any references to
git://git.linaro.org/ and git://android.git.linaro.org/ to their
simple, scalable http URLs (http://(android.)git.linaro.org/git-ro).

At the same time, we need to append '.git' to repository paths.

Along the way, I also kill the non-working 'mirror' functionality for
non-seeded builds: we should be able to get similar performance with seeded
builds if we get a http proxy going on amazon ec2 cloud.

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :
545. By Данило Шеган

Minor string reformatting.

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Looks OK. It feels like this bit should be tidier though:

71 + # Replace git://git.linaro.org/ and http://git.linaro.org/git/
72 + # base URLs with the scalable http://git.linaro.org/git-ro/.
73 + if remote.get('fetch') in (
74 + 'git://git.linaro.org', 'git://git.linaro.org/',
75 + 'http://git.linaro.org/git', 'http://git.linaro.org/git/'):
76 + remote.set('fetch', 'http://git.linaro.org/git-ro/')
77 + remotes_to_handle.add(remote.get('name'))
78 + # Replace git://android.git.linaro.org/ and
79 + # http://android.git.linaro.org/git/ base URLs with the scalable
80 + # http://git.linaro.org/git-ro/.
81 + elif remote.get('fetch') in (
82 + 'git://android.git.linaro.org', 'git://android.git.linaro.org/',
83 + 'http://android.git.linaro.org/git',
84 + 'http://android.git.linaro.org/git/'):
85 + remote.set('fetch', 'http://android.git.linaro.org/git-ro/')
86 + remotes_to_handle.add(remote.get('name'))

Isn't this basically:

url_match = re.search("git://([\w.]*git.linaro.org)(.*?)$", remote.get('fetch'))
if url_match:
    remote.set("fetch", urllib.urljoin("http://" + url_match.group(1)), "git-ro"))

If you wanted to be more careful you could add a check a check that url_match.group(2) is "git/*" or "".

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

Thanks for the review James: I want to keep static paths so it's more obvious what's going on (regular expressions are harder to update and always require you to stop and think to ensure they are doing the right thing). I even thought of defining a dict along the lines of

 rewrite_urls = {
   'git://git.linaro.org/': 'http://git.linaro.org/git-ro/',
   'git://git.linaro.org': 'http://git.linaro.org/git-ro',
   ...
 }

and using that instead. What do you think?

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

The dictionary approach is definitely better, but the trailing slash
causing duplications irritates me. You could rstrip('/') if we don't
need it (I assume we don't).

Agree about regexps - often the cause of write only code!

Revision history for this message
Данило Шеган (danilo) wrote :

That would still lead to code that has to check for several conditions: eg. it'd become something like

  remote_url = remote.get('fetch')
  # Try to see if there's a remote URL
  target_url = rewrite_urls.get(remote_url,
                                rewrite_urls.get(remote_url.rstrip('/'), None))
  if target_url is not None:
     remote.set('fetch', target_url)

(Or, I could repeat the if a few times, but I'd hate that even more).

I don't think the above would be clear enough, and would be easy to break (one would have to ensure URLs in rewrite_urls are without the '/': either with more code, or by trying not to forget that :), and all to save a few measly almost-duplicated lines which would lead to:

  remote_url = remote.get('fetch')
  if remote_url in rewrite_urls:
     remote.set('fetch', rewrite_urls[remote_url])

On top of all this, I don't want to worry about whether repo cares or doesn't care about '/', and I want to copy whatever is being done in the manifest (if there's a trailing '/', I want rewritten URL to have it as well). Sure, we can add more code for that, but it'd make it even less clear what's going on, and it would be longer.

At this time, I want to live with this duplication, but if you really insist, I'll add the code to deal with the slash.

546. By Данило Шеган

Split out URLs being rewritten into a dict as per review.

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

OK, you convinced me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches