~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-07 15:22:42 UTC
  • mfrom: (1843 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1846.
  • Revision ID: john@arbash-meinel.com-20060707152242-a7b5e0afd64d9d5a
[merge] bzr.dev 1843

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):
987
999
 
988
1000
def find_interesting(working_tree, target_tree, filenames):
989
1001
    """Find the ids corresponding to specified filenames."""
990
 
    if not filenames:
991
 
        interesting_ids = None
992
 
    else:
993
 
        interesting_ids = set()
994
 
        for tree_path in filenames:
995
 
            not_found = True
996
 
            for tree in (working_tree, target_tree):
997
 
                file_id = tree.inventory.path2id(tree_path)
998
 
                if file_id is not None:
999
 
                    interesting_ids.add(file_id)
1000
 
                    not_found = False
1001
 
            if not_found:
1002
 
                raise NotVersionedError(path=tree_path)
1003
 
    return interesting_ids
 
1002
    trees = (working_tree, target_tree)
 
1003
    return tree.find_ids_across_trees(filenames, trees)
1004
1004
 
1005
1005
 
1006
1006
def change_entry(tt, file_id, working_tree, target_tree,