~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:03:02 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-20100710210302-o0081gfn0zllhrf1
* extract backup_files
* factor out common backup code in workingtree.remove

Show diffs side-by-side

added added

removed removed

Lines of Context:
2021
2021
                    # in one of the dirs to be deleted.
2022
2022
                    files_to_backup.append(path[1])
2023
2023
 
 
2024
        def backup(file_to_backup):
 
2025
            backup_name = self.bzrdir.generate_backup_name(file_to_backup)
 
2026
            osutils.rename(abs_path, self.abspath(backup_name))
 
2027
            return "removed %s (but kept a copy: %s)" % (file_to_backup, backup_name)
 
2028
 
2024
2029
        # Build inv_delta and delete files where applicable,
2025
2030
        # do this before any modifications to inventory.
2026
2031
        for f in files:
2051
2056
                            osutils.rmtree(abs_path)
2052
2057
                            message = "deleted %s" % (f,)
2053
2058
                        else:
2054
 
                            backup_name = self.bzrdir.generate_backup_name(f)
2055
 
                            osutils.rename(abs_path, self.abspath(backup_name))
2056
 
                            message = "removed %s (but kept a copy: %s)" % (
2057
 
                                f, backup_name)
 
2059
                            message = backup(f)
2058
2060
                    else:
2059
2061
                        if f in files_to_backup:
2060
 
                            backup_name = self.bzrdir.generate_backup_name(f)
2061
 
                            osutils.rename(abs_path, self.abspath(backup_name))
2062
 
                            message = "removed %s (but kept a copy: %s)" % (
2063
 
                                f, backup_name)
 
2062
                            message = backup(f)
2064
2063
                        else:
2065
2064
                            osutils.delete_any(abs_path)
2066
2065
                            message = "deleted %s" % (f,)