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

Commit3203cd7

Browse files
committed
Fixed doc strings, improved error checking on RefLog.write method
1 parent98a3133 commit3203cd7

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

‎refs/log.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def entry_at(cls, filepath, index):
182182
specifiy an entry counted from the end of the list
183183
184184
:raise IndexError: If the entry didn't exist
185+
185186
.. note:: This method is faster as it only parses the entry at index, skipping
186187
all other lines. Nonetheless, the whole file has to be read if
187188
the index is negative
@@ -224,6 +225,7 @@ def to_file(self, filepath):
224225
@classmethod
225226
defappend_entry(cls,config_reader,filepath,oldbinsha,newbinsha,message):
226227
"""Append a new log entry to the revlog at filepath.
228+
227229
:param config_reader: configuration reader of the repository - used to obtain
228230
user information. May be None
229231
:param filepath: full path to the log file
@@ -255,8 +257,13 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
255257
returnentry
256258

257259
defwrite(self):
258-
"""Write this instance's data to the file we are originating from"""
259-
returnself.to_file(self._path)
260+
"""Write this instance's data to the file we are originating from
261+
:return: self"""
262+
ifself._pathisNone:
263+
raiseValueError("Instance was not initialized with a path, use to_file(...) instead")
264+
#END assert path
265+
self.to_file(self._path)
266+
returnself
260267

261268
#} END interface
262269

‎refs/symbolic.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def _get_commit(self):
174174

175175
defset_commit(self,commit,logmsg=None):
176176
"""As set_object, but restricts the type of object to be a Commit
177+
177178
:raise ValueError: If commit is not a Commit object or doesn't point to
178179
a commit
179180
:return: self"""
@@ -345,6 +346,7 @@ def log(self):
345346

346347
deflog_append(self,oldbinsha,message,newbinsha=None):
347348
"""Append a logentry to the logfile of this ref
349+
348350
:param oldbinsha: binary sha this ref used to point to
349351
:param message: A message describing the change
350352
:param newbinsha: The sha the ref points to now. If None, our current commit sha

‎test/test_reflog.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def test_base(self):
5656
self.failUnlessRaises(ValueError,RefLog.from_file,fixture_path(pp+suffix))
5757
#END for each invalid file
5858

59+
# cannot write an uninitialized reflog
60+
self.failUnlessRaises(ValueError,RefLog().write)
5961

6062
# test serialize and deserialize - results must match exactly
6163
binsha=chr(255)*20
@@ -65,6 +67,7 @@ def test_base(self):
6567
reflog=RefLog.from_file(rlp)
6668
tfile=os.path.join(tdir,os.path.basename(rlp))
6769
reflog.to_file(tfile)
70+
assertreflog.write()isreflog
6871

6972
# parsed result must match ...
7073
treflog=RefLog.from_file(tfile)

‎util.py‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ def to_native_path_linux(path):
6969
to_native_path=to_native_path_linux
7070

7171
defjoin_path_native(a,*p):
72-
"""As join path, but makes sure an OS native path is returned. This is only
73-
needed to play it safe on my dear windows and to assure nice paths that only
74-
use '\'"""
72+
"""
73+
As join path, but makes sure an OS native path is returned. This is only
74+
needed to play it safe on my dear windows and to assure nice paths that only
75+
use '\'"""
7576
returnto_native_path(join_path(a,*p))
7677

7778
defassure_directory_exists(path,is_file=False):
@@ -187,10 +188,11 @@ def _main_actor(cls, env_name, env_email, config_reader=None):
187188

188189
@classmethod
189190
defcommitter(cls,config_reader=None):
190-
""":return: Actor instance corresponding to the configured committer. It behaves
191-
similar to the git implementation, such that the environment will override
192-
configuration values of config_reader. If no value is set at all, it will be
193-
generated
191+
"""
192+
:return: Actor instance corresponding to the configured committer. It behaves
193+
similar to the git implementation, such that the environment will override
194+
configuration values of config_reader. If no value is set at all, it will be
195+
generated
194196
:param config_reader: ConfigReader to use to retrieve the values from in case
195197
they are not set in the environment"""
196198
returncls._main_actor(cls.env_committer_name,cls.env_committer_email,config_reader)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp