Merge lp:~elopio/ubuntuone-testing/fix-sourcedeps into lp:ubuntuone-testing

Proposed by Leo Arias
Status: Merged
Approved by: Sidnei da Silva
Approved revision: 103
Merged at revision: 103
Proposed branch: lp:~elopio/ubuntuone-testing/fix-sourcedeps
Merge into: lp:ubuntuone-testing
Diff against target: 140 lines (+0/-122)
2 files modified
Makefile (+0/-1)
utilities/link_external_sourcecode.py (+0/-121)
To merge this branch: bzr merge lp:~elopio/ubuntuone-testing/fix-sourcedeps
Reviewer Review Type Date Requested Status
Sidnei da Silva (community) Approve
Review via email: mp+114306@code.launchpad.net

Commit message

Removed the unnecessary utilities files.
Changed the sourcecode from a link to a directory.
Now it's not necessary for the Makefile to create the sourcecode directory.

Description of the change

The make update-sourcedeps task was failing because there existed a sourcecode symlink.
I tried to copy the task from ubuntuone-servers, so I changed the symlink for a directory, and removed the command to create that directory.
Also, removed a couple of files on the utilities directory that I think shouldn't be there.

To post a comment you must log in.
Revision history for this message
Sidnei da Silva (sidnei) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2011-10-06 19:43:51 +0000
3+++ Makefile 2012-07-10 23:59:23 +0000
4@@ -58,7 +58,6 @@
5
6 $(SOURCEDEPS_SOURCECODE_DIR):
7 mkdir -p $(SOURCEDEPS_DIR)
8- mkdir -p sourcecode
9
10 build-sourcedeps:
11 @echo "Building Python extensions"
12
13=== modified symlink 'sourcecode'
14=== target was u'../sourcedeps/sourcecode/'
15=== removed file 'utilities/__init__.py'
16=== removed file 'utilities/link_external_sourcecode.py'
17--- utilities/link_external_sourcecode.py 2011-10-06 19:43:51 +0000
18+++ utilities/link_external_sourcecode.py 1970-01-01 00:00:00 +0000
19@@ -1,121 +0,0 @@
20-# Copyright 2010 Canonical Ltd. All rights reserved.
21-
22-"""Link external sourcecode."""
23-
24-import os
25-import re
26-import sys
27-import errno
28-import hashlib
29-import subprocess
30-
31-import urllib
32-
33-from bzrlib.branch import Branch
34-from bzrlib.config import LocationConfig
35-from bzrlib.plugin import load_plugins
36-load_plugins()
37-from bzrlib.plugins.launchpad.account import get_lp_login
38-
39-SOURCECODE_DIR = 'sourcecode'
40-
41-
42-def get_branch_config(rootdir):
43- """
44- Retrieves the sourcedeps configuration for an source dir.
45- Returns a dict of (branch, revspec) tuples, keyed by branch name.
46- """
47- config_file = os.path.join(rootdir, 'config-manager.txt')
48- branches = {}
49- with open(config_file, 'r') as stream:
50- for line in stream:
51- line = line.split('#')[0].strip()
52- match = re.match(r'./sourcecode/(\S+)\s+'
53- 'bzr\+ssh://bazaar.launchpad.net/([^;]+)'
54- '(?:;revno=(\d+))?', line)
55- if match:
56- name, branch, revno = match.group(1, 2, 3)
57- if revno is None:
58- revspec = "-1"
59- else:
60- revspec = revno
61- branches[name] = (branch, revspec)
62- return branches
63-
64-
65-def main(parent, target, verbose):
66- """Do the deed."""
67- parent_dir = os.path.realpath(os.path.join(parent, SOURCECODE_DIR))
68- target_dir = os.path.abspath(os.path.join(target, SOURCECODE_DIR))
69-
70- try:
71- os.makedirs(parent_dir)
72- except OSError, e:
73- if e.errno != errno.EEXIST:
74- raise
75- bzr_config = LocationConfig(parent_dir)
76-
77- branches = sorted(get_branch_config(target).items())
78- for branch_name, (quoted_branch_spec, revspec) in branches:
79- revno = int(revspec)
80-
81- # qualify mirror branch name with hash of remote repo path to deal
82- # with changes to the remote branch URL over time
83- branch_spec_digest = hashlib.sha1(quoted_branch_spec).hexdigest()
84- branch_directory = "%s_%s" % (branch_name, branch_spec_digest)
85-
86- source_path = os.path.join(parent_dir, branch_directory)
87- destination_path = os.path.join(target_dir, branch_name)
88-
89- # Remove leftover symlinks/stray files.
90- try:
91- os.remove(destination_path)
92- except OSError, e:
93- if e.errno != errno.EISDIR and e.errno != errno.ENOENT:
94- raise
95-
96- sys.stderr.write('%30s: ' % (branch_name,))
97- sys.stderr.flush()
98-
99- # Create the local mirror branch if it doesn't already exist
100- if not os.path.exists(source_path):
101- username = get_lp_login(bzr_config) or get_lp_login()
102- if username is None:
103- raise RuntimeError("Unable to determine launchpad login")
104- quoted_username = urllib.quote(username)
105- branch_url = ("bzr+ssh://%s@bazaar.launchpad.net/%s" %
106- (quoted_username, quoted_branch_spec))
107- subprocess.check_call(['bzr', 'branch',
108- '--', branch_url, source_path])
109-
110- source_branch = Branch.open(source_path)
111-
112- # Freshen the source branch if required (-1 means we don't care).
113- if revno != -1 and revno > source_branch.revno():
114- subprocess.check_call(['bzr', 'pull', '-r', str(revno),
115- '-d', source_path])
116-
117- if os.path.exists(destination_path):
118- # Overwrite the destination with the appropriate revision.
119- subprocess.check_call(['bzr', 'pull', '--overwrite',
120- '-r', str(revno),
121- '-d', destination_path, '--', source_path])
122- else:
123- # Do a new checkout.
124- subprocess.check_call(['bzr', 'checkout', '--hardlink',
125- '-r', str(revno),
126- '--', source_path, destination_path])
127-
128- # Check the state of the destination branch.
129- destination_branch = Branch.open(destination_path)
130- destination_revno = destination_branch.revno()
131-
132- if verbose:
133- sys.stderr.write('checked out r%d of %s\n' %
134- (destination_revno, branch_name))
135- sys.stderr.flush()
136-
137- # Shouldn't happen, but bzr has lots of bugs.
138- if revno != -1 and destination_revno != revno:
139- raise RuntimeError("Expected revno %d but got revno %d" %
140- (revno, destination_revno))

Subscribers

People subscribed via source and target branches