Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit15ee0ac

Browse files
committed
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
1 parent400d728 commit15ee0ac

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

‎lib/git/index.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def unmerged_blobs(self):
672672
Returns
673673
Iterator yielding dict(path : list( tuple( stage, Blob, ...))), being
674674
a dictionary associating a path in the index with a list containing
675-
stage/blob pairs
675+
sortedstage/blob pairs
676676
677677
Note:
678678
Blobs that have been removed in one side simply do not exist in the
@@ -684,7 +684,8 @@ def unmerged_blobs(self):
684684
forstage,blobinself.iter_blobs(is_unmerged_blob):
685685
path_map.setdefault(blob.path,list()).append((stage,blob))
686686
# END for each unmerged blob
687-
687+
forlinpath_map.itervalues():
688+
l.sort()
688689
returnpath_map
689690

690691
@classmethod
@@ -724,7 +725,7 @@ def resolve_blobs(self, iter_blobs):
724725
forblobiniter_blobs:
725726
stage_null_key= (blob.path,0)
726727
ifstage_null_keyinself.entries:
727-
raiseValueError("Blob %r already at stage 0"%blob )
728+
raiseValueError("Path %r alreadyexistsat stage 0"%blob.path )
728729
# END assert blob is not stage 0 already
729730

730731
# delete all possible stages

‎lib/git/repo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,9 @@ def init(cls, path=None, mkdir=True, **kwargs):
693693
ifmkdirandpathandnotos.path.exists(path):
694694
os.makedirs(path,0755)
695695

696+
# git command automatically chdir into the directory
696697
git=Git(path)
697-
output=git.init(path,**kwargs)
698+
output=git.init(**kwargs)
698699
returnRepo(path)
699700

700701
defclone(self,path,**kwargs):

‎test/git/test_repo.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
fromgitimport*
1010
fromgit.utilsimportjoin_path_native
1111
importtempfile
12+
importshutil
1213

1314
classTestRepo(TestBase):
1415

@@ -90,17 +91,33 @@ def test_trees(self):
9091
assertnum_trees==mc
9192

9293

93-
@patch_object(Repo,'__init__')
94-
@patch_object(Git,'_call_process')
95-
deftest_init(self,git,repo):
96-
git.return_value=True
97-
repo.return_value=None
98-
99-
r=Repo.init("repos/foo/bar.git",bare=True)
100-
assertisinstance(r,Repo)
101-
102-
assert_true(git.called)
103-
assert_true(repo.called)
94+
deftest_init(self):
95+
prev_cwd=os.getcwd()
96+
os.chdir(tempfile.gettempdir())
97+
git_dir_rela="repos/foo/bar.git"
98+
del_dir_abs=os.path.abspath("repos")
99+
git_dir_abs=os.path.abspath(git_dir_rela)
100+
try:
101+
# with specific path
102+
forpathin (git_dir_rela,git_dir_abs):
103+
r=Repo.init(path=path,bare=True)
104+
assertisinstance(r,Repo)
105+
assertr.bare==True
106+
assertos.path.isdir(r.git_dir)
107+
shutil.rmtree(git_dir_abs)
108+
# END for each path
109+
110+
os.makedirs(git_dir_rela)
111+
os.chdir(git_dir_rela)
112+
r=Repo.init(bare=False)
113+
r.bare==False
114+
finally:
115+
try:
116+
shutil.rmtree(del_dir_abs)
117+
exceptOSError:
118+
pass
119+
os.chdir(prev_cwd)
120+
# END restore previous state
104121

105122
deftest_bare_property(self):
106123
self.rorepo.bare

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp