> + """Create a new code import for this target.
> +
> + :param registrant: the `IPerson` who should be recorded as creating
> + the import and will own the resulting branch.
> + :param branch_name: the name the resulting branch should have.
> + :param rcs_type: the type of the foreign VCS.
> + :param url: the url to import from if the import isn't CVS.
> + :param cvs_root: if the import is from CVS the CVSROOT to import from.
> + :param cvs_module: if the import is from CVS the module to import.
> + :returns: an `ICodeImport`.
> + :raises AssertionError: if supports_code_imports is False.
> + """
Two minor whitespace tweaks please, or rather the same one in two
places. Other than that, awesome!
> === modified file 'lib/lp/ code/interfaces /branchtarget. py' code/interfaces /branchtarget. py 2010-01-05 08:18:23 +0000 code/interfaces /branchtarget. py 2010-03-26 01:45:34 +0000 merge_proposals = Attribute( code_imports = Attribute( eable(other_ target) : registrant, branch_name, rcs_type,
> --- lib/lp/
> +++ lib/lp/
> @@ -88,6 +88,9 @@
> supports_
> "Does this target support merge proposals at all?")
>
> + supports_
> + "Does this target support code imports at all?")
> +
> def areBranchesMerg
> """Are branches from other_target mergeable into this target."""
>
> @@ -113,3 +116,18 @@
>
> def getBugTask(bug):
> """Get the BugTask for a given bug related to the branch target."""
> +
> + def newCodeImport(
> + url=None, cvs_root=None, cvs_module=None):
This should be formatted like so:
def newCodeImport( registrant, branch_name, rcs_type, url=None,
cvs_root= None, cvs_module=None):
(https:/ /dev.launchpad. net/PythonStyle Guide#Wrapping% 20long% 20arguments% 20in%20function %20definitions)
> + """Create a new code import for this target. code_imports is False.
> +
> + :param registrant: the `IPerson` who should be recorded as creating
> + the import and will own the resulting branch.
> + :param branch_name: the name the resulting branch should have.
> + :param rcs_type: the type of the foreign VCS.
> + :param url: the url to import from if the import isn't CVS.
> + :param cvs_root: if the import is from CVS the CVSROOT to import from.
> + :param cvs_module: if the import is from CVS the module to import.
> + :returns: an `ICodeImport`.
> + :raises AssertionError: if supports_
> + """
> === modified file 'lib/lp/ code/model/ branchtarget. py' code/model/ branchtarget. py 2010-01-05 08:18:23 +0000 code/model/ branchtarget. py 2010-03-26 01:45:34 +0000 interfaces. branchcollectio n import IAllBranches interfaces. branchtarget import ( stacked_ on, IBranchTarget) interfaces. codeimport import ICodeImportSet interfaces. pocket import PackagePublishi ngPocket launchpad. webapp. interfaces import ICanonicalUrlData
> --- lib/lp/
> +++ lib/lp/
> @@ -19,6 +19,7 @@
> from lp.code.
> from lp.code.
> check_default_
> +from lp.code.
> from lp.registry.
> from canonical.
>
> @@ -36,6 +37,12 @@
> def __ne__(self, other):
> return self.context != other.context
>
> + def newCodeImport(self, registrant, branch_name, rcs_type, url=None,
> + cvs_root=None, cvs_module=None):
Similarly.
> + return getUtility( ICodeImportSet) .new( cvs_module) rget(_BaseBranc hTarget) : IBranchTarget) code_imports( self): eable(self, other_target): code_imports( self): eable(self, other_target): code_imports( self): eable(self, other_target): code_imports( self): url_data_ for_target( branch_ target) :
> + registrant, self, branch_name, rcs_type, url=url,
> + cvs_root=cvs_root, cvs_module=
> +
>
> class PackageBranchTa
> implements(
> @@ -95,6 +102,11 @@
> """See `IBranchTarget`."""
> return True
>
> + @property
> + def supports_
> + """See `IBranchTarget`."""
> + return False
> +
> def areBranchesMerg
> """See `IBranchTarget`."""
> # Branches are mergable into a PackageTarget if the source package
> @@ -182,6 +194,11 @@
> """See `IBranchTarget`."""
> return False
>
> + @property
> + def supports_
> + """See `IBranchTarget`."""
> + return False
> +
> def areBranchesMerg
> """See `IBranchTarget`."""
> return False
> @@ -258,6 +275,11 @@
> """See `IBranchTarget`."""
> return True
>
> + @property
> + def supports_
> + """See `IBranchTarget`."""
> + return True
> +
> def areBranchesMerg
> """See `IBranchTarget`."""
> # Branches are mergable into a PackageTarget if the source package
> @@ -311,6 +333,11 @@
> """See `IBranchTarget`."""
> return self.productseries
>
> + @property
> + def supports_
> + """See `IBranchTarget`."""
> + return False
> +
>
> def get_canonical_
> """Return the `ICanonicalUrlData` for an `IBranchTarget`."""
> === modified file 'lib/lp/ code/model/ codeimport. py' code/model/ codeimport. py 2010-03-26 01:44:52 +0000 code/model/ codeimport. py 2010-03-26 01:45:34 +0000 wStatus. REVIEWED wStatus. NEW supports_ code_imports: getNamespace( registrant) createBranch(
> --- lib/lp/
> +++ lib/lp/
> @@ -225,6 +225,8 @@
> review_status = CodeImportRevie
> else:
> review_status = CodeImportRevie
> + if not target.
> + raise AssertionError("%r doesn't support code imports" % target)
> # Create the branch for the CodeImport.
> namespace = target.
> import_branch = namespace.
I think raising AssertionError here is OK.