226
226
def iter_import_version(output_dir, version, tempdir):
228
228
ancestors = version_ancestry(version)
230
if os.path.exists(output_dir):
231
# We are starting from an existing directory, figure out what
232
# the current version is
233
branch = bzrlib.Branch(output_dir)
234
last_patch = branch.last_patch()
235
if last_patch is not None:
236
if last_patch[:7] != 'Arch-x:':
237
raise UserError("Directory \"%s\" already exists, and the last patch is not an arch patch (%s)" % (output_dir, last_patch))
239
last_patch = last_patch[7:].replace('%', '/')
242
for i in range(len(ancestors)):
243
if str(ancestors[i]) == last_patch:
246
raise UserError("Directory \"%s\" already exists, and the last patch (%s) is not in the revision history" % (output_dir, last_patch))
247
# Strip off all of the ancestors which are already present
248
ancestors = ancestors[i+1:]
250
if len(ancestors) == 0:
251
print '* Tree is up-to-date with %s' % last_patch
253
# Uncomment this for testing, it basically just has baz2bzr only update
254
# 5 patches at a time
255
#ancestors = ancestors[:5]
229
257
for i in range(len(ancestors)):
230
258
revision = ancestors[i]
231
259
yield Progress("revisions", i, len(ancestors))
252
280
bzrlib.trace.silent = False
254
282
yield Progress("revisions", len(ancestors), len(ancestors))
255
unlink_unversioned(branch, revdir)
283
# If you want to update this later, you cannot unlink the {arch} directory.
284
# unlink_unversioned(branch, revdir)
256
285
os.rename(revdir, output_dir)
258
287
def unlink_unversioned(branch, revdir):
329
358
elif len(sys.argv) == 3:
331
360
output_dir = os.path.realpath(sys.argv[2])
332
if os.path.exists(output_dir):
333
raise UserError("Directory \"%s\" already exists" % output_dir)
334
361
import_version(output_dir, pybaz.Version(sys.argv[1]))
335
362
except UserError, e: