142
148
"""Time of day as a string."""
143
149
# Note: this is a separate method so tests can patch in a fixed value
144
150
return time.strftime("%H:%M:%S")
152
def _import_marks(self, filename):
157
"Could not open import-marks file, not importing marks")
160
firstline = f.readline()
161
match = re.match(r'^format=(\d+)$', firstline)
163
print >>sys.stderr, "%r doesn't look like a mark file" % \
166
elif match.group(1) != '1':
167
print >>sys.stderr, 'format version in mark file not supported'
170
for string in f.readline().rstrip('\n').split('\0'):
173
name, integer = string.rsplit('.', 1)
174
# We really can't do anything with the branch information, so we
177
self.cache_mgr.revision_ids = {}
179
line = line.rstrip('\n')
180
mark, revid = line.split(' ', 1)
181
self.cache_mgr.revision_ids[mark] = revid
184
def export_marks(self, filename):
186
f = file(filename, 'w')
189
"Could not open export-marks file, not exporting marks")
191
f.write('format=1\n')
193
for mark, revid in self.cache_mgr.revision_ids.iteritems():
194
f.write('%s %s\n' % (mark, revid))
146
197
def pre_process(self):
147
198
self._start_time = time.time()
148
199
self._load_info_and_params()
149
200
self.cache_mgr = GenericCacheManager(self.info, self.verbose,
150
201
self.inventory_cache_size)
151
self.skip_total = self._init_id_map()
153
self.note("Found %d commits already loaded - "
154
"skipping over these ...", self.skip_total)
203
if self.params.get("import-marks") is not None:
204
self._import_marks(self.params.get("import-marks"))
205
self.skip_total = False
206
self.first_incremental_commit = True
208
self.first_incremental_commit = False
209
self.skip_total = self._init_id_map()
211
self.note("Found %d commits already loaded - "
212
"skipping over these ...", self.skip_total)
155
213
self._revision_count = 0
157
215
# mapping of tag name to revision_id
267
325
self.repo.commit_write_group()
268
326
self._save_id_map()
328
if self.params.get("export-marks") is not None:
329
self.export_marks(self.params.get("export-marks"))
270
331
# Update the branches
271
332
self.note("Updating branch information ...")
272
333
updater = GenericBranchUpdater(self.repo, self.branch, self.cache_mgr,
414
475
self.note("Generated the file-ids cache - %d entries",
415
476
len(self.cache_mgr.file_ids.keys()))
478
if self.first_incremental_commit:
479
self.first_incremental_commit = None
480
parents = _track_heads(cmd, self.cache_mgr)
481
self._gen_file_ids_cache(parents)
418
483
# 'Commit' the revision and report progress
419
484
handler = GenericCommitHandler(cmd, self.repo, self.cache_mgr,
433
498
self._revision_count)
434
499
self.checkpoint_handler(None)
436
def _gen_file_ids_cache(self):
501
def _gen_file_ids_cache(self, revs=False):
437
502
"""Generate the file-id cache by searching repository inventories.
439
504
# Get the interesting revisions - the heads
440
head_ids = self.cache_mgr.heads.keys()
508
head_ids = self.cache_mgr.heads.keys()
441
509
revision_ids = [self.cache_mgr.revision_ids[h] for h in head_ids]
443
511
# Update the fileid cache