| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,18 @@ | |||
| 3 | 3 | """ | |
| 4 | 4 | import inspect | |
| 5 | 5 | 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 | ||
| 6 | 14 | from tag import * | |
| 7 | 15 | from blob import * | |
| 8 | - from tree import * | ||
| 9 | 16 | from commit import * | |
| 10 | - from submodule import * | ||
| 17 | + from tree import * | ||
| 11 | 18 | from util import Actor | |
| 12 | 19 | ||
| 13 | 20 | __all__ = [ name for name, obj in locals().items() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1 @@ | |||
| 1 | 1 | ||
| 2 | - from base import * | ||
| 3 | - from root import * | ||
| Original file line number | Diff line number | Diff 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 | + ) | ||
| 3 | 10 | from git.objects.util import Traversable | |
| 4 | 11 | 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 | + ) | ||
| 6 | 17 | from git.config import SectionConstraint | |
| 7 | - from git.exc import InvalidGitRepositoryError, NoSuchPathError | ||
| 18 | + from git.exc import ( | ||
| 19 | + InvalidGitRepositoryError, | ||
| 20 | + NoSuchPathError | ||
| 21 | + ) | ||
| 8 | 22 | import stat | |
| 9 | 23 | import git | |
| 10 | 24 | ||
@@ -13,11 +27,13 @@ | |||
| 13 | 27 | ||
| 14 | 28 | import shutil | |
| 15 | 29 | ||
| 16 | - __all__ = ("Submodule", "RootModule") | ||
| 30 | + __all__ = ["Submodule"] | ||
| 17 | 31 | ||
| 18 | 32 | ||
| 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): | ||
| 21 | 37 | """Implements access to a git submodule. They are special in that their sha | |
| 22 | 38 | represents a commit in the submodule's repository which is to be checked out | |
| 23 | 39 | at the path of this instance. | |
@@ -41,6 +57,7 @@ class Submodule(git.objects.base.IndexObject, Iterable, Traversable): | |||
| 41 | 57 | def __init__(self, repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, branch=None): | |
| 42 | 58 | """Initialize this instance with its attributes. We only document the ones | |
| 43 | 59 | that differ from ``IndexObject`` | |
| 60 | + | ||
| 44 | 61 | :param repo: Our parent repository | |
| 45 | 62 | :param binsha: binary sha referring to a commit in the remote repository, see url parameter | |
| 46 | 63 | :param parent_commit: see set_parent_commit() | |
@@ -163,6 +180,7 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False): | |||
| 163 | 180 | as well as the .gitmodules file, but will not create a new commit. | |
| 164 | 181 | If the submodule already exists, no matter if the configuration differs | |
| 165 | 182 | from the one provided, the existing submodule will be returned. | |
| 183 | + | ||
| 166 | 184 | :param repo: Repository instance which should receive the submodule | |
| 167 | 185 | :param name: The name/identifier for the submodule | |
| 168 | 186 | :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): | |||
| 260 | 278 | def update(self, recursive=False, init=True, to_latest_revision=False): | |
| 261 | 279 | """Update the repository of this submodule to point to the checkout | |
| 262 | 280 | we point at with the binsha of this instance. | |
| 281 | + | ||
| 263 | 282 | :param recursive: if True, we will operate recursively and update child- | |
| 264 | 283 | modules as well. | |
| 265 | 284 | :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): | |||
| 382 | 401 | """Move the submodule to a another module path. This involves physically moving | |
| 383 | 402 | the repository at our current path, changing the configuration, as well as | |
| 384 | 403 | adjusting our index entry accordingly. | |
| 404 | + | ||
| 385 | 405 | :param module_path: the path to which to move our module, given as | |
| 386 | 406 | repository-relative path. Intermediate directories will be created | |
| 387 | 407 | accordingly. If the path already exists, it must be empty. | |
@@ -484,6 +504,7 @@ def move(self, module_path, configuration=True, module=True): | |||
| 484 | 504 | def remove(self, module=True, force=False, configuration=True, dry_run=False): | |
| 485 | 505 | """Remove this submodule from the repository. This will remove our entry | |
| 486 | 506 | from the .gitmodules file and the entry in the .git/config file. | |
| 507 | + | ||
| 487 | 508 | :param module: If True, the module we point to will be deleted | |
| 488 | 509 | as well. If the module is currently on a commit which is not part | |
| 489 | 510 | 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): | |||
| 588 | 609 | def set_parent_commit(self, commit, check=True): | |
| 589 | 610 | """Set this instance to use the given commit whose tree is supposed to | |
| 590 | 611 | contain the .gitmodules blob. | |
| 612 | + | ||
| 591 | 613 | :param commit: Commit'ish reference pointing at the root_tree | |
| 592 | 614 | :param check: if True, relatively expensive checks will be performed to verify | |
| 593 | 615 | validity of the submodule. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,8 @@ | |||
| 1 | 1 | from base import Submodule | |
| 2 | + from util import ( | ||
| 3 | + mkhead, | ||
| 4 | + find_first_remote_branch | ||
| 5 | + ) | ||
| 2 | 6 | from git.exc import InvalidGitRepositoryError | |
| 3 | 7 | import git | |
| 4 | 8 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ | |||
| 7 | 7 | from base import IndexObject | |
| 8 | 8 | from git.util import join_path | |
| 9 | 9 | from blob import Blob | |
| 10 | - from submodule import Submodule | ||
| 10 | + from submodule.base import Submodule | ||
| 11 | 11 | import git.diff as diff | |
| 12 | 12 | ||
| 13 | 13 | from fun import ( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | 4 | from test.testlib import * | |
| 5 | 5 | 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 | ||
| 7 | 8 | from git.util import to_native_path_linux, join_path_native | |
| 8 | 9 | import shutil | |
| 9 | 10 | import git | |
@@ -315,7 +316,6 @@ def _do_base_tests(self, rwrepo): | |||
| 315 | 316 | # Error if there is no submodule file here | |
| 316 | 317 | self.failUnlessRaises(IOError, Submodule._config_parser, rwrepo, rwrepo.commit(self.k_no_subm_tag), True) | |
| 317 | 318 | ||
| 318 | - | ||
| 319 | 319 | @with_rw_repo(k_subm_current) | |
| 320 | 320 | def test_base_rw(self, rwrepo): | |
| 321 | 321 | self._do_base_tests(rwrepo) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments