Skip to content

Commit

Permalink
Fixed all imports, refactoring appears to be complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 18, 2010
1 parent 4c34d5c commit 9519f18
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
11 changes: 9 additions & 2 deletions lib/git/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
"""
import inspect
from base import *
# Fix import dependency - add IndexObject to the util module, so that it can be
# imported by the submodule.base
import submodule.util
submodule.util.IndexObject = IndexObject
from submodule.base import *
from submodule.root import *

# must come after submodule was made available
from tag import *
from blob import *
from tree import *
from commit import *
from submodule import *
from tree import *
from util import Actor

__all__ = [ name for name, obj in locals().items()
Expand Down
2 changes: 0 additions & 2 deletions lib/git/objects/submodule/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@

from base import *
from root import *
36 changes: 29 additions & 7 deletions lib/git/objects/submodule/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import git.objects.base
from util import *
import util
from util import (
mkhead,
sm_name,
sm_section,
unbare_repo,
SubmoduleConfigParser,
find_first_remote_branch
)
from git.objects.util import Traversable
from StringIO import StringIO # need a dict to set bloody .name field
from git.util import Iterable, join_path_native, to_native_path_linux
from git.util import (
Iterable,
join_path_native,
to_native_path_linux
)
from git.config import SectionConstraint
from git.exc import InvalidGitRepositoryError, NoSuchPathError
from git.exc import (
InvalidGitRepositoryError,
NoSuchPathError
)
import stat
import git

Expand All @@ -13,11 +27,13 @@

import shutil

__all__ = ("Submodule", "RootModule")
__all__ = ["Submodule"]



class Submodule(git.objects.base.IndexObject, Iterable, Traversable):
# IndexObject comes via util module, its a 'hacky' fix thanks to pythons import
# mechanism which cause plenty of trouble of the only reason for packages and
# modules is refactoring - subpackages shoudn't depend on parent packages
class Submodule(util.IndexObject, Iterable, Traversable):
"""Implements access to a git submodule. They are special in that their sha
represents a commit in the submodule's repository which is to be checked out
at the path of this instance.
Expand All @@ -41,6 +57,7 @@ class Submodule(git.objects.base.IndexObject, Iterable, Traversable):
def __init__(self, repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, branch=None):
"""Initialize this instance with its attributes. We only document the ones
that differ from ``IndexObject``
:param repo: Our parent repository
:param binsha: binary sha referring to a commit in the remote repository, see url parameter
:param parent_commit: see set_parent_commit()
Expand Down Expand Up @@ -163,6 +180,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
as well as the .gitmodules file, but will not create a new commit.
If the submodule already exists, no matter if the configuration differs
from the one provided, the existing submodule will be returned.
:param repo: Repository instance which should receive the submodule
:param name: The name/identifier for the submodule
:param path: repository-relative or absolute path at which the submodule
Expand Down Expand Up @@ -260,6 +278,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
def update(self, recursive=False, init=True, to_latest_revision=False):
"""Update the repository of this submodule to point to the checkout
we point at with the binsha of this instance.
:param recursive: if True, we will operate recursively and update child-
modules as well.
:param init: if True, the module repository will be cloned into place if necessary
Expand Down Expand Up @@ -382,6 +401,7 @@ def move(self, module_path, configuration=True, module=True):
"""Move the submodule to a another module path. This involves physically moving
the repository at our current path, changing the configuration, as well as
adjusting our index entry accordingly.
:param module_path: the path to which to move our module, given as
repository-relative path. Intermediate directories will be created
accordingly. If the path already exists, it must be empty.
Expand Down Expand Up @@ -484,6 +504,7 @@ def move(self, module_path, configuration=True, module=True):
def remove(self, module=True, force=False, configuration=True, dry_run=False):
"""Remove this submodule from the repository. This will remove our entry
from the .gitmodules file and the entry in the .git/config file.
:param module: If True, the module we point to will be deleted
as well. If the module is currently on a commit which is not part
of any branch in the remote, if the currently checked out branch
Expand Down Expand Up @@ -588,6 +609,7 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False):
def set_parent_commit(self, commit, check=True):
"""Set this instance to use the given commit whose tree is supposed to
contain the .gitmodules blob.
:param commit: Commit'ish reference pointing at the root_tree
:param check: if True, relatively expensive checks will be performed to verify
validity of the submodule.
Expand Down
4 changes: 4 additions & 0 deletions lib/git/objects/submodule/root.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from base import Submodule
from util import (
mkhead,
find_first_remote_branch
)
from git.exc import InvalidGitRepositoryError
import git

Expand Down
2 changes: 1 addition & 1 deletion lib/git/objects/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from base import IndexObject
from git.util import join_path
from blob import Blob
from submodule import Submodule
from submodule.base import Submodule
import git.diff as diff

from fun import (
Expand Down
4 changes: 2 additions & 2 deletions test/git/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from test.testlib import *
from git.exc import *
from git.objects.submodule import *
from git.objects.submodule.base import Submodule
from git.objects.submodule.root import RootModule
from git.util import to_native_path_linux, join_path_native
import shutil
import git
Expand Down Expand Up @@ -315,7 +316,6 @@ def _do_base_tests(self, rwrepo):
# Error if there is no submodule file here
self.failUnlessRaises(IOError, Submodule._config_parser, rwrepo, rwrepo.commit(self.k_no_subm_tag), True)


@with_rw_repo(k_subm_current)
def test_base_rw(self, rwrepo):
self._do_base_tests(rwrepo)
Expand Down

0 comments on commit 9519f18

Please sign in to comment.