@@ -44,6 +44,7 @@ class RefLogEntry(Tuple[str, str, Actor, Tuple[int, int], str]):
4444 """Named tuple allowing easy access to the revlog data fields."""
4545
4646 _re_hexsha_only = re .compile (r"^[0-9A-Fa-f]{40}$" )
47+
4748 __slots__ = ()
4849
4950 def __repr__ (self ) -> str :
@@ -81,7 +82,7 @@ def actor(self) -> Actor:
8182
8283 @property
8384 def time (self ) -> Tuple [int , int ]:
84- """time as tuple:
85+ """Time as tuple:
8586
8687 * [0] = ``int(time)``
8788 * [1] = ``int(timezone_offset)`` in :attr:`time.altzone` format
@@ -113,9 +114,11 @@ def new(
113114 def from_line (cls , line : bytes ) -> "RefLogEntry" :
114115 """:return: New RefLogEntry instance from the given revlog line.
115116
116- :param line: Line bytes without trailing newline
117+ :param line:
118+ Line bytes without trailing newline
117119
118- :raise ValueError: If `line` could not be parsed
120+ :raise ValueError:
121+ If `line` could not be parsed.
119122 """
120123 line_str = line .decode (defenc )
121124 fields = line_str .split ("\t " , 1 )
@@ -147,9 +150,9 @@ def from_line(cls, line: bytes) -> "RefLogEntry":
147150
148151
149152class RefLog (List [RefLogEntry ], Serializable ):
150- """A reflog contains RefLogEntrys , each of which defines a certain state
151- of the head in question. Custom query methods allow to retrieve log entries
152- by date or by other criteria.
153+ R """A reflog contains :class:`RefLogEntry`\s , each of which defines a certain state
154+ of the head in question. Custom query methods allow to retrieve log entries by date
155+ or by other criteria.
153156
154157 Reflog entries are ordered. The first added entry is first in the list. The last
155158 entry, i.e. the last change of the head or reference, is last in the list.
@@ -163,8 +166,8 @@ def __new__(cls, filepath: Union[PathLike, None] = None) -> "RefLog":
163166
164167 def __init__ (self , filepath : Union [PathLike , None ] = None ):
165168 """Initialize this instance with an optional filepath, from which we will
166- initialize our data. The path is also used to write changes back using
167- the write() method."""
169+ initialize our data. The path is also used to write changes back using the
170+ :meth:` write` method."""
168171 self ._path = filepath
169172 if filepath is not None :
170173 self ._read_from_file ()
@@ -189,31 +192,40 @@ def _read_from_file(self) -> None:
189192 @classmethod
190193 def from_file (cls , filepath : PathLike ) -> "RefLog" :
191194 """
192- :return: A new RefLog instance containing all entries from the reflog
193- at the given filepath
194- :param filepath: Path to reflog
195- :raise ValueError: If the file could not be read or was corrupted in some way
195+ :return:
196+ A new :class:`RefLog` instance containing all entries from the reflog at the
197+ given `filepath`.
198+
199+ :param filepath:
200+ Path to reflog.
201+
202+ :raise ValueError:
203+ If the file could not be read or was corrupted in some way.
196204 """
197205 return cls (filepath )
198206
199207 @classmethod
200208 def path (cls , ref : "SymbolicReference" ) -> str :
201209 """
202- :return: String to absolute path at which the reflog of the given ref
203- instance would be found. The path is not guaranteed to point to a valid
204- file though.
205- :param ref: SymbolicReference instance
210+ :return:
211+ String to absolute path at which the reflog of the given ref instance would
212+ be found. The path is not guaranteed to point to a valid file though.
213+
214+ :param ref:
215+ :class:`~git.refs.symbolic.SymbolicReference` instance
206216 """
207217 return osp .join (ref .repo .git_dir , "logs" , to_native_path (ref .path ))
208218
209219 @classmethod
210220 def iter_entries (cls , stream : Union [str , "BytesIO" , mmap ]) -> Iterator [RefLogEntry ]:
211221 """
212- :return: Iterator yielding RefLogEntry instances, one for each line read
222+ :return:
223+ Iterator yielding :class:`RefLogEntry` instances, one for each line read
213224 from the given stream.
214225
215- :param stream: File-like object containing the revlog in its native format
216- or string instance pointing to a file to read.
226+ :param stream:
227+ File-like object containing the revlog in its native format or string
228+ instance pointing to a file to read.
217229 """
218230 new_entry = RefLogEntry .from_line
219231 if isinstance (stream , str ):
@@ -233,18 +245,23 @@ def iter_entries(cls, stream: Union[str, "BytesIO", mmap]) -> Iterator[RefLogEnt
233245 @classmethod
234246 def entry_at (cls , filepath : PathLike , index : int ) -> "RefLogEntry" :
235247 """
236- :return: RefLogEntry at the given index.
248+ :return:
249+ :class:`RefLogEntry` at the given index.
237250
238- :param filepath: Full path to the index file from which to read the entry.
251+ :param filepath:
252+ Full path to the index file from which to read the entry.
239253
240- :param index: Python list compatible index, i.e. it may be negative to
241- specify an entry counted from the end of the list.
254+ :param index:
255+ Python list compatible index, i.e. it may be negative to specify an entry
256+ counted from the end of the list.
242257
243- :raise IndexError: If the entry didn't exist.
258+ :raise IndexError:
259+ If the entry didn't exist.
244260
245- .. note:: This method is faster as it only parses the entry at index, skipping
246- all other lines. Nonetheless, the whole file has to be read if
247- the index is negative.
261+ :note:
262+ This method is faster as it only parses the entry at index, skipping all
263+ other lines. Nonetheless, the whole file has to be read if the index is
264+ negative.
248265 """
249266 with open (filepath , "rb" ) as fp :
250267 if index < 0 :
@@ -264,7 +281,8 @@ def entry_at(cls, filepath: PathLike, index: int) -> "RefLogEntry":
264281 def to_file (self , filepath : PathLike ) -> None :
265282 """Write the contents of the reflog instance to a file at the given filepath.
266283
267- :param filepath: Path to file, parent directories are assumed to exist.
284+ :param filepath:
285+ Path to file. Parent directories are assumed to exist.
268286 """
269287 lfd = LockedFD (filepath )
270288 assure_directory_exists (filepath , is_file = True )
@@ -290,19 +308,32 @@ def append_entry(
290308 ) -> "RefLogEntry" :
291309 """Append a new log entry to the revlog at filepath.
292310
293- :param config_reader: Configuration reader of the repository - used to obtain
294- user information. May also be an Actor instance identifying the committer
311+ :param config_reader:
312+ Configuration reader of the repository - used to obtain user information.
313+ May also be an :class:`~git.util.Actor` instance identifying the committer
295314 directly or None.
296- :param filepath: Full path to the log file.
297- :param oldbinsha: Binary sha of the previous commit.
298- :param newbinsha: Binary sha of the current commit.
299- :param message: Message describing the change to the reference.
300- :param write: If True, the changes will be written right away. Otherwise the
301- change will not be written.
302315
303- :return: RefLogEntry objects which was appended to the log.
316+ :param filepath:
317+ Full path to the log file.
318+
319+ :param oldbinsha:
320+ Binary sha of the previous commit.
321+
322+ :param newbinsha:
323+ Binary sha of the current commit.
324+
325+ :param message:
326+ Message describing the change to the reference.
327+
328+ :param write:
329+ If True, the changes will be written right away.
330+ Otherwise the change will not be written.
331+
332+ :return:
333+ :class:`RefLogEntry` objects which was appended to the log.
304334
305- :note: As we are append-only, concurrent access is not a problem as we do not
335+ :note:
336+ As we are append-only, concurrent access is not a problem as we do not
306337 interfere with readers.
307338 """
308339
@@ -340,7 +371,8 @@ def append_entry(
340371 def write (self ) -> "RefLog" :
341372 """Write this instance's data to the file we are originating from.
342373
343- :return: self
374+ :return:
375+ self
344376 """
345377 if self ._path is None :
346378 raise ValueError ("Instance was not initialized with a path, use to_file(...) instead" )
0 commit comments