~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Wouter van Heyst
  • Date: 2006-07-13 18:18:00 UTC
  • mfrom: (1863 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1867.
  • Revision ID: larstiq@larstiq.dyndns.org-20060713181800-4e8c4f9326597d7f
[merge] bzr.dev 1863

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
                            delete_any)
27
27
from bzrlib.progress import DummyProgress, ProgressPhase
28
28
from bzrlib.trace import mutter, warning
 
29
from bzrlib import tree
29
30
import bzrlib.ui 
30
31
import bzrlib.urlutils as urlutils
31
32
 
259
260
        New file takes the permissions of any existing file with that id,
260
261
        unless mode_id is specified.
261
262
        """
262
 
        f = file(self._limbo_name(trans_id), 'wb')
263
 
        unique_add(self._new_contents, trans_id, 'file')
264
 
        for segment in contents:
265
 
            f.write(segment)
266
 
        f.close()
 
263
        name = self._limbo_name(trans_id)
 
264
        f = open(name, 'wb')
 
265
        try:
 
266
            try:
 
267
                unique_add(self._new_contents, trans_id, 'file')
 
268
            except:
 
269
                # Clean up the file, it never got registered so
 
270
                # TreeTransform.finalize() won't clean it up.
 
271
                f.close()
 
272
                os.unlink(name)
 
273
                raise
 
274
 
 
275
            for segment in contents:
 
276
                f.write(segment)
 
277
        finally:
 
278
            f.close()
267
279
        self._set_mode(trans_id, mode_id, S_ISREG)
268
280
 
269
281
    def _set_mode(self, trans_id, mode_id, typefunc):
988
1000
def find_interesting(working_tree, target_tree, filenames):
989
1001
    """Find the ids corresponding to specified filenames."""
990
1002
    trees = (working_tree, target_tree)
991
 
    if not filenames:
992
 
        interesting_ids = None
993
 
    else:
994
 
        interesting_ids = set()
995
 
        for tree_path in filenames:
996
 
            not_found = True
997
 
            for tree in trees:
998
 
                file_id = tree.inventory.path2id(tree_path)
999
 
                if file_id is not None:
1000
 
                    interesting_ids.add(file_id)
1001
 
                    not_found = False
1002
 
            if not_found:
1003
 
                raise NotVersionedError(path=tree_path)
1004
 
        
1005
 
        pending = interesting_ids
1006
 
        # now handle children of interesting ids
1007
 
        # we loop so that we handle all children of each id in both trees
1008
 
        while len(pending) > 0:
1009
 
            new_pending = set()
1010
 
            for file_id in pending:
1011
 
                for tree in trees:
1012
 
                    if file_id not in tree:
1013
 
                        continue
1014
 
                    entry = tree.inventory[file_id]
1015
 
                    for child in getattr(entry, 'children', {}).itervalues():
1016
 
                        if child.file_id not in interesting_ids:
1017
 
                            new_pending.add(child.file_id)
1018
 
            interesting_ids.update(new_pending)
1019
 
            pending = new_pending
1020
 
    return interesting_ids
 
1003
    return tree.find_ids_across_trees(filenames, trees)
1021
1004
 
1022
1005
 
1023
1006
def change_entry(tt, file_id, working_tree, target_tree,