filter-repo: reinstate the id_offset

My idea to use --export-marks and --import-marks to avoid the need for the
id_offset was not tested and apparently a bad idea.  When splicing together
multiple repositories, the second will croak if we pass it --import-marks
with a file having sha1sums that don't exist in that repository.

I'm afraid this might conflict with the --import-marks stuff used in collab
so I've only enabled it for streams beyond the first.  So there might be an
issue using --import-marks on a second or later fast-export output stream,
but I can't think of a use case for that...

Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
Elijah Newren 2009-04-04 17:12:43 -06:00
parent fbd3a04b7f
commit e7311b6db9

View File

@ -661,6 +661,10 @@ 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
#############################################################################
def _advance_currentline(self):
#############################################################################
@ -679,7 +683,7 @@ class FastExportFilter(object):
mark = None
matches = re.match('mark :(\d+)\n$', self._currentline)
if matches:
mark = int(matches.group(1))
mark = int(matches.group(1))+self._id_offset
self._advance_currentline()
return mark
@ -697,7 +701,7 @@ class FastExportFilter(object):
if matches:
# We translate the parent commit mark to what it needs to be in
# our mark namespace
baseref = _IDS.translate( int(matches.group(1)) )
baseref = _IDS.translate( int(matches.group(1))+self._id_offset )
self._advance_currentline()
return baseref
@ -715,7 +719,7 @@ class FastExportFilter(object):
(mode, idnum, path) = \
re.match('M (\d+) :(\d+) (.*)\n$', self._currentline).groups()
# We translate the idnum to our id system
idnum = _IDS.translate( int(idnum) )
idnum = _IDS.translate( int(idnum)+self._id_offset )
if idnum is not None:
if path.startswith('"'):
path = unquote(path)
@ -1058,6 +1062,8 @@ class FastExportFilter(object):
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()