135
137
"""Time of day as a string."""
136
138
# Note: this is a separate method so tests can patch in a fixed value
137
139
return time.strftime("%H:%M:%S")
141
def _import_marks(self, filename):
145
self.warning("Could not open import-marks file, not importing marks")
148
firstline = f.readline()
149
match = re.match(r'^format=(\d+)$', firstline)
152
print >>sys.stderr, "%r doesn't look like a mark file" % (filename,)
154
elif match.group(1) != '1':
155
print >>sys.stderr, 'format version in mark file not supported'
158
for string in f.readline().rstrip('\n').split('\0'):
161
name, integer = string.rsplit('.', 1)
162
# We really can't do anything with the branch information, so we
165
self.cache_mgr.revision_ids = {}
167
line = line.rstrip('\n')
168
mark, revid = line.split(' ', 1)
170
self.cache_mgr.revision_ids[mark] = revid
172
def export_marks(self, filename):
173
f = file(filename, 'w')
174
f.write('format=1\n')
178
for mark, revid in self.cache_mgr.revision_ids.iteritems():
179
f.write('%s %s\n' % (mark, revid))
139
183
def pre_process(self):
140
184
self._start_time = time.time()
141
185
self._load_info_and_params()
142
186
self.cache_mgr = GenericCacheManager(self.info, self.verbose,
143
187
self.inventory_cache_size)
144
self.skip_total = self._init_id_map()
146
self.note("Found %d commits already loaded - "
147
"skipping over these ...", self.skip_total)
148
self._revision_count = 0
189
if self.params.get("import-marks"):
190
self._import_marks(self.params.get("import-marks"))
191
self.skip_total = False
192
self._revision_count = 0
193
self.first_incremental_commit = True
195
self.first_incremental_commit = False
196
self.skip_total = self._init_id_map()
199
self.note("Found %d commits already loaded - "
200
"skipping over these ...", self.skip_total)
201
self._revision_count = 0
150
203
# mapping of tag name to revision_id
235
288
self.repo.commit_write_group()
236
289
self._save_id_map()
291
if self.params.get("export-marks"):
292
self.export_marks(self.params.get("export-marks"))
238
294
# Update the branches
239
295
self.note("Updating branch information ...")
240
296
updater = GenericBranchUpdater(self.repo, self.branch, self.cache_mgr,
382
438
self.note("Generated the file-ids cache - %d entries",
383
439
len(self.cache_mgr.file_ids.keys()))
441
if self.first_incremental_commit:
442
self.first_incremental_commit = None
443
parents = _track_heads(cmd, self.cache_mgr)
444
self._gen_file_ids_cache(parents)
386
446
# 'Commit' the revision and report progress
387
447
handler = GenericCommitHandler(cmd, self.repo, self.cache_mgr,
401
461
self._revision_count)
402
462
self.checkpoint_handler(None)
404
def _gen_file_ids_cache(self):
464
def _gen_file_ids_cache(self, revs = False):
405
465
"""Generate the file-id cache by searching repository inventories.
407
467
# Get the interesting revisions - the heads
408
head_ids = self.cache_mgr.heads.keys()
471
head_ids = self.cache_mgr.heads.keys()
409
472
revision_ids = [self.cache_mgr.revision_ids[h] for h in head_ids]
411
474
# Update the fileid cache