/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Vincent Ladeuil
  • Date: 2009-03-12 10:04:53 UTC
  • mfrom: (4112.1.3 4117-cat-wrong-file-id)
  • mto: This revision was merged to the branch mainline in revision 4135.
  • Revision ID: v.ladeuil+lp@free.fr-20090312100453-6txhip85enlh3fwo
cat use old file id if current one is not found is requested revision

Show diffs side-by-side

added added

removed removed

Lines of Context:
2583
2583
            tree = b.basis_tree()
2584
2584
        rev_tree = _get_one_revision_tree('cat', revision, branch=b)
2585
2585
 
2586
 
        cur_file_id = tree.path2id(relpath)
2587
2586
        old_file_id = rev_tree.path2id(relpath)
2588
2587
 
2589
2588
        if name_from_revision:
 
2589
            # Try in revision if requested
2590
2590
            if old_file_id is None:
2591
2591
                raise errors.BzrCommandError(
2592
2592
                    "%r is not present in revision %s" % (
2593
2593
                        filename, rev_tree.get_revision_id()))
2594
2594
            else:
2595
2595
                content = rev_tree.get_file_text(old_file_id)
2596
 
        elif cur_file_id is not None:
2597
 
            content = rev_tree.get_file_text(cur_file_id)
2598
 
        elif old_file_id is not None:
2599
 
            content = rev_tree.get_file_text(old_file_id)
2600
2596
        else:
2601
 
            raise errors.BzrCommandError(
2602
 
                "%r is not present in revision %s" % (
2603
 
                    filename, rev_tree.get_revision_id()))
 
2597
            cur_file_id = tree.path2id(relpath)
 
2598
            found = False
 
2599
            if cur_file_id is not None:
 
2600
                # Then try with the actual file id
 
2601
                try:
 
2602
                    content = rev_tree.get_file_text(cur_file_id)
 
2603
                    found = True
 
2604
                except errors.NoSuchId:
 
2605
                    # The actual file id didn't exist at that time
 
2606
                    pass
 
2607
            if not found and old_file_id is not None:
 
2608
                # Finally try with the old file id
 
2609
                content = rev_tree.get_file_text(old_file_id)
 
2610
                found = True
 
2611
            if not found:
 
2612
                # Can't be found anywhere
 
2613
                raise errors.BzrCommandError(
 
2614
                    "%r is not present in revision %s" % (
 
2615
                        filename, rev_tree.get_revision_id()))
2604
2616
        self.outf.write(content)
2605
2617
 
2606
2618