summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--refs/log.py11
-rw-r--r--refs/symbolic.py2
-rw-r--r--test/test_reflog.py3
-rw-r--r--util.py16
4 files changed, 23 insertions, 9 deletions
diff --git a/refs/log.py b/refs/log.py
index 6c734ad4..f49c07fd 100644
--- a/refs/log.py
+++ b/refs/log.py
@@ -182,6 +182,7 @@ class RefLog(list, Serializable):
specifiy an entry counted from the end of the list
:raise IndexError: If the entry didn't exist
+
.. note:: This method is faster as it only parses the entry at index, skipping
all other lines. Nonetheless, the whole file has to be read if
the index is negative
@@ -224,6 +225,7 @@ class RefLog(list, Serializable):
@classmethod
def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
"""Append a new log entry to the revlog at filepath.
+
:param config_reader: configuration reader of the repository - used to obtain
user information. May be None
:param filepath: full path to the log file
@@ -255,8 +257,13 @@ class RefLog(list, Serializable):
return entry
def write(self):
- """Write this instance's data to the file we are originating from"""
- return self.to_file(self._path)
+ """Write this instance's data to the file we are originating from
+ :return: self"""
+ if self._path is None:
+ raise ValueError("Instance was not initialized with a path, use to_file(...) instead")
+ #END assert path
+ self.to_file(self._path)
+ return self
#} END interface
diff --git a/refs/symbolic.py b/refs/symbolic.py
index 6ba8083f..9937cf0c 100644
--- a/refs/symbolic.py
+++ b/refs/symbolic.py
@@ -174,6 +174,7 @@ class SymbolicReference(object):
def set_commit(self, commit, logmsg = None):
"""As set_object, but restricts the type of object to be a Commit
+
:raise ValueError: If commit is not a Commit object or doesn't point to
a commit
:return: self"""
@@ -345,6 +346,7 @@ class SymbolicReference(object):
def log_append(self, oldbinsha, message, newbinsha=None):
"""Append a logentry to the logfile of this ref
+
:param oldbinsha: binary sha this ref used to point to
:param message: A message describing the change
:param newbinsha: The sha the ref points to now. If None, our current commit sha
diff --git a/test/test_reflog.py b/test/test_reflog.py
index 5c4a21b8..3fdf1fae 100644
--- a/test/test_reflog.py
+++ b/test/test_reflog.py
@@ -56,6 +56,8 @@ class TestRefLog(TestBase):
self.failUnlessRaises(ValueError, RefLog.from_file, fixture_path(pp+suffix))
#END for each invalid file
+ # cannot write an uninitialized reflog
+ self.failUnlessRaises(ValueError, RefLog().write)
# test serialize and deserialize - results must match exactly
binsha = chr(255)*20
@@ -65,6 +67,7 @@ class TestRefLog(TestBase):
reflog = RefLog.from_file(rlp)
tfile = os.path.join(tdir, os.path.basename(rlp))
reflog.to_file(tfile)
+ assert reflog.write() is reflog
# parsed result must match ...
treflog = RefLog.from_file(tfile)
diff --git a/util.py b/util.py
index c93ae715..42719233 100644
--- a/util.py
+++ b/util.py
@@ -69,9 +69,10 @@ else:
to_native_path = to_native_path_linux
def join_path_native(a, *p):
- """As join path, but makes sure an OS native path is returned. This is only
- needed to play it safe on my dear windows and to assure nice paths that only
- use '\'"""
+ """
+ As join path, but makes sure an OS native path is returned. This is only
+ needed to play it safe on my dear windows and to assure nice paths that only
+ use '\'"""
return to_native_path(join_path(a, *p))
def assure_directory_exists(path, is_file=False):
@@ -187,10 +188,11 @@ class Actor(object):
@classmethod
def committer(cls, config_reader=None):
- """:return: Actor instance corresponding to the configured committer. It behaves
- similar to the git implementation, such that the environment will override
- configuration values of config_reader. If no value is set at all, it will be
- generated
+ """
+ :return: Actor instance corresponding to the configured committer. It behaves
+ similar to the git implementation, such that the environment will override
+ configuration values of config_reader. If no value is set at all, it will be
+ generated
:param config_reader: ConfigReader to use to retrieve the values from in case
they are not set in the environment"""
return cls._main_actor(cls.env_committer_name, cls.env_committer_email, config_reader)