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+ )
310from git .objects .util import Traversable
411from 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+ )
617from git .config import SectionConstraint
7- from git .exc import InvalidGitRepositoryError , NoSuchPathError
18+ from git .exc import (
19+ InvalidGitRepositoryError ,
20+ NoSuchPathError
21+ )
822import stat
923import git
1024
1327
1428import 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.
0 commit comments