Ejemplo n.º 1
0
 def test_commit_dropped_patches(self):
     """Test if we commit the patch-queue branch with all patches dropped"""
     repo = self.repo
     start = repo.get_branch()
     pq_branch = os.path.join('patch-queue', start)
     opts = TestExport.Options()
     opts.commit = True
     patch_dir = os.path.join(repo.path, 'debian/patches')
     os.makedirs(patch_dir)
     with open(os.path.join(patch_dir, 'series'), 'w') as f:
         f.write("patch1.diff\n")
         f.write("patch2.diff\n")
     repo.add_files('debian/patches')
     repo.commit_all('Add series file')
     repo.create_branch(pq.pq_branch_name('master'))
     switch_pq(repo, start, opts)
     self.assertEqual(len(repo.get_commits()), 2)
     self.assertEqual(repo.get_branch(), pq_branch)
     export_patches(repo, pq_branch, opts)
     self.assertEqual(repo.get_branch(), start)
     self.assertTrue(repo.has_branch(pq_branch))
     self.assertEqual(len(repo.get_commits()), 3,
                      "Export did not create commit")
     self.assertIn(b"Drop patch1.diff:", repo.show('HEAD'))
     self.assertIn(b"Drop patch2.diff:", repo.show('HEAD'))
Ejemplo n.º 2
0
    def test_empty(self):

        import_quilt_patches(self.repo,
                             branch=self.repo.get_branch(),
                             series=SERIES_FILE,
                             tries=1,
                             force=TestFromTAG.Options.force,
                             pq_from=TestFromTAG.Options.pq_from,
                             upstream_tag=TestFromTAG.Options.upstream_tag)
        diff = self.repo.diff(self.repo.get_branch(), 'upstream/0.0.1')
        self.assertEqual('', diff)
        diff = self.repo.diff(self.repo.get_branch(), 'master')
        self.assertNotEqual('', diff)

        rebase_pq(self.repo,
                  branch=self.repo.get_branch(),
                  pq_from=TestFromTAG.Options.pq_from,
                  upstream_tag=TestFromTAG.Options.upstream_tag)
        diff = self.repo.diff(self.repo.get_branch(), 'upstream/0.0.1')
        self.assertEqual('', diff)
        diff = self.repo.diff(self.repo.get_branch(), 'master')
        self.assertNotEqual('', diff)

        export_patches(self.repo,
                       branch=self.repo.get_branch(),
                       options=TestFromTAG.Options())
        diff = self.repo.diff(self.repo.get_branch(), self.repo.head)
        self.assertEqual('', diff)
Ejemplo n.º 3
0
    def test_empty(self):

        import_quilt_patches(self.repo,
                             branch=self.repo.get_branch(),
                             series=SERIES_FILE,
                             tries=1,
                             force=TestFromTAG.Options.force,
                             pq_from=TestFromTAG.Options.pq_from,
                             upstream_tag=TestFromTAG.Options.upstream_tag)
        diff = self.repo.diff(self.repo.get_branch(), 'upstream/0.0.1')
        self.assertEqual(b'', diff)
        diff = self.repo.diff(self.repo.get_branch(), 'master')
        self.assertNotEqual(b'', diff)

        rebase_pq(self.repo,
                  branch=self.repo.get_branch(),
                  options=TestFromTAG.Options)
        diff = self.repo.diff(self.repo.get_branch(), 'upstream/0.0.1')
        self.assertEqual(b'', diff)
        diff = self.repo.diff(self.repo.get_branch(), 'master')
        self.assertNotEqual(b'', diff)

        export_patches(self.repo,
                       branch=self.repo.get_branch(),
                       options=TestFromTAG.Options())
        diff = self.repo.diff(self.repo.get_branch(), self.repo.head)
        self.assertEqual(b'', diff)
