summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-12-11 22:30:10 +0100
committerJelmer Vernooij <jelmer@samba.org>2010-12-11 22:30:10 +0100
commit41fdf95ce9883e23bc423060b8437203b3c2039d (patch)
tree31b20a7829b63c9bc0708862cb76b500b557927b
parent1bd92b8ae760d6ed8f47c5b74bbdcd2eba6580ba (diff)
parentb84a807c54458a04c971085c7564b057cecd070e (diff)
downloadbzr-fastimport-41fdf95ce9883e23bc423060b8437203b3c2039d.tar.gz
Support new marks file format introduced in (apparently) git 1.6.
-rw-r--r--NEWS3
-rw-r--r--exporter.py8
-rw-r--r--marks_file.py59
-rw-r--r--processors/generic_processor.py2
4 files changed, 30 insertions, 42 deletions
diff --git a/NEWS b/NEWS
index 7d2cb12..c9aa26e 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,9 @@ Bug fixes
* SOURCE argument to bzr fast-import-filter is now optional, consistent with
examples. (Jelmer Vernooij, #477861)
+* Support new marks file format introduced in (apparently) git 1.6.
+ (Ian Clatworthy, Jelmer Vernooij, Gabriel Filion, #347729)
+
0.9 28-Feb-2010
===============
diff --git a/exporter.py b/exporter.py
index 68f5cde..3f477d1 100644
--- a/exporter.py
+++ b/exporter.py
@@ -103,8 +103,9 @@ class BzrFastExporter(object):
marks_info = marks_file.import_marks(self.import_marks_file)
if marks_info is not None:
self.revid_to_mark = dict((r, m) for m, r in
- marks_info[0].items())
- self.branch_names = marks_info[1]
+ marks_info.items())
+ # These are no longer included in the marks file
+ #self.branch_names = marks_info[1]
def interesting_history(self):
if self.revision:
@@ -193,8 +194,7 @@ class BzrFastExporter(object):
def _save_marks(self):
if self.export_marks_file:
revision_ids = dict((m, r) for r, m in self.revid_to_mark.items())
- marks_file.export_marks(self.export_marks_file, revision_ids,
- self.branch_names)
+ marks_file.export_marks(self.export_marks_file, revision_ids)
def is_empty_dir(self, tree, path):
path_id = tree.path2id(path)
diff --git a/marks_file.py b/marks_file.py
index 96e3cab..c05f8c6 100644
--- a/marks_file.py
+++ b/marks_file.py
@@ -17,7 +17,6 @@
"""Routines for reading/writing a marks file."""
-import re
from bzrlib.trace import warning
@@ -25,11 +24,8 @@ def import_marks(filename):
"""Read the mapping of marks to revision-ids from a file.
:param filename: the file to read from
- :return: None if an error is encountered or (revision_ids, branch_names)
- where
- * revision_ids is a dictionary with marks as keys and revision-ids
- as values
- * branch_names is a dictionary mapping branch names to some magic #
+ :return: None if an error is encountered or a dictionary with marks
+ as keys and revision-ids as values
"""
# Check that the file is readable and in the right format
try:
@@ -38,41 +34,38 @@ def import_marks(filename):
warning("Could not import marks file %s - not importing marks",
filename)
return None
- firstline = f.readline()
- match = re.match(r'^format=(\d+)$', firstline)
- if not match:
- warning("%r doesn't look like a marks file - not importing marks",
- filename)
- return None
- elif match.group(1) != '1':
- warning('format version in marks file %s not supported - not importing'
- 'marks', filename)
- return None
- # Read the branch info
- branch_names = {}
- for string in f.readline().rstrip('\n').split('\0'):
- if not string:
- continue
- name, integer = string.rsplit('.', 1)
- branch_names[name] = int(integer)
-
# Read the revision info
revision_ids = {}
- for line in f:
+
+ line = f.readline()
+ if line == 'format=1\n':
+ # Cope with old-style marks files
+ # Read the branch info
+ branch_names = {}
+ for string in f.readline().rstrip('\n').split('\0'):
+ if not string:
+ continue
+ name, integer = string.rsplit('.', 1)
+ branch_names[name] = int(integer)
+ line = f.readline()
+
+ while line:
line = line.rstrip('\n')
mark, revid = line.split(' ', 1)
+ if mark.startswith(':'):
+ mark = mark[1:]
revision_ids[mark] = revid
+ line = f.readline()
f.close()
- return (revision_ids, branch_names)
+ return revision_ids
-def export_marks(filename, revision_ids, branch_names=None):
+def export_marks(filename, revision_ids):
"""Save marks to a file.
:param filename: filename to save data to
:param revision_ids: dictionary mapping marks -> bzr revision-ids
- :param branch_names: dictionary mapping branch names to some magic #
"""
try:
f = file(filename, 'w')
@@ -80,16 +73,8 @@ def export_marks(filename, revision_ids, branch_names=None):
warning("Could not open export-marks file %s - not exporting marks",
filename)
return
- f.write('format=1\n')
-
- # Write the branch names line
- if branch_names:
- branch_names = [ '%s.%d' % x for x in branch_names.iteritems() ]
- f.write('\0'.join(branch_names) + '\n')
- else:
- f.write('\0tmp.0\n')
# Write the revision info
for mark, revid in revision_ids.iteritems():
- f.write('%s %s\n' % (mark, revid))
+ f.write(':%s %s\n' % (mark, revid))
f.close()
diff --git a/processors/generic_processor.py b/processors/generic_processor.py
index 43c933b..70779b3 100644
--- a/processors/generic_processor.py
+++ b/processors/generic_processor.py
@@ -154,7 +154,7 @@ class GenericProcessor(processor.ImportProcessor):
if self.params.get("import-marks") is not None:
mark_info = marks_file.import_marks(self.params.get("import-marks"))
if mark_info is not None:
- self.cache_mgr.revision_ids = mark_info[0]
+ self.cache_mgr.revision_ids = mark_info
self.skip_total = False
self.first_incremental_commit = True
else: