~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

  • Committer: Martin
  • Date: 2011-04-15 21:22:57 UTC
  • mto: This revision was merged to the branch mainline in revision 5797.
  • Revision ID: gzlist@googlemail.com-20110415212257-jgtovwwp4be7egd9
Add release notes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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):
2681
2692
        if tracing:
2682
2693
            trace.mutter("set_state_from_inventory complete.")
2683
2694
 
 
2695
    def set_state_from_scratch(self, working_inv, parent_trees, parent_ghosts):
 
2696
        """Wipe the currently stored state and set it to something new.
 
2697
 
 
2698
        This is a hard-reset for the data we are working with.
 
2699
        """
 
2700
        # Technically, we really want a write lock, but until we write, we
 
2701
        # don't really need it.
 
2702
        self._requires_lock()
 
2703
        # root dir and root dir contents with no children. We have to have a
 
2704
        # root for set_state_from_inventory to work correctly.
 
2705
        empty_root = (('', '', inventory.ROOT_ID),
 
2706
                      [('d', '', 0, False, DirState.NULLSTAT)])
 
2707
        empty_tree_dirblocks = [('', [empty_root]), ('', [])]
 
2708
        self._set_data([], empty_tree_dirblocks)
 
2709
        self.set_state_from_inventory(working_inv)
 
2710
        self.set_parent_trees(parent_trees, parent_ghosts)
 
2711
 
2684
2712
    def _make_absent(self, current_old):
2685
2713
        """Mark current_old - an entry - as absent for tree 0.
2686
2714