Ejemplo n.º 4
0
 def test_commit_dropped_patches(self):
     """Test if we commit the patch-queue branch with all patches dropped"""
     repo = self.repo
     start = repo.get_branch()
     pq_branch = os.path.join('patch-queue', start)
     opts = TestExport.Options()
     opts.commit = True
     patch_dir = os.path.join(repo.path, 'debian/patches')
     os.makedirs(patch_dir)
     with open(os.path.join(patch_dir, 'series'), 'w') as f:
         f.write("patch1.diff\n")
         f.write("patch2.diff\n")
     repo.add_files('debian/patches')
     repo.commit_all('Add series file')
     repo.create_branch(pq.pq_branch_name('master'))
     switch_pq(repo, start, opts)
     self.assertEqual(len(repo.get_commits()), 2)
     self.assertEqual(repo.get_branch(), pq_branch)
     export_patches(repo, pq_branch, opts)
     self.assertEqual(repo.get_branch(), start)
     self.assertTrue(repo.has_branch(pq_branch))
     self.assertEqual(len(repo.get_commits()), 3,
                      "Export did not create commit")
     self.assertIn(b"Drop patch1.diff:", repo.show('HEAD'))
     self.assertIn(b"Drop patch2.diff:", repo.show('HEAD'))
Ejemplo n.º 5
0
 def test_drop(self):
     """Test if we drop the patch-queue branch with --drop"""
     repo = self.repo
     start = repo.get_branch()
     pq_branch = os.path.join('patch-queue', start)
     pq.switch_pq(repo, start)
     self.assertEqual(repo.get_branch(), pq_branch)
     export_patches(repo, pq_branch, TestExport.Options)
     self.assertEqual(repo.get_branch(), start)
     self.assertFalse(repo.has_branch(pq_branch))
Ejemplo n.º 6
0
    def test_drop(self):
        """Test if we drop the patch-queue branch with --drop"""
        repo = self.repo
        start = repo.get_branch()
        pq_branch = os.path.join('patch-queue', start)
        opts = TestExport.Options()
        opts.drop = True

        repo.create_branch(pq.pq_branch_name('master'))
        switch_pq(repo, start, opts)
        self.assertEqual(repo.get_branch(), pq_branch)
        export_patches(repo, pq_branch, opts)
        self.assertEqual(repo.get_branch(), start)
        self.assertFalse(repo.has_branch(pq_branch))
Ejemplo n.º 7
0
    def test_drop(self):
        """Test if we drop the patch-queue branch with --drop"""
        repo = self.repo
        start = repo.get_branch()
        pq_branch = os.path.join('patch-queue', start)
        opts = TestExport.Options()
        opts.drop = True

        repo.create_branch(pq.pq_branch_name('master'))
        switch_pq(repo, start, opts)
        self.assertEqual(repo.get_branch(), pq_branch)
        export_patches(repo, pq_branch, opts)
        self.assertEqual(repo.get_branch(), start)
        self.assertFalse(repo.has_branch(pq_branch))
Ejemplo n.º 8
0
 def test_commit(self):
     """Test if we commit the patch-queue branch with --commit"""
     repo = self.repo
     start = repo.get_branch()
     pq_branch = os.path.join('patch-queue', start)
     opts = TestExport.Options()
     opts.commit = True
     pq.switch_pq(repo, start)
     self.assertEqual(len(repo.get_commits()), 1)
     self.assertEqual(repo.get_branch(), pq_branch)
     self.add_file('foo', 'foo')
     export_patches(repo, pq_branch, opts)
     self.assertEqual(repo.get_branch(), start)
     self.assertTrue(repo.has_branch(pq_branch))
     self.assertEqual(len(repo.get_commits()), 2,
                      "Export did not create commit")
     export_patches(repo, pq_branch, opts)
     self.assertEqual(repo.get_branch(), start)
     self.assertEqual(len(repo.get_commits()), 2,
                      "Export must not create another commit")
Ejemplo n.º 9
0
 def test_commit(self):
     """Test if we commit the patch-queue branch with --commit"""
     repo = self.repo
     start = repo.get_branch()
     pq_branch = os.path.join('patch-queue', start)
     opts = TestExport.Options()
     opts.commit = True
     pq.switch_pq(repo, start)
     self.assertEqual(len(repo.get_commits()), 1)
     self.assertEqual(repo.get_branch(), pq_branch)
     self.add_file('foo', 'foo')
     export_patches(repo, pq_branch, opts)
     self.assertEqual(repo.get_branch(), start)
     self.assertTrue(repo.has_branch(pq_branch))
     self.assertEqual(len(repo.get_commits()), 2,
                      "Export did not create commit")
     export_patches(repo, pq_branch, opts)
     self.assertEqual(repo.get_branch(), start)
     self.assertEqual(len(repo.get_commits()), 2,
                      "Export must not create another commit")
