/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Robert Collins
  • Date: 2006-08-08 23:19:29 UTC
  • mfrom: (1884 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1912.
  • Revision ID: robertc@robertcollins.net-20060808231929-4e3e298190214b3a
current status

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):
539
551
        if child_id is None:
540
552
            return lexists(self._tree.abspath(childpath))
541
553
        else:
542
 
            if tt.final_parent(child_id) != parent_id:
 
554
            if self.final_parent(child_id) != parent_id:
543
555
                return False
544
 
            if child_id in tt._removed_contents:
 
556
            if child_id in self._removed_contents:
545
557
                # XXX What about dangling file-ids?
546
558
                return False
547
559
            else:
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, 
1066
1066
    try:
1067
1067
        working_kind = working_tree.kind(file_id)
1068
1068
        has_contents = True
1069
 
    except OSError, e:
1070
 
        if e.errno != errno.ENOENT:
1071
 
            raise
 
1069
    except NoSuchFile:
1072
1070
        has_contents = False
1073
1071
        contents_mod = True
1074
1072
        meta_mod = False