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

  • Committer: Robert Collins
  • Date: 2007-03-25 08:59:56 UTC
  • mto: (2376.3.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2401.
  • Revision ID: robertc@robertcollins.net-20070325085956-my8jv7cifqzyltyz
New SmartServer hooks facility. There are two initial hooks documented
in bzrlib.transport.smart.SmartServerHooks. The two initial hooks allow
plugins to execute code upon server startup and shutdown.
(Robert Collins).

SmartServer in standalone mode will now close its listening socket
when it stops, rather than waiting for garbage collection. This primarily
fixes test suite hangs when a test tries to connect to a shutdown server.
It may also help improve behaviour when dealing with a server running
on a specific port (rather than dynamically assigned ports).
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 
 
17
 
"""An adapter between a Git index and a Bazaar Working Tree"""
18
 
 
19
 
from dulwich.index import (
20
 
    Index,
21
 
    )
22
 
import os
23
 
 
24
 
from bzrlib import (
25
 
    inventory,
26
 
    lockable_files,
27
 
    lockdir,
28
 
    transport,
29
 
    urlutils,
30
 
    workingtree,
31
 
    )
32
 
 
33
 
class GitWorkingTree(workingtree.WorkingTree):
34
 
    """A Git working tree."""
35
 
 
36
 
    def __init__(self, bzrdir, repo, branch):
37
 
        self.basedir = bzrdir.transport.base
38
 
        self.bzrdir = bzrdir
39
 
        self.repository = repo
40
 
        self._branch = branch
41
 
        self._transport = bzrdir.transport
42
 
 
43
 
        self.controldir = urlutils.join(self.repository._git.path, 'bzr')
44
 
 
45
 
        try:
46
 
            os.makedirs(self.controldir)
47
 
            os.makedirs(os.path.join(self.controldir, 'lock'))
48
 
        except OSError:
49
 
            pass
50
 
 
51
 
        self._control_files = lockable_files.LockableFiles(
52
 
            transport.get_transport(self.controldir), 'lock', lockdir.LockDir)
53
 
 
54
 
        self._format = GitWorkingTreeFormat()
55
 
 
56
 
        self.index = Index(os.path.join(self.repository._git.controldir(), 
57
 
            "index"))
58
 
        self.views = self._make_views()
59
 
 
60
 
    def unlock(self):
61
 
        # non-implementation specific cleanup
62
 
        self._cleanup()
63
 
 
64
 
        # reverse order of locking.
65
 
        try:
66
 
            return self._control_files.unlock()
67
 
        finally:
68
 
            self.branch.unlock()
69
 
 
70
 
    def is_control_filename(self, path):
71
 
        return os.path.basename(path) == ".git"
72
 
 
73
 
    def _get_inventory(self):
74
 
        return inventory.Inventory()
75
 
 
76
 
    inventory = property(_get_inventory,
77
 
                         doc="Inventory of this Tree")
78
 
 
79
 
 
80
 
class GitWorkingTreeFormat(workingtree.WorkingTreeFormat):
81
 
 
82
 
    def get_format_description(self):
83
 
        return "Git Working Tree"