← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/codeimport-list-git into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/codeimport-list-git into lp:launchpad with lp:~cjwatson/launchpad/codeimport-git-read-only-views as a prerequisite.

Commit message:
Extend CodeImportSet:+index to support different target types.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1469459 in Launchpad itself: "import external code into a LP git repo (natively)"
  https://bugs.launchpad.net/launchpad/+bug/1469459

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/codeimport-list-git/+merge/308387
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/codeimport-list-git into lp:launchpad.
=== modified file 'lib/lp/code/browser/codeimport.py'
--- lib/lp/code/browser/codeimport.py	2016-10-13 14:25:08 +0000
+++ lib/lp/code/browser/codeimport.py	2016-10-13 14:25:09 +0000
@@ -123,12 +123,19 @@
         review_status_field = copy_field(
             ICodeImport['review_status'], required=False, default=None)
         self.review_status_widget = CustomWidgetFactory(DropdownWidgetWithAny)
-        setUpWidget(self, 'review_status',  review_status_field, IInputWidget)
+        setUpWidget(self, 'review_status', review_status_field, IInputWidget)
 
         rcs_type_field = copy_field(
             ICodeImport['rcs_type'], required=False, default=None)
         self.rcs_type_widget = CustomWidgetFactory(DropdownWidgetWithAny)
-        setUpWidget(self, 'rcs_type',  rcs_type_field, IInputWidget)
+        setUpWidget(self, 'rcs_type', rcs_type_field, IInputWidget)
+
+        target_rcs_type_field = copy_field(
+            ICodeImport['target_rcs_type'], required=False, default=None)
+        self.target_rcs_type_widget = CustomWidgetFactory(
+            DropdownWidgetWithAny)
+        setUpWidget(
+            self, 'target_rcs_type', target_rcs_type_field, IInputWidget)
 
         # status should be None if either (a) there were no query arguments
         # supplied, i.e. the user browsed directly to this page (this is when
@@ -138,13 +145,17 @@
         review_status = None
         if self.review_status_widget.hasValidInput():
             review_status = self.review_status_widget.getInputValue()
-        # Similar for 'type'
+        # Similar for 'rcs_type' and 'target_rcs_type'.
         rcs_type = None
         if self.rcs_type_widget.hasValidInput():
             rcs_type = self.rcs_type_widget.getInputValue()
+        target_rcs_type = None
+        if self.target_rcs_type_widget.hasValidInput():
+            target_rcs_type = self.target_rcs_type_widget.getInputValue()
 
         imports = self.context.search(
-            review_status=review_status, rcs_type=rcs_type)
+            review_status=review_status, rcs_type=rcs_type,
+            target_rcs_type=target_rcs_type)
 
         self.batchnav = BatchNavigator(imports, self.request)
 

=== modified file 'lib/lp/code/interfaces/codeimport.py'
--- lib/lp/code/interfaces/codeimport.py	2016-10-13 14:25:08 +0000
+++ lib/lp/code/interfaces/codeimport.py	2016-10-13 14:25:09 +0000
@@ -267,11 +267,14 @@
     def delete(id):
         """Delete a CodeImport given its id."""
 
-    def search(review_status=None, rcs_type=None):
+    def search(review_status=None, rcs_type=None, target_rcs_type=None):
         """Find the CodeImports of the given status and type.
 
         :param review_status: An entry from the `CodeImportReviewStatus`
             schema, or None, which signifies 'any status'.
         :param rcs_type: An entry from the `RevisionControlSystems`
             schema, or None, which signifies 'any type'.
+        :param target_rcs_type: An entry from the
+            `TargetRevisionControlSystems` schema, or None, which signifies
+            'any type'.
         """

=== modified file 'lib/lp/code/model/codeimport.py'
--- lib/lp/code/model/codeimport.py	2016-10-13 14:25:08 +0000
+++ lib/lp/code/model/codeimport.py	2016-10-13 14:25:09 +0000
@@ -364,11 +364,15 @@
     def getByGitRepository(self, repository):
         return CodeImport.selectOneBy(git_repository=repository)
 
-    def search(self, review_status=None, rcs_type=None):
+    def search(self, review_status=None, rcs_type=None, target_rcs_type=None):
         """See `ICodeImportSet`."""
         clauses = []
         if review_status is not None:
             clauses.append(CodeImport.review_status == review_status)
         if rcs_type is not None:
             clauses.append(CodeImport.rcs_type == rcs_type)
