mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-07-04 01:15:41 +02:00
filter-repo: delete complex code
Over a decade ago, I added code to deal with splitting and splicing repositories where you weren't always dealing with first parents and linear histories, and in particular where the mainline tended to be the second parent (because there was no integrator or special central gatekeeper like gerrit or github; instead, everyone pushed directly to the main repository after locally testing, and integration happened via everyone running 'git pull'). When attempting to splice repositories the fact that fast-export always gave changes relative to the first parent caused some grief with my splitting and splicing efforts. It has been over a decade, I don't know of a good testcase of this functionality separate from the live repositories I lost access to over six years ago, git-subtree was released in the meantime which I'm certain handled the task better, git-fast-export since gained a --full-tree option which might have provided a better way to attack the problem (though with splicing repos you often want work with additive changes rather than recreating from scratch), and I just don't quite understand the code anymore anyway. I think it had some fundamental limitations that I knew my usecase avoided, but I don't remember the details (and I'm not certain if this is true). Even though code coverage hits all but one of the lines, I'd rather rewrite any needed functionality if the usecase arises, and in view of what facilities exist today rather than what I was working with a decade ago. So, just nuke this code. Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
cb9e3dd92c
commit
a31a381fb8
|
@ -590,38 +590,12 @@ class Commit(_GitElementWithId):
|
|||
# Record additional parent commits
|
||||
self.merge_commits = merge_commits
|
||||
|
||||
# Member below is necessary for workaround fast-import's/fast-export's
|
||||
# weird handling of merges.
|
||||
self.stream_number = 0
|
||||
if "stream_number" in kwargs:
|
||||
self.stream_number = kwargs["stream_number"]
|
||||
|
||||
def dump(self, file_):
|
||||
"""
|
||||
Write this commit element to a file.
|
||||
"""
|
||||
self.dumped = 1
|
||||
|
||||
# Workaround fast-import/fast-export weird handling of merges
|
||||
if self.stream_number != _CURRENT_STREAM_NUMBER:
|
||||
_EXTRA_CHANGES[self.id] = [[change for change in self.file_changes]]
|
||||
|
||||
merge_extra_changes = []
|
||||
for parent in self.merge_commits:
|
||||
if parent in _EXTRA_CHANGES:
|
||||
merge_extra_changes += _EXTRA_CHANGES[parent]
|
||||
|
||||
for additional_changes in merge_extra_changes:
|
||||
self.file_changes += additional_changes
|
||||
|
||||
if self.stream_number == _CURRENT_STREAM_NUMBER:
|
||||
parent_extra_changes = []
|
||||
if self.from_commit and self.from_commit in _EXTRA_CHANGES:
|
||||
parent_extra_changes = _EXTRA_CHANGES[self.from_commit]
|
||||
parent_extra_changes += merge_extra_changes
|
||||
_EXTRA_CHANGES[self.id] = parent_extra_changes
|
||||
# End workaround
|
||||
|
||||
# Make output to fast-import slightly easier for humans to read if the
|
||||
# message has no trailing newline of its own; cosmetic, but a nice touch...
|
||||
extra_newline = '\n'
|
||||
|
@ -886,10 +860,6 @@ class FastExportFilter(object):
|
|||
# Stores the contents of the current line of input being parsed
|
||||
self._currentline = ''
|
||||
|
||||
# Stores a translation of ids, useful when reading the output of a second
|
||||
# or third (or etc.) git fast-export output stream
|
||||
self._id_offset = 0
|
||||
|
||||
# Progress handling (number of commits parsed, etc.)
|
||||
self._progress_writer = ProgressWriter()
|
||||
self._num_commits = 0
|
||||
|
@ -932,7 +902,7 @@ class FastExportFilter(object):
|
|||
mark = None
|
||||
matches = self._mark_re.match(self._currentline)
|
||||
if matches:
|
||||
mark = int(matches.group(1))+self._id_offset
|
||||
mark = int(matches.group(1))
|
||||
self._advance_currentline()
|
||||
return mark
|
||||
|
||||
|
@ -947,7 +917,7 @@ class FastExportFilter(object):
|
|||
rule, altrule = self._parent_regexes[refname]
|
||||
matches = rule.match(self._currentline)
|
||||
if matches:
|
||||
orig_baseref = int(matches.group(1)) + self._id_offset
|
||||
orig_baseref = int(matches.group(1))
|
||||
# We translate the parent commit mark to what it needs to be in
|
||||
# our mark namespace
|
||||
baseref = _IDS.translate(orig_baseref)
|
||||
|
@ -976,7 +946,7 @@ class FastExportFilter(object):
|
|||
path = path.rstrip('\n')
|
||||
# We translate the idnum to our id system
|
||||
if len(idnum) != 40:
|
||||
idnum = _IDS.translate( int(idnum)+self._id_offset )
|
||||
idnum = _IDS.translate( int(idnum) )
|
||||
if idnum is not None:
|
||||
if path.startswith('"'):
|
||||
path = PathQuoting.dequote(path)
|
||||
|
@ -1442,8 +1412,7 @@ class FastExportFilter(object):
|
|||
file_changes,
|
||||
from_commit,
|
||||
merge_commits,
|
||||
original_id,
|
||||
stream_number = _CURRENT_STREAM_NUMBER)
|
||||
original_id)
|
||||
|
||||
# If fast-export text had a mark for this commit, need to make sure this
|
||||
# mark translates to the commit's true id.
|
||||
|
@ -1712,13 +1681,6 @@ class FastExportFilter(object):
|
|||
self._fast_import_pipes = fast_import_pipes
|
||||
self._quiet = quiet
|
||||
|
||||
# Setup some vars
|
||||
global _CURRENT_STREAM_NUMBER
|
||||
|
||||
_CURRENT_STREAM_NUMBER += 1
|
||||
if _CURRENT_STREAM_NUMBER > 1:
|
||||
self._id_offset = _IDS._next_id-1
|
||||
|
||||
# Run over the input and do the filtering
|
||||
self._advance_currentline()
|
||||
while self._currentline:
|
||||
|
@ -1764,9 +1726,7 @@ def record_id_rename(old_id, new_id):
|
|||
|
||||
# Internal globals
|
||||
_IDS = _IDs()
|
||||
_EXTRA_CHANGES = {} # idnum -> list of list of FileChanges
|
||||
_SKIPPED_COMMITS = set()
|
||||
_CURRENT_STREAM_NUMBER = 0
|
||||
|
||||
class GitUtils(object):
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in New Issue
Block a user