~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

[merge] robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock, quotefn
50
50
import bzrlib.tree
51
51
from bzrlib.osutils import appendpath, file_kind, isdir, splitpath, relpath
52
 
from bzrlib.errors import BzrCheckError, NotVersionedError
 
52
from bzrlib.errors import BzrCheckError, DivergedBranches, NotVersionedError
53
53
from bzrlib.trace import mutter
54
54
 
 
55
 
55
56
class TreeEntry(object):
56
57
    """An entry that implements the minium interface used by commands.
57
58
 
140
141
 
141
142
        # update the whole cache up front and write to disk if anything changed;
142
143
        # in the future we might want to do this more selectively
 
144
        # two possible ways offer themselves : in self._unlock, write the cache
 
145
        # if needed, or, when the cache sees a change, append it to the hash
 
146
        # cache file, and have the parser take the most recent entry for a
 
147
        # given path only.
143
148
        hc = self._hashcache = HashCache(basedir)
144
149
        hc.read()
145
150
        hc.scan()
147
152
        if hc.needs_write:
148
153
            mutter("write hc")
149
154
            hc.write()
150
 
            
151
 
            
152
 
    def __del__(self):
153
 
        if self._hashcache.needs_write:
154
 
            self._hashcache.write()
155
 
 
156
155
 
157
156
    def __iter__(self):
158
157
        """Iterate through file_ids for this tree.
330
329
                conflicted.add(stem)
331
330
                yield stem
332
331
 
 
332
    @needs_write_lock
 
333
    def pull(self, source, remember=False, clobber=False):
 
334
        from bzrlib.merge import merge_inner
 
335
        source.lock_read()
 
336
        try:
 
337
            old_revision_history = self.branch.revision_history()
 
338
            try:
 
339
                self.branch.update_revisions(source)
 
340
            except DivergedBranches:
 
341
                if not clobber:
 
342
                    raise
 
343
                self.branch.set_revision_history(source.revision_history())
 
344
            new_revision_history = self.branch.revision_history()
 
345
            if new_revision_history != old_revision_history:
 
346
                if len(old_revision_history):
 
347
                    other_revision = old_revision_history[-1]
 
348
                else:
 
349
                    other_revision = None
 
350
                merge_inner(self.branch,
 
351
                            self.branch.basis_tree(), 
 
352
                            self.branch.revision_tree(other_revision))
 
353
            if self.branch.get_parent() is None or remember:
 
354
                self.branch.set_parent(source.base)
 
355
        finally:
 
356
            source.unlock()
 
357
 
333
358
    def extras(self):
334
359
        """Yield all unknown files in this WorkingTree.
335
360