Skip to content

Commit 9519f18

Browse files
committed
Fixed all imports, refactoring appears to be complete
1 parent 4c34d5c commit 9519f18

File tree

6 files changed

+45
-14
lines changed

6 files changed

+45
-14
lines changed

Diff for: lib/git/objects/__init__.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
"""
44
import inspect
55
from base import *
6+
# Fix import dependency - add IndexObject to the util module, so that it can be
7+
# imported by the submodule.base
8+
import submodule.util
9+
submodule.util.IndexObject = IndexObject
10+
from submodule.base import *
11+
from submodule.root import *
12+
13+
# must come after submodule was made available
614
from tag import *
715
from blob import *
8-
from tree import *
916
from commit import *
10-
from submodule import *
17+
from tree import *
1118
from util import Actor
1219

1320
__all__ = [ name for name, obj in locals().items()

Diff for: lib/git/objects/submodule/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11

2-
from base import *
3-
from root import *

Diff for: lib/git/objects/submodule/base.py

+29-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
import git.objects.base
2-
from util import *
1+
import util
2+
from util import (
3+
mkhead,
4+
sm_name,
5+
sm_section,
6+
unbare_repo,
7+
SubmoduleConfigParser,
8+
find_first_remote_branch
9+
)
310
from git.objects.util import Traversable
411
from StringIO import StringIO # need a dict to set bloody .name field
5-
from git.util import Iterable, join_path_native, to_native_path_linux
12+
from git.util import (
13+
Iterable,
14+
join_path_native,
15+
to_native_path_linux
16+
)
617
from git.config import SectionConstraint
7-
from git.exc import InvalidGitRepositoryError, NoSuchPathError
18+
from git.exc import (
19+
InvalidGitRepositoryError,
20+
NoSuchPathError
21+
)
822
import stat
923
import git
1024

@@ -13,11 +27,13 @@
1327

1428
import shutil
1529

16-
__all__ = ("Submodule", "RootModule")
30+
__all__ = ["Submodule"]
1731

1832

19-
20-
class Submodule(git.objects.base.IndexObject, Iterable, Traversable):
33+
# IndexObject comes via util module, its a 'hacky' fix thanks to pythons import
34+
# mechanism which cause plenty of trouble of the only reason for packages and
35+
# modules is refactoring - subpackages shoudn't depend on parent packages
36+
class Submodule(util.IndexObject, Iterable, Traversable):
2137
"""Implements access to a git submodule. They are special in that their sha
2238
represents a commit in the submodule's repository which is to be checked out
2339
at the path of this instance.
@@ -41,6 +57,7 @@ class Submodule(git.objects.base.IndexObject, Iterable, Traversable):
4157
def __init__(self, repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, branch=None):
4258
"""Initialize this instance with its attributes. We only document the ones
4359
that differ from ``IndexObject``
60+
4461
:param repo: Our parent repository
4562
:param binsha: binary sha referring to a commit in the remote repository, see url parameter
4663
:param parent_commit: see set_parent_commit()
@@ -163,6 +180,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
163180
as well as the .gitmodules file, but will not create a new commit.
164181
If the submodule already exists, no matter if the configuration differs
165182
from the one provided, the existing submodule will be returned.
183+
166184
:param repo: Repository instance which should receive the submodule
167185
:param name: The name/identifier for the submodule
168186
:param path: repository-relative or absolute path at which the submodule
@@ -260,6 +278,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
260278
def update(self, recursive=False, init=True, to_latest_revision=False):
261279
"""Update the repository of this submodule to point to the checkout
262280
we point at with the binsha of this instance.
281+
263282
:param recursive: if True, we will operate recursively and update child-
264283
modules as well.
265284
:param init: if True, the module repository will be cloned into place if necessary
@@ -382,6 +401,7 @@ def move(self, module_path, configuration=True, module=True):
382401
"""Move the submodule to a another module path. This involves physically moving
383402
the repository at our current path, changing the configuration, as well as
384403
adjusting our index entry accordingly.
404+
385405
:param module_path: the path to which to move our module, given as
386406
repository-relative path. Intermediate directories will be created
387407
accordingly. If the path already exists, it must be empty.
@@ -484,6 +504,7 @@ def move(self, module_path, configuration=True, module=True):
484504
def remove(self, module=True, force=False, configuration=True, dry_run=False):
485505
"""Remove this submodule from the repository. This will remove our entry
486506
from the .gitmodules file and the entry in the .git/config file.
507+
487508
:param module: If True, the module we point to will be deleted
488509
as well. If the module is currently on a commit which is not part
489510
of any branch in the remote, if the currently checked out branch
@@ -588,6 +609,7 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False):
588609
def set_parent_commit(self, commit, check=True):
589610
"""Set this instance to use the given commit whose tree is supposed to
590611
contain the .gitmodules blob.
612+
591613
:param commit: Commit'ish reference pointing at the root_tree
592614
:param check: if True, relatively expensive checks will be performed to verify
593615
validity of the submodule.

Diff for: lib/git/objects/submodule/root.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
from base import Submodule
2+
from util import (
3+
mkhead,
4+
find_first_remote_branch
5+
)
26
from git.exc import InvalidGitRepositoryError
37
import git
48

Diff for: lib/git/objects/tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from base import IndexObject
88
from git.util import join_path
99
from blob import Blob
10-
from submodule import Submodule
10+
from submodule.base import Submodule
1111
import git.diff as diff
1212

1313
from fun import (

Diff for: test/git/test_submodule.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

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

318-
319319
@with_rw_repo(k_subm_current)
320320
def test_base_rw(self, rwrepo):
321321
self._do_base_tests(rwrepo)

0 commit comments

Comments
 (0)