Exemplo n.º 1
0
def _status(info):
    path = os.getcwd()
    if hasattr(info, 'package'):
        pkg = Package(path)
        for filename in sorted(os.listdir(path)):
            print "%s\t%s" % (pkg.status(filename), filename)
    else:
        prj = Project(path)
        for package in sorted(os.listdir(path)):
            print "%s\t%s" % (prj._status(package), package)
Exemplo n.º 2
0
    def package_obj(self, *args, **kwargs):
        """Returns a Package object if possible.

        *args and **kwargs are optional arguments for Package's
        __init__ method. If no Package can be returned None is
        returned.

        """
        if self.package_path is None or not wc_is_package(self.package_path):
            return None
        return Package(self.package_path, *args, **kwargs)
Exemplo n.º 3
0
 def test_package4(self):
     """test package convert (_project file missing)"""
     path = self.fixture_file('convert_2_inv_project')
     self.assertRaises(WCFormatVersionError, Package, path)
     self.assertRaises(WCInconsistentError,
                       Package,
                       path,
                       verify_format=False)
     self._not_exists(path, '_project', store=True)
     self.assertRaises(ValueError, convert_package, path)
     convert_package(path, project='foobar')
     pkg = Package(path)
     self.assertEqual(pkg.project, 'foobar')
     self._exists(path, '_project', store=True)
Exemplo n.º 4
0
def _update(info):
    path = os.getcwd()
    par_path = os.path.join(path, os.pardir)
    expand = ''
    if hasattr(info, 'expand'):
        expand = info.expand
    if hasattr(info, 'package') and not wc_is_project(par_path):
        pkg = Package(path, transaction_listner=[MyTransactionListener()])
        pkg.update(expand=expand)
    elif hasattr(info, 'package') and wc_is_project(par_path):
        prj = Project(par_path, transaction_listener=[MyTransactionListener()])
        prj.update(*[info.package], expand=expand)
    elif wc_is_project(path):
        prj = Project(path, transaction_listener=[MyTransactionListener()])
        prj.update(expand=expand)
Exemplo n.º 5
0
    def package(self, package, *args, **kwargs):
        """Return a Package object for package package.

        None is returned if package is missing (has state '!')
        or if package is untracked.

        *args and **kwargs are additional arguments for the
        Package's __init__ method.

        """
        path = os.path.join(self.path, package)
        st = self._status(package)
        if st in ('!', '?') or not wc_is_package(path):
            return None
        return Package(path, *args, **kwargs)
Exemplo n.º 6
0
 def test_package1(self):
     """test package convert (added package)"""
     path = self.fixture_file('convert_1')
     self.assertRaises(WCFormatVersionError, Package, path)
     self.assertRaises(WCInconsistentError,
                       Package,
                       path,
                       verify_format=False)
     convert_package(path)
     pkg = Package(path)
     self.assertEqual(pkg.files(), ['add'])
     self.assertEqual(pkg.status('add'), 'A')
     self._exists(path, 'data', store=True)
     self._exists(path, '_version', store=True)
     self._not_exists(path, '_osclib_version', store=True)
     self._not_exists(path, '_to_be_added', store=True)
Exemplo n.º 7
0
 def test_package3(self):
     """test package convert (deleted storefile missing)"""
     path = self.fixture_file('convert_2_inv')
     self.assertRaises(WCFormatVersionError, Package, path)
     self.assertRaises(WCInconsistentError,
                       Package,
                       path,
                       verify_format=False)
     convert_package(path)
     pkg = Package(path)
     self.assertEqual(pkg.files(), ['conflict', 'missing', 'deleted'])
     self.assertEqual(pkg.status('conflict'), 'C')
     self.assertEqual(pkg.status('missing'), '!')
     self.assertEqual(pkg.status('deleted'), 'D')
     self._exists(path, 'data', store=True)
     self._exists(path, '_version', store=True)
     self._not_exists(path, '_osclib_version', store=True)
Exemplo n.º 8
0
def _diff(info):
    path = os.getcwd()
    pkg = Package(path)
    ud = MyUnifiedDiff()
    pkg.diff(ud)
    ud.diff()