+        if target_rcs_type == TargetRevisionControlSystems.BZR:
+            clauses.append(CodeImport.branch != None)
+        elif target_rcs_type == TargetRevisionControlSystems.GIT:
+            clauses.append(CodeImport.git_repository != None)
         return IStore(CodeImport).find(CodeImport, *clauses)

=== modified file 'lib/lp/code/stories/codeimport/xx-codeimport-view.txt'
--- lib/lp/code/stories/codeimport/xx-codeimport-view.txt	2011-12-24 15:18:32 +0000
+++ lib/lp/code/stories/codeimport/xx-codeimport-view.txt	2016-10-13 14:25:09 +0000
@@ -1,10 +1,37 @@
 Code imports
 ============
 
-The code imports overview page is linked of the main code page.
+The sample data only contains imports that target Bazaar, but we'll create
+another couple that target Git as well before we start.
+
+    >>> from zope.component import getUtility
+    >>> from lp.code.enums import TargetRevisionControlSystems
+    >>> from lp.code.tests.helpers import GitHostingFixture
+    >>> from lp.registry.interfaces.person import IPersonSet
+    >>> from lp.registry.interfaces.product import IProductSet
+    >>> from lp.testing import login, logout
+
+    >>> login('test@xxxxxxxxxxxxx')
+    >>> name12 = getUtility(IPersonSet).getByName('name12')
+    >>> with GitHostingFixture():
+    ...     _ = factory.makeCodeImport(
+    ...         registrant=name12,
+    ...         context=getUtility(IProductSet).getByName('gnome-terminal'),
+    ...         branch_name=u'gnome-terminal',
+    ...         git_repo_url=u'git://git.gnome.org/gnome-terminal',
+    ...         target_rcs_type=TargetRevisionControlSystems.GIT)
+    ...     _ = factory.makeCodeImport(
+    ...         registrant=name12,
+    ...         context=getUtility(IProductSet).getByName('evolution'),
+    ...         branch_name=u'evolution',
+    ...         git_repo_url=u'https://git.gnome.org/browse/evolution',
+    ...         target_rcs_type=TargetRevisionControlSystems.GIT)
+    >>> logout()
+
+The code imports overview page is linked off the main code page.
 
     >>> browser.open('http://code.launchpad.dev')
-    >>> browser.getLink('1 imported branches').click()
+    >>> browser.getLink('3 imported branches').click()
     >>> print browser.title
     Code Imports
 
@@ -15,19 +42,21 @@
     Code Imports
 
 There are two CodeImports in the sample data and they both show up in
-the page:
+the page, as well as the two we created above:
 
     >>> table = find_tag_by_id(browser.contents, 'code-import-listing')
     >>> names = [extract_text(tr.td) for tr in table.tbody('tr')]
     >>> for name in names:
     ...     print name
-    gnome-terminal/import
-    evolution/import
+    ~vcs-imports/gnome-terminal/import
+    ~vcs-imports/evolution/import
+    ~name12/gnome-terminal/+git/gnome-terminal
+    ~name12/evolution/+git/evolution
 
 If we click on the code import's name, we go to the associated branch
 for that import:
 
-    >>> browser.getLink('gnome-terminal/import').click()
+    >>> browser.getLink('~vcs-imports/gnome-terminal/import').click()
     >>> browser.url
     'http://code.launchpad.dev/~vcs-imports/gnome-terminal/import'
 
@@ -35,12 +64,11 @@
 Filtering the code import list
 ==============================
 
-The code import listing is filterable, on review status and type.
-There are no invalid imports in the sample data, so if we filter just
-on them we'll see the "no imports found" message.  It is worth
-ensuring that the control for filtering on review status reads "Any"
-by default, as the code that ensures this is poking at Zope 3
-internals a bit.
+The code import listing is filterable, on review status, source type, and
+target type.  There are no invalid imports in the sample data, so if we
+filter just on them we'll see the "no imports found" message.  It is worth
+ensuring that the control for filtering on review status reads "Any" by
+default, as the code that ensures this is poking at Zope 3 internals a bit.
 
     >>> browser.open('http://code.launchpad.dev/+code-imports')
     >>> control = browser.getControl(name="field.review_status")
@@ -61,32 +89,47 @@
     >>> rows = [extract_text(tr) for tr in table('tr')]
     >>> for row in rows:
     ...     print row
-    Import                Created  Type               Location     Status
-    gnome-terminal/import 2007-... Subversion via ... http://sv... Reviewed
-    evolution/import      2007-... Concurrent Vers... :pserver:... Pending Review
+    Import                                     Created  Source type        Target type Location     Status
+    ~vcs-imports/gnome-terminal/import         2007-... Subversion via ... Bazaar      http://sv... Reviewed
+    ~vcs-imports/evolution/import              2007-... Concurrent Vers... Bazaar      :pserver:... Pending Review
+    ~name12/gnome-terminal/+git/gnome-terminal ...      Git                Git         git://git... Reviewed
+    ~name12/evolution/+git/evolution           ...      Git                Git         https://g... Reviewed
 
