~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-07 17:02:44 UTC
  • mfrom: (4934.1.14 2.1.0rc1-set-mtime)
  • Revision ID: pqm@pqm.ubuntu.com-20100107170244-3cgdapvuokgf8l42
(jam,
        gz) (bug #488724) Set the mtime of files touched in a TreeTransform.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import os
18
18
import errno
19
19
from stat import S_ISREG, S_IEXEC
 
20
import time
20
21
 
21
22
from bzrlib.lazy_import import lazy_import
22
23
lazy_import(globals(), """
1023
1024
        self._limbo_children_names = {}
1024
1025
        # List of transform ids that need to be renamed from limbo into place
1025
1026
        self._needs_rename = set()
 
1027
        self._creation_mtime = None
1026
1028
 
1027
1029
    def finalize(self):
1028
1030
        """Release the working tree lock, if held, clean up limbo dir.
1133
1135
            f.writelines(contents)
1134
1136
        finally:
1135
1137
            f.close()
 
1138
        self._set_mtime(name)
1136
1139
        self._set_mode(trans_id, mode_id, S_ISREG)
1137
1140
 
1138
1141
    def _read_file_chunks(self, trans_id):
1145
1148
    def _read_symlink_target(self, trans_id):
1146
1149
        return os.readlink(self._limbo_name(trans_id))
1147
1150
 
 
1151
    def _set_mtime(self, path):
 
1152
        """All files that are created get the same mtime.
 
1153
 
 
1154
        This time is set by the first object to be created.
 
1155
        """
 
1156
        if self._creation_mtime is None:
 
1157
            self._creation_mtime = time.time()
 
1158
        os.utime(path, (self._creation_mtime, self._creation_mtime))
 
1159
 
1148
1160
    def create_hardlink(self, path, trans_id):
1149
1161
        """Schedule creation of a hard link"""
1150
1162
        name = self._limbo_name(trans_id)