launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04793
[Merge] lp:~jelmer/launchpad/bzr-code-imports-ui into lp:launchpad
You have been requested to review the proposed merge of lp:~jelmer/launchpad/bzr-code-imports-ui into lp:launchpad.
For more details, see:
https://code.launchpad.net/~jelmer/launchpad/bzr-code-imports-ui/+merge/73153
Make it possible to create new Bazaar code imports in the code import UI, disable the ability to create mirror branches.
This removes the user-visible distinction in the web UI between code imports (syncing from remote non-bzr branches) and mirrors (syncing from remote bzr branches), which should make the UI a bit easier to comprehend.
This doesn't migrate any of the existing mirror branches to be code imports, but that would be the next logical step.
It also doesn't remove the ability to create old-style mirrors via the XML/RPC API used by the "bzr register-branch" command in bzr.
--
https://code.launchpad.net/~jelmer/launchpad/bzr-code-imports-ui/+merge/73153
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jelmer/launchpad/bzr-code-imports-ui into lp:launchpad.
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2011-08-22 18:10:47 +0000
+++ lib/lp/code/browser/branch.py 2011-08-27 23:49:51 +0000
@@ -1120,15 +1120,12 @@
class schema(Interface):
use_template(
- IBranch, include=['owner', 'name', 'url', 'lifecycle_status'])
- branch_type = copy_field(
- IBranch['branch_type'], vocabulary=UICreatableBranchType)
+ IBranch, include=['owner', 'name', 'lifecycle_status'])
for_input = True
- field_names = ['owner', 'name', 'branch_type', 'url', 'lifecycle_status']
+ field_names = ['owner', 'name', 'lifecycle_status']
branch = None
- custom_widget('branch_type', LaunchpadRadioWidgetWithDescription)
custom_widget('lifecycle_status', LaunchpadRadioWidgetWithDescription)
initial_focus_widget = 'name'
@@ -1157,27 +1154,17 @@
"""
return IPerson(self.context, self.user)
- def showOptionalMarker(self, field_name):
- """Don't show the optional marker for url."""
- if field_name == 'url':
- return False
- else:
- return LaunchpadFormView.showOptionalMarker(self, field_name)
-
@action('Register Branch', name='add')
def add_action(self, action, data):
"""Handle a request to create a new branch for this product."""
try:
- ui_branch_type = data['branch_type']
namespace = self.target.getNamespace(data['owner'])
self.branch = namespace.createBranch(
- branch_type=BranchType.items[ui_branch_type.name],
+ branch_type=BranchType.HOSTED,
name=data['name'],
registrant=self.user,
- url=data.get('url'),
+ url=None,
lifecycle_status=data['lifecycle_status'])
- if self.branch.branch_type == BranchType.MIRRORED:
- self.branch.requestMirror()
except BranchCreationForbidden:
self.addError(
"You are not allowed to create branches in %s." %
@@ -1195,36 +1182,6 @@
'owner',
'You are not a member of %s' % owner.displayname)
- branch_type = data.get('branch_type')
- # If branch_type failed to validate, then the rest of the method
- # doesn't make any sense.
- if branch_type is None:
- return
-
- # If the branch is a MIRRORED branch, then the url
- # must be supplied, and if HOSTED the url must *not*
- # be supplied.
- url = data.get('url')
- if branch_type == UICreatableBranchType.MIRRORED:
- if url is None:
- # If the url is not set due to url validation errors,
- # there will be an error set for it.
- error = self.getFieldError('url')
- if not error:
- self.setFieldError(
- 'url',
- 'Branch URLs are required for Mirrored branches.')
- elif branch_type == UICreatableBranchType.HOSTED:
- if url is not None:
- self.setFieldError(
- 'url',
- 'Branch URLs cannot be set for Hosted branches.')
- elif branch_type == UICreatableBranchType.REMOTE:
- # A remote location can, but doesn't have to be set.
- pass
- else:
- raise AssertionError('Unknown branch type')
-
@property
def cancel_url(self):
return canonical_url(self.context)
=== modified file 'lib/lp/code/browser/codeimport.py'
--- lib/lp/code/browser/codeimport.py 2011-05-27 21:12:25 +0000
+++ lib/lp/code/browser/codeimport.py 2011-08-27 23:49:51 +0000
@@ -271,6 +271,16 @@
allow_fragment=False, # Fragment makes no sense in Mercurial
trailing_slash=False) # See http://launchpad.net/bugs/56357.
+ bzr_branch_url = URIField(
+ title=_("Bazaar branch URL"), required=False,
+ description=_("The URL of the Bazaar branch."),
+ allowed_schemes=["http", "https", "bzr"],
+ allow_userinfo=False, # Only anonymous access is supported.
+ allow_port=True,
+ allow_query=False, # Query makes no sense in Mercurial
+ allow_fragment=False, # Fragment makes no sense in Mercurial
+ trailing_slash=False)
+
branch_name = copy_field(
IBranch['name'],
__name__='branch_name',
@@ -346,9 +356,9 @@
# display them separately in the form.
soup = BeautifulSoup(self.widgets['rcs_type']())
fields = soup.findAll('input')
- [cvs_button, svn_button, git_button, hg_button, empty_marker] = [
- field for field in fields
- if field.get('value') in ['CVS', 'BZR_SVN', 'GIT', 'HG', '1']]
+ [cvs_button, svn_button, git_button, hg_button, bzr_button,
+ empty_marker] = [field for field in fields
+ if field.get('value') in ['CVS', 'BZR_SVN', 'GIT', 'HG', 'BZR', '1']]
cvs_button['onclick'] = 'updateWidgets()'
svn_button['onclick'] = 'updateWidgets()'
git_button['onclick'] = 'updateWidgets()'
@@ -358,6 +368,7 @@
self.rcs_type_svn = str(svn_button)
self.rcs_type_git = str(git_button)
self.rcs_type_hg = str(hg_button)
+ self.rcs_type_bzr = str(bzr_button)
self.rcs_type_emptymarker = str(empty_marker)
def _getImportLocation(self, data):
@@ -371,6 +382,8 @@
return None, None, data.get('git_repo_url')
elif rcs_type == RevisionControlSystems.HG:
return None, None, data.get('hg_repo_url')
+ elif rcs_type == RevisionControlSystems.BZR:
+ return None, None, data.get('bzr_branch_url')
else:
raise AssertionError(
'Unexpected revision control type %r.' % rcs_type)
@@ -485,6 +498,9 @@
elif rcs_type == RevisionControlSystems.HG:
self._validateURL(
data.get('hg_repo_url'), field_name='hg_repo_url')
+ elif rcs_type == RevisionControlSystems.BZR:
+ self._validateURL(
+ data.get('bzr_branch_url'), field_name='bzr_branch_url')
else:
raise AssertionError(
'Unexpected revision control type %r.' % rcs_type)
@@ -576,7 +592,8 @@
elif self.code_import.rcs_type in (RevisionControlSystems.SVN,
RevisionControlSystems.BZR_SVN,
RevisionControlSystems.GIT,
- RevisionControlSystems.HG):
+ RevisionControlSystems.HG,
+ RevisionControlSystems.BZR):
self.form_fields = self.form_fields.omit(
'cvs_root', 'cvs_module')
else:
@@ -611,7 +628,8 @@
elif self.code_import.rcs_type in (RevisionControlSystems.SVN,
RevisionControlSystems.BZR_SVN,
RevisionControlSystems.GIT,
- RevisionControlSystems.HG):
+ RevisionControlSystems.HG,
+ RevisionControlSystems.BZR):
self._validateURL(data.get('url'), self.code_import)
else:
raise AssertionError('Unknown rcs_type for code import.')
=== modified file 'lib/lp/code/browser/tests/test_branch.py'
--- lib/lp/code/browser/tests/test_branch.py 2011-08-22 18:10:47 +0000
+++ lib/lp/code/browser/tests/test_branch.py 2011-08-27 23:49:51 +0000
@@ -191,8 +191,8 @@
"This is a short error message.",
branch_view.mirror_status_message)
- def testBranchAddRequestsMirror(self):
- """Registering a mirrored branch requests a mirror."""
+ def testBranchAddRequests(self):
+ """Registering a branch that requests a mirror."""
arbitrary_person = self.factory.makePerson()
arbitrary_product = self.factory.makeProduct()
login_person(arbitrary_person)
@@ -200,9 +200,8 @@
add_view = BranchAddView(arbitrary_person, self.request)
add_view.initialize()
data = {
- 'branch_type': BranchType.MIRRORED,
+ 'branch_type': BranchType.HOSTED,
'name': 'some-branch',
- 'url': 'http://example.com',
'title': 'Branch Title',
'summary': '',
'lifecycle_status': BranchLifecycleStatus.DEVELOPMENT,
@@ -212,15 +211,6 @@
'product': arbitrary_product,
}
add_view.add_action.success(data)
- # Make sure that next_mirror_time is a datetime, not an sqlbuilder
- # expression.
- removeSecurityProxy(add_view.branch).sync()
- now = datetime.now(pytz.timezone('UTC'))
- self.assertNotEqual(None, add_view.branch.next_mirror_time)
- self.assertTrue(
- add_view.branch.next_mirror_time < now,
- "next_mirror_time not set to UTC_NOW: %s < %s"
- % (add_view.branch.next_mirror_time, now))
finally:
logout()
=== modified file 'lib/lp/code/enums.py'
--- lib/lp/code/enums.py 2011-08-25 23:32:36 +0000
+++ lib/lp/code/enums.py 2011-08-27 23:49:51 +0000
@@ -99,8 +99,8 @@
IMPORTED = DBItem(3, """
Imported
- Branches that have been converted from some other revision
- control system into bzr and are made available through Launchpad.
+ Branches that have been imported from an externally hosted
+ branch in bzr or another VCS and are made available through Launchpad.
""")
REMOTE = DBItem(4, """
=== modified file 'lib/lp/code/stories/branches/xx-creating-branches.txt'
--- lib/lp/code/stories/branches/xx-creating-branches.txt 2010-10-18 22:24:59 +0000
+++ lib/lp/code/stories/branches/xx-creating-branches.txt 2011-08-27 23:49:51 +0000
@@ -32,94 +32,8 @@
>>> browser.open('http://code.launchpad.dev/redfish')
>>> browser.getLink("Register a branch").click()
- >>> browser.getControl('Hosted').click()
>>> browser.getControl('Name').value = 'hosted-branch'
-Branch URLs are not valid for hosted branches.
-
- >>> browser.getControl('Branch URL').value = (
- ... 'http://example.com/hosted-branch')
- >>> browser.getControl('Register Branch').click()
- >>> for message in get_feedback_messages(browser.contents):
- ... print message
- There is 1 error.
- Branch URLs cannot be set for Hosted branches.
-
- >>> browser.getControl('Branch URL').value = ''
- >>> browser.getControl('Register Branch').click()
-
- >>> def print_branch_info(browser):
- ... branch_info = find_tag_by_id(browser.contents, 'branch-info')
- ... print extract_text(branch_info)
- >>> print_branch_info(browser)
- Branch information
- Owner: Sample Person
- Project: Redfish
- Status: Development
-
-
-Creating a mirrored branch
---------------------------
-
-Mirrored branches are primarily hosted outside of Launchpad, and
-Launchpad mirrors the branch.
-
- >>> browser.open('http://code.launchpad.dev/redfish')
- >>> browser.getLink("Register a branch").click()
-
- >>> print_radio_button_field(browser.contents, 'branch_type')
- ( ) Hosted
- (*) Mirrored
- ( ) Remote
-
- >>> browser.getControl('Name').value = 'mirrored-branch'
-
-Branch URLs are required for mirrored branches.
-
- >>> browser.getControl('Register Branch').click()
- >>> for message in get_feedback_messages(browser.contents):
- ... print message
- There is 1 error.
- Branch URLs are required for Mirrored branches.
-
- >>> browser.getControl('Branch URL').value = (
- ... 'http://example.com/mirrored-branch')
- >>> browser.getControl('Register Branch').click()
-
- >>> print_branch_info(browser)
- Branch information
- Owner: Sample Person
- Project: Redfish
- Status: Development
- Location: http://example.com/mirrored-branch
- Last mirrored: Not mirrored yet
- Next mirror: As soon as possible
-
-
-Creating a remote branch
-------------------------
-
-The contents of Remote branches are not accessible through Launchpad.
-
- >>> browser.open('http://code.launchpad.dev/redfish')
- >>> browser.getLink("Register a branch").click()
-
- >>> browser.getControl('Remote').click()
- >>> browser.getControl('Name').value = 'remote-branch'
-
-A remote branch may have a URL, but doesn't have to.
-
- >>> browser.getControl('Branch URL').value = (
- ... 'http://example.com/remote-branch')
- >>> browser.getControl('Register Branch').click()
- >>> print_branch_info(browser)
- Branch information
- Owner: Sample Person
- Project: Redfish
- Status: Development
- Location: http://example.com/remote-branch
-
-
Finding product/+addbranch
--------------------------
@@ -209,34 +123,6 @@
Other branches owned by No Privileges Person
-Adding a branch via a product series
-------------------------------------
-
-A user can register a branch from the project series page using the
-'Submit code' link, or in the case of a series driver, by using the
-'registering a mirrored branch' link.
-
- >>> browser.open('http://launchpad.dev/gnome-terminal/trunk')
- >>> browser.getLink('registering a mirrored branch').click()
- >>> print browser.title
- Register a branch : Code : GNOME Terminal
-
-The user sees that he is registering a branch for the series' project.
-
- >>> print extract_text(find_main_content(browser.contents).h1)
- Register a branch on GNOME Terminal
-
-After posting the form, he sees the registered branch page.
-
- >>> browser.getControl('Branch URL').value = (
- ... 'http://example.com/applets/master')
- >>> browser.getControl('Name').value = 'master'
- >>> browser.getControl('Experimental').click()
- >>> browser.getControl('Register Branch').click()
- >>> print browser.title
- master : Code : GNOME Terminal
-
-
Finding person/+addbranch
-------------------------
@@ -271,7 +157,6 @@
Ubuntu Gnome Team (name18)
Warty Security Team (name20)
-
Conflict on unique name
-----------------------
@@ -288,8 +173,6 @@
Try a adding a conflicting branch from the product/+addbranch form.
>>> browser.open('http://code.launchpad.dev/gnome-terminal/+addbranch')
- >>> browser.getControl('Branch URL').value = (
- ... 'http://example.com/gnome-terminal/main-dup')
Trying to post the form without filling a name at all should not cause
an oops!
@@ -321,7 +204,6 @@
>>> browser.getControl('Owner').displayValue = [
... 'Landscape Developers']
>>> browser.getControl('Name').value = 'main'
- >>> browser.getControl('Hosted').click()
>>> browser.getControl('Register Branch').click()
>>> print browser.url
http://code.launchpad.dev/~landscape-developers/gnome-terminal/main
@@ -335,7 +217,6 @@
>>> browser.getControl('Owner').displayValue = [
... 'Landscape Developers']
>>> browser.getControl('Name').value = 'main'
- >>> browser.getControl('Hosted').click()
>>> browser.getControl('Register Branch').click()
>>> for message in get_feedback_messages(browser.contents):
... print extract_text(message)
@@ -343,65 +224,6 @@
Landscape Developers already has a branch for GNOME Terminal called main.
-Checking URLs
--------------
-
-URL validation should check that the entered URL is not the root of a
-site.
-
- >>> user_browser.open('http://code.launchpad.dev/applets')
- >>> user_browser.getLink("Register a branch").click()
- >>> user_browser.getControl('Branch URL').value = 'http://example.com'
- >>> user_browser.getControl('Name').value = 'unique-name'
- >>> user_browser.getControl('Register Branch').click()
- >>> messages = find_tags_by_class(user_browser.contents, 'message')
- >>> for element in messages:
- ... print element.renderContents()
- There is 1 error.
- URLs for branches cannot point to the root of a site.
-
-URL validation should check that the entered URL is not from Launchpad.
-
- >>> user_browser.open('http://code.launchpad.dev/applets')
- >>> user_browser.getLink("Register a branch").click()
- >>> user_browser.getControl('Branch URL').value = (
- ... 'http://code.launchpad.dev/~testuser/')
- >>> user_browser.getControl('Name').value = 'unique-name'
- >>> user_browser.getControl('Register Branch').click()
- >>> for message in get_feedback_messages(user_browser.contents):
- ... print message
- There is 1 error.
- For Launchpad to mirror a branch, the original branch cannot be on
- launchpad.dev.
-
-As well as checking against the root site set in the config, a check is
-also done against the value stored as a database constraint.
-
- >>> user_browser.open('http://code.launchpad.dev/applets')
- >>> user_browser.getLink("Register a branch").click()
- >>> user_browser.getControl('Branch URL').value = (
- ... 'http://bazaar.launchpad.net/foo/bar/')
- >>> user_browser.getControl('Name').value = 'unique-name'
- >>> user_browser.getControl('Register Branch').click()
- >>> for message in get_feedback_messages(user_browser.contents):
- ... print message
- There is 1 error.
- For Launchpad to mirror a branch, the original branch cannot be on
- http://bazaar.launchpad.net.
-
-Trailing slashes on URLs are removed.
-
- >>> user_browser.getControl('Branch URL').value = (
- ... 'sftp://example.com/~lifeless/pyresources/')
- >>> user_browser.getControl('Register Branch').click()
- >>> print_tag_with_id(user_browser.contents, 'branch-info')
- Branch information
- Owner: ...
- ...
- Location: sftp://example.com/~lifeless/pyresources
- ...
-
-
Attempting to create a branch in a forbidden project
----------------------------------------------------
@@ -423,7 +245,6 @@
>>> user_browser.open('http://code.launchpad.dev/landscape')
>>> user_browser.getLink("Register a branch").click()
- >>> user_browser.getControl('Branch URL').value = 'http://foo.com/bar'
>>> user_browser.getControl('Name').value = 'landscape1'
>>> user_browser.getControl('Register Branch').click()
>>> messages = find_tags_by_class(user_browser.contents, 'message')
=== modified file 'lib/lp/code/stories/codeimport/xx-create-codeimport.txt'
--- lib/lp/code/stories/codeimport/xx-create-codeimport.txt 2010-09-28 19:25:54 +0000
+++ lib/lp/code/stories/codeimport/xx-create-codeimport.txt 2011-08-27 23:49:51 +0000
@@ -56,6 +56,7 @@
The default foreign VCS type is Subversion.
>>> print_radio_button_field(browser.contents, "rcs_type")
+ ( ) Bazaar
( ) Git
( ) Mercurial
(*) Subversion
=== modified file 'lib/lp/code/templates/branch-form-macros.pt'
--- lib/lp/code/templates/branch-form-macros.pt 2009-10-02 15:02:23 +0000
+++ lib/lp/code/templates/branch-form-macros.pt 2011-08-27 23:49:51 +0000
@@ -17,20 +17,6 @@
<script type="text/javascript">
//<![CDATA[
-function update_branch_url()
-{
- var branch_type_field = document.getElementsByName('field.branch_type')
- var form = branch_type_field[0].form;
- var branch_type = 'None';
- for (var i = 0; i < branch_type_field.length; i++) {
- if (branch_type_field[i].checked) {
- branch_type = branch_type_field[i].value;
- break;
- }
- }
- updateField(form['field.url'], branch_type != 'HOSTED');
-}
-
function update_branch_unique_name()
{
var unique_name = document.getElementById("branch-unique-name")
@@ -43,44 +29,16 @@
unique_name.innerHTML = branch_name
}
-function populate_branch_name_from_url()
-{
- url_field = document.getElementById('field.url');
- var url_text = trim(url_field.value);
- // strip of any trailing slashes
- url_text = url_text.replace(/\/+$/, '')
- if (url_text != url_field.value) {
- url_field.value = url_text;
- }
- var name_field = document.getElementById('field.name');
- if (name_field.value == '')
- {
- // parse the value of the url field
- url_bits = url_text.split('/');
- if (url_bits.length > 2) {
- // attempt at not barfing on something completely invalid
- last_bit = url_bits[url_bits.length - 1];
- name_field.value = last_bit;
- }
- }
-}
-
function hookUpBranchFieldFunctions()
{
connect('field.owner', 'onkeyup', update_branch_unique_name);
connect('field.owner', 'onchange', update_branch_unique_name);
connect('field.name', 'onkeyup', update_branch_unique_name);
- connect('field.branch_type.0', 'onclick', update_branch_url);
- connect('field.branch_type.1', 'onclick', update_branch_url);
- connect('field.branch_type.2', 'onclick', update_branch_url);
update_branch_unique_name();
- connect('field.url', 'onchange', populate_branch_name_from_url);
- connect('field.url', 'onblur', populate_branch_name_from_url);
document.getElementById("branch-unique-name-div").style.display = "block";
}
registerLaunchpadFunction(hookUpBranchFieldFunctions);
-registerLaunchpadFunction(update_branch_url);
//]]>
</script>
=== modified file 'lib/lp/code/templates/branch-import-details.pt'
--- lib/lp/code/templates/branch-import-details.pt 2010-06-10 07:54:59 +0000
+++ lib/lp/code/templates/branch-import-details.pt 2011-08-27 23:49:51 +0000
@@ -51,6 +51,12 @@
</p>
</tal:hg-import>
+ <tal:bzr-import condition="code_import/rcs_type/enumvalue:BZR">
+ <p>This branch is an import of the Bazaar branch at
+ <span tal:replace="code_import/url" />.
+ </p>
+ </tal:bzr-import>
+
<tal:svn-import condition="view/is_svn_import">
<p id="svn-import-details">
This branch is an import of the
=== modified file 'lib/lp/code/templates/codeimport-new.pt'
--- lib/lp/code/templates/codeimport-new.pt 2010-04-22 23:50:51 +0000
+++ lib/lp/code/templates/codeimport-new.pt 2011-08-27 23:49:51 +0000
@@ -53,6 +53,20 @@
<tr>
<td>
<label>
+ <input tal:replace="structure view/rcs_type_bzr" />
+ Bazaar
+ </label>
+ <table class="importdetails">
+ <tal:widget define="widget nocall:view/widgets/bzr_branch_url">
+ <metal:block use-macro="context/@@launchpad_form/widget_row" />
+ </tal:widget>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <label>
<input tal:replace="structure view/rcs_type_git" />
Git
</label>
=== modified file 'lib/lp/registry/browser/productseries.py'
--- lib/lp/registry/browser/productseries.py 2011-08-24 21:17:35 +0000
+++ lib/lp/registry/browser/productseries.py 2011-08-27 23:49:51 +0000
@@ -1090,8 +1090,7 @@
# Create a new branch.
if branch_type == CREATE_NEW:
- branch = self._createBzrBranch(
- BranchType.HOSTED, branch_name, branch_owner)
+ branch = self._createBzrBranch(branch_name, branch_owner)
if branch is not None:
self.context.branch = branch
self.request.response.addInfoNotification(
@@ -1102,55 +1101,42 @@
# Either create an externally hosted bzr branch
# (a.k.a. 'mirrored') or create a new code import.
rcs_type = data.get('rcs_type')
- if rcs_type == RevisionControlSystems.BZR:
- branch = self._createBzrBranch(
- BranchType.MIRRORED, branch_name, branch_owner,
- data['repo_url'])
- if branch is None:
- return
-
- self.context.branch = branch
- self.request.response.addInfoNotification(
- 'Mirrored branch created and linked to '
- 'the series.')
+ # We need to create an import request.
+ if rcs_type == RevisionControlSystems.CVS:
+ cvs_root = data.get('repo_url')
+ cvs_module = data.get('cvs_module')
+ url = None
else:
- # We need to create an import request.
- if rcs_type == RevisionControlSystems.CVS:
- cvs_root = data.get('repo_url')
- cvs_module = data.get('cvs_module')
- url = None
- else:
- cvs_root = None
- cvs_module = None
- url = data.get('repo_url')
- rcs_item = RevisionControlSystems.items[rcs_type.name]
- try:
- code_import = getUtility(ICodeImportSet).new(
- registrant=branch_owner,
- target=IBranchTarget(self.context.product),
- branch_name=branch_name,
- rcs_type=rcs_item,
- url=url,
- cvs_root=cvs_root,
- cvs_module=cvs_module)
- except BranchExists, e:
- self._setBranchExists(e.existing_branch,
- 'branch_name')
- self.errors_in_action = True
- # Abort transaction. This is normally handled
- # by LaunchpadFormView, but we are already in
- # the success handler.
- self._abort()
- return
- self.context.branch = code_import.branch
- self.request.response.addInfoNotification(
- 'Code import created and branch linked to the '
- 'series.')
+ cvs_root = None
+ cvs_module = None
+ url = data.get('repo_url')
+ rcs_item = RevisionControlSystems.items[rcs_type.name]
+ try:
+ code_import = getUtility(ICodeImportSet).new(
+ registrant=branch_owner,
+ target=IBranchTarget(self.context.product),
+ branch_name=branch_name,
+ rcs_type=rcs_item,
+ url=url,
+ cvs_root=cvs_root,
+ cvs_module=cvs_module)
+ except BranchExists, e:
+ self._setBranchExists(e.existing_branch,
+ 'branch_name')
+ self.errors_in_action = True
+ # Abort transaction. This is normally handled
+ # by LaunchpadFormView, but we are already in
+ # the success handler.
+ self._abort()
+ return
+ self.context.branch = code_import.branch
+ self.request.response.addInfoNotification(
+ 'Code import created and branch linked to the '
+ 'series.')
else:
raise UnexpectedFormData(branch_type)
- def _createBzrBranch(self, branch_type, branch_name,
- branch_owner, repo_url=None):
+ def _createBzrBranch(self, branch_name, branch_owner, repo_url=None):
"""Create a new Bazaar branch. It may be hosted or mirrored.
Return the branch on success or None.
@@ -1158,12 +1144,10 @@
branch = None
try:
namespace = self.target.getNamespace(branch_owner)
- branch = namespace.createBranch(branch_type=branch_type,
+ branch = namespace.createBranch(branch_type=BranchType.HOSTED,
name=branch_name,
registrant=self.user,
url=repo_url)
- if branch_type == BranchType.MIRRORED:
- branch.requestMirror()
except BranchCreationForbidden:
self.addError(
"You are not allowed to create branches in %s." %
=== modified file 'lib/lp/registry/templates/productseries-codesummary.pt'
--- lib/lp/registry/templates/productseries-codesummary.pt 2011-05-16 20:55:08 +0000
+++ lib/lp/registry/templates/productseries-codesummary.pt 2011-08-27 23:49:51 +0000
@@ -54,7 +54,7 @@
</li>
<li>
- If the code is in Git, Mercurial, CVS or Subversion you can
+ If the code is in Git, Mercurial, CVS, Subversion or an external Bazaar branch you can
<a tal:attributes="href view/request_import_link">request that the branch be imported to Bazaar</a>.
</li>
</ul>