summaryrefslogtreecommitdiff
path: root/lib/git/repo.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-20 11:17:39 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-20 11:17:39 +0200
commit35a09c0534e89b2d43ec4101a5fb54576b577905 (patch)
treeb2f45485ba021a23e41285fef944f64407356dd9 /lib/git/repo.py
parent972a8b84bb4a3adec6322219c11370e48824404e (diff)
downloadgitpython-35a09c0534e89b2d43ec4101a5fb54576b577905.tar.gz
repo.alternates test cheked for correctness and bugfixed - totally mocked tests bare the risk that things do not work properly outside of the sandbox.
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r--lib/git/repo.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py
index 898b0f30..37847c98 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -394,21 +394,25 @@ class Repo(object):
Raises
NoSuchPathError
+ Note
+ The method does not check for the existance of the paths in alts
+ as the caller is responsible.
+
Returns
None
"""
- for alt in alts:
- if not os.path.exists(alt):
- raise NoSuchPathError("Could not set alternates. Alternate path %s must exist" % alt)
-
+ alternates_path = os.path.join(self.path, 'objects', 'info', 'alternates')
if not alts:
- os.remove(os.path.join(self.path, 'objects', 'info', 'alternates'))
+ if os.path.isfile(alternates_path):
+ os.remove(alternates_path)
else:
try:
- f = open(os.path.join(self.path, 'objects', 'info', 'alternates'), 'w')
+ f = open(alternates_path, 'w')
f.write("\n".join(alts))
finally:
f.close()
+ # END file handling
+ # END alts handling
alternates = property(_get_alternates, _set_alternates, doc="Retrieve a list of alternates paths or set a list paths to be used as alternates")