-We can also filter by type.
+We can also filter by source type.
 
     >>> control = browser.getControl(name="field.rcs_type")
     >>> control.displayValue
     ['Any']
-    >>> browser.getControl(name="field.rcs_type").displayValue = [
-    ...    "Concurrent Versions System"]
-    >>> browser.getControl(name="submit").click()
-    >>> table = find_tag_by_id(browser.contents, 'code-import-listing')
-    >>> rows = [extract_text(tr) for tr in table('tr')]
-    >>> for row in rows:
-    ...     print row
-    Import           Created  Type               Location     Status
-    evolution/import 2007-... Concurrent Vers... :pserver:... Pending Review
+    >>> control.displayValue = ["Concurrent Versions System"]
+    >>> browser.getControl(name="submit").click()
+    >>> table = find_tag_by_id(browser.contents, 'code-import-listing')
+    >>> rows = [extract_text(tr) for tr in table('tr')]
+    >>> for row in rows:
+    ...     print row
+    Import                        Created  Source type        Target type Location     Status
+    ~vcs-imports/evolution/import 2007-... Concurrent Vers... Bazaar      :pserver:... Pending Review
+
+... or by target type.
+
+    >>> browser.getControl(name="field.rcs_type").displayValue = ["Any"]
+    >>> control = browser.getControl(name="field.target_rcs_type")
+    >>> control.displayValue
+    ['Any']
+    >>> control.displayValue = ["Git"]
+    >>> browser.getControl(name="submit").click()
+    >>> table = find_tag_by_id(browser.contents, 'code-import-listing')
+    >>> rows = [extract_text(tr) for tr in table('tr')]
+    >>> for row in rows:
+    ...     print row
+    Import                                     Created  Source type        Target type Location     Status
+    ~name12/gnome-terminal/+git/gnome-terminal ...      Git                Git         git://git... Reviewed
+    ~name12/evolution/+git/evolution           ...      Git                Git         https://g... Reviewed
 
 If we create a lot of imports, the listing view will be batched.
 
-    >>> from lp.testing import login, logout
     >>> login('test@xxxxxxxxxxxxx')
     >>> for i in range(10):
     ...     new_import = factory.makeCodeImport()
-
     >>> logout()
 
     >>> browser.open('http://code.launchpad.dev/+code-imports')

=== modified file 'lib/lp/code/templates/codeimport-list.pt'
--- lib/lp/code/templates/codeimport-list.pt	2011-09-28 10:28:47 +0000
+++ lib/lp/code/templates/codeimport-list.pt	2016-10-13 14:25:09 +0000
@@ -19,6 +19,7 @@
       <option label="NEW">New</option>
       <option label="REVIEWED">Reviewed</option>
     </select>
+    from
     <select name="rcs_type" tal:replace="structure view/rcs_type_widget">
       <option label="">Any</option>
       <option label="BZR">Bazaar</option>
@@ -26,6 +27,12 @@
       <option label="BZR_SVN">Subversion</option>
       <option label="SVN">Subversion (legacy)</option>
     </select>
+    to
+    <select name="target_rcs_type" tal:replace="structure view/target_rcs_type_widget">
+      <option label="">Any</option>
+      <option label="BZR">Bazaar</option>
+      <option label="GIT">Git</option>
+    </select>
     <input type="submit" name="submit"/>
   </form>
 
@@ -45,7 +52,10 @@
             Created
           </th>
           <th>
-            Type
+            Source type
+          </th>
+          <th>
+            Target type
           </th>
           <th>
             Location
@@ -60,11 +70,9 @@
 
           <td>
             <a href="code-import"
-               tal:attributes="href codeimport/branch/fmt:url">
-              <span tal:replace="codeimport/branch/target/name">
+               tal:attributes="href codeimport/target/fmt:url">
+              <span tal:replace="codeimport/target/unique_name">
                 target-name
-              </span>/<span tal:replace="codeimport/branch/name">
-                branch-name
               </span>
             </a>
           </td>
@@ -77,6 +85,10 @@
             some type
           </td>
 
+          <td tal:content="codeimport/target_rcs_type/title">
+            some type
+          </td>
+
           <td tal:content="codeimport/getImportDetailsForDisplay">
             some details
           </td>


Follow ups