~ubuntu-branches/ubuntu/oneiric/bzr/oneiric

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-28 22:34:03 UTC
  • mfrom: (3815.2547.111 upstream)
  • Revision ID: jelmer@samba.org-20110428223403-iw7pg8u0rsegjwxo
releasing version 2.4.0~beta2-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
265
265
        # return '%X.%X' % (int(st.st_mtime), st.st_mode)
266
266
 
267
267
 
 
268
def _unpack_stat(packed_stat):
 
269
    """Turn a packed_stat back into the stat fields.
 
270
 
 
271
    This is meant as a debugging tool, should not be used in real code.
 
272
    """
 
273
    (st_size, st_mtime, st_ctime, st_dev, st_ino,
 
274
     st_mode) = struct.unpack('>LLLLLL', binascii.a2b_base64(packed_stat))
 
275
    return dict(st_size=st_size, st_mtime=st_mtime, st_ctime=st_ctime,
 
276
                st_dev=st_dev, st_ino=st_ino, st_mode=st_mode)
 
277
 
 
278
 
268
279
class SHA1Provider(object):
269
280
    """An interface for getting sha1s of a file."""
270
281
 
1734
1745
                self._sha_cutoff_time()
1735
1746
            if (stat_value.st_mtime < self._cutoff_time
1736
1747
                and stat_value.st_ctime < self._cutoff_time):
1737
 
                entry[1][0] = ('f', sha1, entry[1][0][2], entry[1][0][3],
1738
 
                    packed_stat)
 
1748
                entry[1][0] = ('f', sha1, stat_value.st_size, entry[1][0][3],
 
1749
                               packed_stat)
1739
1750
                self._dirblock_state = DirState.IN_MEMORY_MODIFIED
1740
1751
 
1741
1752
    def _sha_cutoff_time(self):
3194
3205
    # If we have gotten this far, that means that we need to actually
3195
3206
    # process this entry.
3196
3207
    link_or_sha1 = None
 
3208
    worth_saving = True
3197
3209
    if minikind == 'f':
3198
3210
        executable = state._is_executable(stat_value.st_mode,
3199
3211
                                         saved_executable)
3215
3227
        else:
3216
3228
            entry[1][0] = ('f', '', stat_value.st_size,
3217
3229
                           executable, DirState.NULLSTAT)
 
3230
            worth_saving = False
3218
3231
    elif minikind == 'd':
3219
3232
        link_or_sha1 = None
3220
3233
        entry[1][0] = ('d', '', 0, False, packed_stat)
3226
3239
                state._get_block_entry_index(entry[0][0], entry[0][1], 0)
3227
3240
            state._ensure_block(block_index, entry_index,
3228
3241
                               osutils.pathjoin(entry[0][0], entry[0][1]))
 
3242
        else:
 
3243
            worth_saving = False
3229
3244
    elif minikind == 'l':
3230
3245
        link_or_sha1 = state._read_link(abspath, saved_link_or_sha1)
3231
3246
        if state._cutoff_time is None:
3237
3252
        else:
3238
3253
            entry[1][0] = ('l', '', stat_value.st_size,
3239
3254
                           False, DirState.NULLSTAT)
3240
 
    state._dirblock_state = DirState.IN_MEMORY_MODIFIED
 
3255
    if worth_saving:
 
3256
        state._dirblock_state = DirState.IN_MEMORY_MODIFIED
3241
3257
    return link_or_sha1
3242
3258
 
3243
3259