/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 commit.py

More work on commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
 
 
18
"""Support for committing in native Git working trees."""
 
19
 
 
20
 
 
21
import stat
 
22
 
 
23
from bzrlib import (
 
24
    osutils,
 
25
    )
17
26
from bzrlib.repository import (
18
27
    CommitBuilder,
19
28
    )
30
39
        super(GitCommitBuilder, self).__init__(*args, **kwargs)
31
40
        self._trees = {}
32
41
 
 
42
    def _new_tree(self, path):
 
43
        newtree = Tree()
 
44
        # FIXME: Inherit children from the base revision
 
45
        self._trees[path] = newtree
 
46
        return newtree
 
47
 
33
48
    def _add_tree(self, path):
 
49
        if path in self._trees:
 
50
            return self._trees[path]
 
51
        if path == "":
 
52
            return self._new_tree("")
34
53
        dirname, basename = osutils.split(path)
35
54
        t = self._add_tree(dirname)
 
55
        assert isinstance(basename, str)
36
56
        if not basename in t:
37
 
            t[basename] = Tree()
38
 
            # FIXME: Inherit children from the base revision
39
 
        return t[basename]
 
57
            newtree = self._new_tree(path)
 
58
            t[basename] = (stat.S_IFDIR, newtree.id)
 
59
            return newtree
 
60
        else:
 
61
            return self.repository._git.object_store[t[basename][1]]
40
62
 
41
63
    def _change_blob(self, path, value):
 
64
        assert isinstance(path, str)
42
65
        dirname, basename = osutils.split(path)
43
66
        t = self._add_tree(dirname)
44
67
        t[basename] = value
61
84
                mode = stat.S_IFLNK
62
85
            if executable:
63
86
                mode |= 0111
64
 
            self._change_blob(path, (mode, workingtree.index.get_sha1(path)))
65
 
            yield file_id, path, None
 
87
            self._change_blob(path[1].encode("utf-8"), (mode, workingtree.index.get_sha1(path[1].encode("utf-8"))))
 
88
            yield file_id, path, (None, None)
66
89
 
67
90
    def commit(self, message):
68
91
        # FIXME: Eliminate any empty trees recursively