Ejemplo n.º 10
0
 def test_adding_patch(self):
     import_quilt_patches(self.repo,
                          branch=self.repo.get_branch(),
                          series=SERIES_FILE,
                          tries=1,
                          force=TestFromTAG.Options.force,
                          pq_from=TestFromTAG.Options.pq_from,
                          upstream_tag=TestFromTAG.Options.upstream_tag)
     self.add_file('bar', 'bar', 'added bar')
     export_patches(self.repo,
                    branch=self.repo.get_branch(),
                    options=TestFromTAG.Options())
     self.assertTrue(
         os.path.exists(
             os.path.join(self.repo.path, os.path.dirname(SERIES_FILE),
                          'added-bar.patch')))
     pq.switch_pq(self.repo, 'master')
     rebase_pq(self.repo,
               branch=self.repo.get_branch(),
               pq_from=TestFromTAG.Options.pq_from,
               upstream_tag=TestFromTAG.Options.upstream_tag)
     export_patches(self.repo,
                    branch=self.repo.get_branch(),
                    options=TestFromTAG.Options())
     self.assertTrue(
         os.path.exists(
             os.path.join(self.repo.path, os.path.dirname(SERIES_FILE),
                          'added-bar.patch')))
     # New upstream release
     self.repo.set_branch('bar')
     GitCommand('cherry-pick', cwd=self.repo.path)(['patch-queue/master'])
     self.repo.create_tag('upstream/0.0.2')
     self.repo.set_branch('master')
     self.add_file(
         'debian/changelog', 'foo (0.0.2-1) UNRELEASED; urgency=medium\n'
         '\n'
         '  * Initial foo\n'
         '\n'
         ' -- Mr. T. S. <*****@*****.**>  '
         'Thu, 01 Jan 1970 00:00:00 +0000\n')
     pq.switch_pq(self.repo, 'master')
     rebase_pq(self.repo,
               branch=self.repo.get_branch(),
               pq_from=TestFromTAG.Options.pq_from,
               upstream_tag=TestFromTAG.Options.upstream_tag)
     export_patches(self.repo,
                    branch=self.repo.get_branch(),
                    options=TestFromTAG.Options())
     self.assertFalse(
         os.path.exists(
             os.path.join(self.repo.path, os.path.dirname(SERIES_FILE),
                          'added-bar.patch')))
Ejemplo n.º 11
0
 def test_adding_patch(self):
     import_quilt_patches(self.repo,
                          branch=self.repo.get_branch(),
                          series=SERIES_FILE,
                          tries=1,
                          force=TestFromTAG.Options.force,
                          pq_from=TestFromTAG.Options.pq_from,
                          upstream_tag=TestFromTAG.Options.upstream_tag)
     self.add_file('bar', 'bar', 'added bar')
     export_patches(self.repo,
                    branch=self.repo.get_branch(),
                    options=TestFromTAG.Options())
     self.assertTrue(os.path.exists(os.path.join(self.repo.path,
                                                 os.path.dirname(SERIES_FILE),
                                                 'added-bar.patch')))
     rebase_pq(self.repo,
               branch=self.repo.get_branch(),
               pq_from=TestFromTAG.Options.pq_from,
               upstream_tag=TestFromTAG.Options.upstream_tag)
     export_patches(self.repo,
                    branch=self.repo.get_branch(),
                    options=TestFromTAG.Options())
     self.assertTrue(os.path.exists(os.path.join(self.repo.path,
                                                 os.path.dirname(SERIES_FILE),
                                                 'added-bar.patch')))
     # New upstream release
     self.repo.set_branch('bar')
     GitCommand('cherry-pick', cwd=self.repo.path)(['patch-queue/master'])
     self.repo.create_tag('upstream/0.0.2')
     self.repo.set_branch('master')
     self.add_file(
         'debian/changelog',
         'foo (0.0.2-1) UNRELEASED; urgency=medium\n'
         '\n'
         '  * Initial foo\n'
         '\n'
         ' -- Mr. T. S. <*****@*****.**>  '
         'Thu, 01 Jan 1970 00:00:00 +0000\n'
     )
     rebase_pq(self.repo,
               branch=self.repo.get_branch(),
               pq_from=TestFromTAG.Options.pq_from,
               upstream_tag=TestFromTAG.Options.upstream_tag)
     export_patches(self.repo,
                    branch=self.repo.get_branch(),
                    options=TestFromTAG.Options())
     self.assertFalse(os.path.exists(os.path.join(self.repo.path,
                                                  os.path.dirname(SERIES_FILE),
                                                  'added-bar.patch')))