~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Marius Kruger
  • Date: 2010-07-09 22:45:25 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100709224525-a0bijmcw3dw02r8g
* make the backup file name generator in bzrdir available to others
* Whenever bzr is asked to delete stuff, back it up if the content is not in version control.
* Update whitebox tests (Did them first btw. Vila's voice keeps ringing in my head)
* deprecate the now unused BzrRemoveChangedFilesError

Show diffs side-by-side

added added

removed removed

Lines of Context:
615
615
        """
616
616
        raise NotImplementedError(self.create_workingtree)
617
617
 
 
618
    def gen_backup_name(self, base):
 
619
        """Generate a non-existing backup file name based on base."""
 
620
        counter = 1
 
621
        name = "%s.~%d~" % (base, counter)
 
622
        while self.root_transport.has(name):
 
623
            counter += 1
 
624
            name = "%s.~%d~" % (base, counter)
 
625
        return name
 
626
 
618
627
    def backup_bzrdir(self):
619
628
        """Backup this bzr control directory.
620
629
 
621
630
        :return: Tuple with old path name and new path name
622
631
        """
623
 
        def name_gen(base='backup.bzr'):
624
 
            counter = 1
625
 
            name = "%s.~%d~" % (base, counter)
626
 
            while self.root_transport.has(name):
627
 
                counter += 1
628
 
                name = "%s.~%d~" % (base, counter)
629
 
            return name
630
632
 
631
 
        backup_dir=name_gen()
 
633
        backup_dir=self.name_gen('backup.bzr')
632
634
        pb = ui.ui_factory.nested_progress_bar()
633
635
        try:
634
636
            # FIXME: bug 300001 -- the backup fails if the backup directory