filter-repo: rename FileChanges to FileChange

This class only represents one FileChange, so fix the misnomer and make
it clearer to others the purpose of this object.

Signed-off-by: Elijah Newren <newren@gmail.com>
pull/13/head
Elijah Newren 5 years ago
parent 346f2ba891
commit 5ed97e999c

@ -45,7 +45,7 @@ import textwrap
from datetime import tzinfo, timedelta, datetime
__all__ = ["Blob", "Reset", "FileChanges", "Commit", "Tag", "Progress",
__all__ = ["Blob", "Reset", "FileChange", "Commit", "Tag", "Progress",
"Checkpoint", "FastExportFilter", "ProgressWriter",
"string_to_date", "date_to_string",
"record_id_rename", "GitUtils", "FilteringOptions", "RepoFilter"]
@ -537,7 +537,7 @@ class Reset(_GitElement):
file_.write(b'from :%d\n' % self.from_ref)
file_.write(b'\n')
class FileChanges(_GitElement):
class FileChange(_GitElement):
"""
This class defines our representation of file change elements. File change
elements are components within a Commit element.
@ -1016,7 +1016,7 @@ class FastExportFilter(object):
if idnum is not None:
if path.startswith(b'"'):
path = PathQuoting.dequote(path)
filechange = FileChanges(b'M', path, idnum, mode)
filechange = FileChange(b'M', path, idnum, mode)
else:
filechange = b'skipped'
self._advance_currentline()
@ -1025,7 +1025,7 @@ class FastExportFilter(object):
path = path.rstrip(b'\n')
if path.startswith(b'"'):
path = PathQuoting.dequote(path)
filechange = FileChanges(b'D', path)
filechange = FileChange(b'D', path)
self._advance_currentline()
elif changetype == b'R': # pragma: no cover (now avoid fast-export renames)
rest = self._currentline[2:-1]
@ -1039,7 +1039,7 @@ class FastExportFilter(object):
orig, new = rest.split(b' ', 1)
if new.startswith(b'"'):
new = PathQuoting.dequote(new)
filechange = FileChanges(b'R', orig, new)
filechange = FileChange(b'R', orig, new)
self._advance_currentline()
return filechange
@ -2970,7 +2970,7 @@ class RepoFilter(object):
# NEEDSWORK: _If_ we ever want to pass `--full-tree` to fast-export and
# parse that output, we'll need to modify this block; `--full-tree`
# issues a deleteall directive which has no filename, and thus this
# block would normally strip it. Of course, FileChanges() and
# block would normally strip it. Of course, FileChange() and
# _parse_optional_filechange() would need updates too.
if change.filename in self._newnames:
change.filename = self._newnames[change.filename]

@ -12,7 +12,7 @@ not try to handle any such special cases.
"""
import git_filter_repo as fr
from git_filter_repo import Blob, Reset, FileChanges, Commit, Tag, FixedTimeZone
from git_filter_repo import Blob, Reset, FileChange, Commit, Tag, FixedTimeZone
from git_filter_repo import Progress, Checkpoint
from datetime import datetime, timedelta
@ -32,8 +32,8 @@ bar.dump(output)
master = Reset(b"refs/heads/master")
master.dump(output)
changes = [FileChanges(b'M', b'world', world.id, mode=b"100644"),
FileChanges(b'M', b'bar', bar.id, mode=b"100644")]
changes = [FileChange(b'M', b'world', world.id, mode=b"100644"),
FileChange(b'M', b'bar', bar.id, mode=b"100644")]
when = datetime(year=2005, month=4, day=7,
hour=15, minute=16, second=10,
tzinfo=FixedTimeZone(b"-0700"))
@ -51,8 +51,8 @@ world.dump(output)
world_link = Blob(b"world")
world_link.dump(output)
changes = [FileChanges(b'M', b'world', world.id, mode=b"100644"),
FileChanges(b'M', b'planet', world_link.id, mode=b"120000")]
changes = [FileChange(b'M', b'world', world.id, mode=b"100644"),
FileChange(b'M', b'planet', world_link.id, mode=b"120000")]
when += timedelta(days=3, hours=4, minutes=6)
when_string = fr.date_to_string(when)
commit2 = Commit(b"refs/heads/master",
@ -65,8 +65,8 @@ commit2.dump(output)
script = Blob(b"#!/bin/sh\n\necho Hello")
script.dump(output)
changes = [FileChanges(b'M', b'runme', script.id, mode=b"100755"),
FileChanges(b'D', b'bar')]
changes = [FileChange(b'M', b'runme', script.id, mode=b"100755"),
FileChange(b'D', b'bar')]
when_string = b"1234567890 -0700"
commit3 = Commit(b"refs/heads/master",
b"A U Thor", b"au@thor.email", when_string,
@ -87,7 +87,7 @@ devel.dump(output)
world = Blob(b"Hello\nGoodbye")
world.dump(output)
changes = [FileChanges(b'M', b'world', world.id, mode=b"100644")]
changes = [FileChange(b'M', b'world', world.id, mode=b"100644")]
when = datetime(2006, 8, 17, tzinfo=FixedTimeZone(b"+0200"))
when_string = fr.date_to_string(when)
commit4 = Commit(b"refs/heads/devel",
@ -106,10 +106,10 @@ when_string = fr.date_to_string(when)
# to the first parent. Thus, despite the fact that runme and planet have
# not changed and bar was not modified in the devel side, we have to list them
# all anyway.
changes = [FileChanges(b'M', b'world', world.id, mode=b"100644"),
FileChanges(b'D', b'bar'),
FileChanges(b'M', b'runme', script.id, mode=b"100755"),
FileChanges(b'M', b'planet', world_link.id, mode=b"120000")]
changes = [FileChange(b'M', b'world', world.id, mode=b"100644"),
FileChange(b'D', b'bar'),
FileChange(b'M', b'runme', script.id, mode=b"100755"),
FileChange(b'M', b'planet', world_link.id, mode=b"120000")]
commit5 = Commit(b"refs/heads/devel",
b"A U Thor", b"au@thor.email", when_string,

Loading…
Cancel
Save