Example #1
0
    def export(self, basetemp):
        if not self.hasvcs:
            return Exported(self.hub, self.setupdir, self.setupdir)
        with self.rootpath.as_cwd():
            if self.cm_ui:
                files = check_manifest.get_vcs_files(self.cm_ui)
            else:
                files = check_manifest.get_vcs_files()
        newrepo = basetemp.join(self.rootpath.basename)
        for fn in files:
            source = self.rootpath.join(fn)
            if source.islink():
                dest = newrepo.join(fn)
                dest.dirpath().ensure(dir=1)
                dest.mksymlinkto(source.readlink(), absolute=True)
            elif source.isfile():
                dest = newrepo.join(fn)
                dest.dirpath().ensure(dir=1)
                source.copy(dest, mode=True)
        self.hub.debug("copied", len(files), "files to", newrepo)

        if self.hasvcs not in (".git", ".hg") or self.setupdir_only:
            self.hub.warn("not copying vcs repository metadata for",
                          self.hasvcs)
        else:
            srcrepo = self.rootpath.join(self.hasvcs)
            assert srcrepo.exists(), srcrepo
            destrepo = newrepo.join(self.hasvcs)
            self.rootpath.join(self.hasvcs).copy(destrepo, mode=True)
            self.hub.info("copied repo", srcrepo, "to", destrepo)
        self.hub.debug("%s-exported project to %s -> new CWD" %
                       (self.hasvcs, newrepo))
        setupdir_newrepo = newrepo.join(self.setupdir.relto(self.rootpath))
        return Exported(self.hub, setupdir_newrepo, self.setupdir)
Example #2
0
 def test_get_vcs_files_added_but_uncommitted(self):
     from check_manifest import get_vcs_files
     self._init_vcs()
     self._create_and_add_to_vcs(['a.txt', 'b/b.txt', 'b/c/d.txt'])
     self._create_files(['b/x.txt', 'd/d.txt', 'i.txt'])
     self.assertEqual(get_vcs_files(),
                      ['a.txt', 'b', 'b/b.txt', 'b/c', 'b/c/d.txt'])
Example #3
0
 def test_get_vcs_files_in_a_subdir(self):
     from check_manifest import get_vcs_files
     self._init_vcs()
     self._create_and_add_to_vcs(['a.txt', 'b/b.txt', 'b/c/d.txt'])
     self._commit()
     self._create_files(['b/x.txt', 'd/d.txt', 'i.txt'])
     os.chdir('b')
     self.assertEqual(get_vcs_files(), ['b.txt', 'c', 'c/d.txt'])
Example #4
0
 def test_get_vcs_files_nonascii_filenames(self):
     # This test will fail if your locale is incapable of expressing
     # "eacute".  UTF-8 or Latin-1 should work.
     from check_manifest import get_vcs_files
     self._init_vcs()
     # A spelling of u"\xe9.txt" that works on Python 3.2 too
     filename = b'\xc3\xa9.txt'.decode('UTF-8')
     self._create_and_add_to_vcs([filename])
     self.assertEqual(get_vcs_files(), [filename])
Example #5
0
 def test_get_vcs_files_nonascii_filenames(self):
     # This test will fail if your locale is incapable of expressing
     # "eacute".  UTF-8 or Latin-1 should work.
     from check_manifest import get_vcs_files
     self._init_vcs()
     # A spelling of u"\xe9.txt" that works on Python 3.2 too
     filename = b'\xc3\xa9.txt'.decode('UTF-8')
     self._create_and_add_to_vcs([filename])
     self.assertEqual(get_vcs_files(), [filename])
Example #6
0
 def test_get_vcs_files_in_a_subdir(self):
     from check_manifest import get_vcs_files
     self._init_vcs()
     self._create_and_add_to_vcs(['a.txt', 'b/b.txt', 'b/c/d.txt'])
     self._commit()
     self._create_files(['b/x.txt', 'd/d.txt', 'i.txt'])
     os.chdir('b')
     j = os.path.join
     self.assertEqual(get_vcs_files(), ['b.txt', 'c', j('c', 'd.txt')])
Example #7
0
 def test_get_vcs_files_added_but_uncommitted(self):
     from check_manifest import get_vcs_files
     self._init_vcs()
     self._create_and_add_to_vcs(['a.txt', 'b/b.txt', 'b/c/d.txt'])
     self._create_files(['b/x.txt', 'd/d.txt', 'i.txt'])
     j = os.path.join
     self.assertEqual(get_vcs_files(),
                      ['a.txt', 'b', j('b', 'b.txt'), j('b', 'c'),
                       j('b', 'c', 'd.txt')])
Example #8
0
 def test_get_vcs_files_deleted_but_not_removed(self):
     if self.vcs.command == 'bzr':
         self.skipTest("this cosmetic feature is not supported with bzr")
         # see the longer explanation in test_missing_source_files
     from check_manifest import get_vcs_files
     self._init_vcs()
     self._create_and_add_to_vcs(['a.txt'])
     self._commit()
     os.unlink('a.txt')
     self.assertEqual(get_vcs_files(), ['a.txt'])
Example #9
0
 def test_get_vcs_files(self):
     from check_manifest import get_vcs_files
     self._init_vcs()
     self._create_and_add_to_vcs(['a.txt', 'b/b.txt', 'b/c/d.txt'])
     self._commit()
     self._create_files(['b/x.txt', 'd/d.txt', 'i.txt'])
     j = os.path.join
     self.assertEqual(get_vcs_files(),
                      ['a.txt', 'b', j('b', 'b.txt'), j('b', 'c'),
                       j('b', 'c', 'd.txt')])
Example #10
0
 def test_get_vcs_files_deleted_but_not_removed(self):
     if self.vcs.command == 'bzr':
         self.skipTest("this cosmetic feature is not supported with bzr")
         # see the longer explanation in test_missing_source_files
     from check_manifest import get_vcs_files
     self._init_vcs()
     self._create_and_add_to_vcs(['a.txt'])
     self._commit()
     os.unlink('a.txt')
     self.assertEqual(get_vcs_files(), ['a.txt'])
Example #11
0
 def test_svn_externals(self):
     from check_manifest import get_vcs_files
     self.vcs._run('svnadmin', 'create', 'repo2')
     repo2_url = 'file:///' + os.path.abspath('repo2').replace(os.path.sep, '/')
     self.vcs._init_vcs()
     self.vcs._run('svn', 'propset', 'svn:externals', 'ext %s' % repo2_url, '.')
     self.vcs._run('svn', 'up')
     self._create_files(['a.txt', 'ext/b.txt'])
     self.vcs._run('svn', 'add', 'a.txt', 'ext/b.txt')
     j = os.path.join
     self.assertEqual(get_vcs_files(),
                      ['a.txt', 'ext', j('ext', 'b.txt')])
Example #12
0
 def test_svn_externals(self):
     from check_manifest import get_vcs_files
     self.vcs._run('svnadmin', 'create', 'repo2')
     repo2_url = 'file:///' + os.path.abspath('repo2').replace(os.path.sep, '/')
     self.vcs._init_vcs()
     self.vcs._run('svn', 'propset', 'svn:externals', 'ext %s' % repo2_url, '.')
     self.vcs._run('svn', 'up')
     self._create_files(['a.txt', 'ext/b.txt'])
     self.vcs._run('svn', 'add', 'a.txt', 'ext/b.txt')
     j = os.path.join
     self.assertEqual(get_vcs_files(),
                      ['a.txt', 'ext', j('ext', 'b.txt')])