~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to baz2bzr

  • Committer: Aaron Bentley
  • Date: 2005-06-02 18:16:32 UTC
  • Revision ID: abentley@panoramicfeedback.com-20050602181632-c8a739077a85046b
Skip symlinks while importing

Show diffs side-by-side

added added

removed removed

Lines of Context:
231
231
        yield Progress("revisions", i, len(ancestors))
232
232
        if revdir is None:
233
233
            revdir = os.path.join(tempdir, "rd")
234
 
            baz_inv, log = get_revision(revdir, revision)
 
234
            baz_inv, log = get_revision(revdir, revision, skip_symlink=True)
235
235
            branch = bzrlib.Branch(revdir, init=True)
236
236
        else:
237
237
            old = os.path.join(revdir, ".bzr")
238
238
            new = os.path.join(tempdir, ".bzr")
239
239
            os.rename(old, new)
240
 
            baz_inv, log = apply_revision(revdir, revision)
 
240
            baz_inv, log = apply_revision(revdir, revision, skip_symlink=True)
241
241
            os.rename(new, old)
242
242
            branch = bzrlib.Branch(revdir)
243
243
        timestamp = email.Utils.mktime_tz(log.date + (0,))
268
268
    assert log.revision == revision
269
269
    return log
270
270
 
271
 
def get_revision(revdir, revision):
 
271
def get_revision(revdir, revision, skip_symlink=False):
272
272
    revision.get(revdir)
273
273
    tree = pybaz.tree_root(revdir)
274
274
    log = get_log(tree, revision)
275
275
    try:
276
 
        return bzr_inventory_data(tree), log 
 
276
        return bzr_inventory_data(tree, skip_symlink=skip_symlink), log 
277
277
    except BadFileKind, e:
278
278
        raise UserError("Cannot convert %s because %s is a %s" % (revision,e.path, e.kind) )
279
279
 
280
280
 
281
 
def apply_revision(revdir, revision):
 
281
def apply_revision(revdir, revision, skip_symlink=False):
282
282
    tree = pybaz.tree_root(revdir)
283
283
    revision.apply(tree)
284
284
    log = get_log(tree, revision)
285
285
    try:
286
 
        return bzr_inventory_data(tree), log
 
286
        return bzr_inventory_data(tree, skip_symlink=skip_symlink), log
287
287
    except BadFileKind, e:
288
288
        raise UserError("Cannot convert %s because %s is a %s" % (revision,e.path, e.kind) )
289
289
 
299
299
        Exception.__init__(self, "File %s is of forbidden type %s" %
300
300
                           (os.path.join(tree_root, path), kind))
301
301
 
302
 
def bzr_inventory_data(tree):
 
302
def bzr_inventory_data(tree, skip_symlink=False):
303
303
    inv_iter = tree.iter_inventory_ids(source=True, both=True)
304
304
    inv_map = {}
305
305
    for file_id, path in inv_iter:
309
309
    for path, file_id in inv_map.iteritems():
310
310
        full_path = os.path.join(tree, path)
311
311
        kind = bzrlib.osutils.file_kind(full_path)
 
312
        if skip_symlink and kind == "symlink":
 
313
            continue
312
314
        if kind not in ("file", "directory"):
313
315
            raise BadFileKind(tree, path, kind)
314
316
        parent_dir = os.path.dirname(path)