diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-02-13 19:48:40 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-02-13 19:48:40 +0100 |
commit | 15ee0ac0d56a5fb5ba13fae4288621ddd2185f17 (patch) | |
tree | acdf245dfc10162680e16885f182f6b4a3c81b7e | |
parent | 400d728c99ddeae73c608e244bd301248b5467fc (diff) | |
download | gitpython-15ee0ac0d56a5fb5ba13fae4288621ddd2185f17.tar.gz |
IndexFile: unmerged_blobs lists are now sorted
Repo.init: fixed incorrect use of the path which was to optionally specify where to initialize the repository. Update test as well
-rw-r--r-- | lib/git/index.py | 7 | ||||
-rw-r--r-- | lib/git/repo.py | 3 | ||||
-rw-r--r-- | test/git/test_repo.py | 39 |
3 files changed, 34 insertions, 15 deletions
diff --git a/lib/git/index.py b/lib/git/index.py index df633ccd..96d42eaf 100644 --- a/lib/git/index.py +++ b/lib/git/index.py @@ -672,7 +672,7 @@ class IndexFile(LazyMixin, diff.Diffable): Returns Iterator yielding dict(path : list( tuple( stage, Blob, ...))), being a dictionary associating a path in the index with a list containing - stage/blob pairs + sorted stage/blob pairs Note: Blobs that have been removed in one side simply do not exist in the @@ -684,7 +684,8 @@ class IndexFile(LazyMixin, diff.Diffable): for stage, blob in self.iter_blobs(is_unmerged_blob): path_map.setdefault(blob.path, list()).append((stage, blob)) # END for each unmerged blob - + for l in path_map.itervalues(): + l.sort() return path_map @classmethod @@ -724,7 +725,7 @@ class IndexFile(LazyMixin, diff.Diffable): for blob in iter_blobs: stage_null_key = (blob.path, 0) if stage_null_key in self.entries: - raise ValueError( "Blob %r already at stage 0" % blob ) + raise ValueError( "Path %r already exists at stage 0" % blob.path ) # END assert blob is not stage 0 already # delete all possible stages diff --git a/lib/git/repo.py b/lib/git/repo.py index 25cc412e..0c8ac9e9 100644 --- a/lib/git/repo.py +++ b/lib/git/repo.py @@ -693,8 +693,9 @@ class Repo(object): if mkdir and path and not os.path.exists(path): os.makedirs(path, 0755) + # git command automatically chdir into the directory git = Git(path) - output = git.init(path, **kwargs) + output = git.init(**kwargs) return Repo(path) def clone(self, path, **kwargs): diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 0e913ff1..4af9161c 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -9,6 +9,7 @@ from test.testlib import * from git import * from git.utils import join_path_native import tempfile +import shutil class TestRepo(TestBase): @@ -90,17 +91,33 @@ class TestRepo(TestBase): assert num_trees == mc - @patch_object(Repo, '__init__') - @patch_object(Git, '_call_process') - def test_init(self, git, repo): - git.return_value = True - repo.return_value = None - - r = Repo.init("repos/foo/bar.git", bare=True) - assert isinstance(r, Repo) - - assert_true(git.called) - assert_true(repo.called) + def test_init(self): + prev_cwd = os.getcwd() + os.chdir(tempfile.gettempdir()) + git_dir_rela = "repos/foo/bar.git" + del_dir_abs = os.path.abspath("repos") + git_dir_abs = os.path.abspath(git_dir_rela) + try: + # with specific path + for path in (git_dir_rela, git_dir_abs): + r = Repo.init(path=path, bare=True) + assert isinstance(r, Repo) + assert r.bare == True + assert os.path.isdir(r.git_dir) + shutil.rmtree(git_dir_abs) + # END for each path + + os.makedirs(git_dir_rela) + os.chdir(git_dir_rela) + r = Repo.init(bare=False) + r.bare == False + finally: + try: + shutil.rmtree(del_dir_abs) + except OSError: + pass + os.chdir(prev_cwd) + # END restore previous state def test_bare_property(self): self.rorepo.bare |