~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2006-03-10 06:29:53 UTC
  • mfrom: (1608 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060310062953-bc1c7ade75c89a7a
[merge] bzr.dev; pycurl not updated for readv yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
 
 
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
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
23
23
import sys
24
24
from unittest import TestSuite
25
25
from warnings import warn
26
 
try:
27
 
    import xml.sax.saxutils
28
 
except ImportError:
29
 
    raise ImportError("We were unable to import 'xml.sax.saxutils',"
30
 
                      " most likely you have an xml.pyc or xml.pyo file"
31
 
                      " lying around in your bzrlib directory."
32
 
                      " Please remove it.")
33
 
 
34
26
 
35
27
import bzrlib
36
28
import bzrlib.bzrdir as bzrdir
48
40
import bzrlib.inventory as inventory
49
41
from bzrlib.inventory import Inventory
50
42
from bzrlib.lockable_files import LockableFiles, TransportLock
 
43
from bzrlib.lockdir import LockDir
51
44
from bzrlib.osutils import (isdir, quotefn,
52
45
                            rename, splitpath, sha_file,
53
46
                            file_kind, abspath, normpath, pathjoin,
207
200
            raise Exception("can't fetch from a branch to itself %s, %s" % 
208
201
                            (self.base, to_branch.base))
209
202
        if pb is None:
210
 
            pb = bzrlib.ui.ui_factory.progress_bar()
 
203
            nested_pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
204
            pb = nested_pb
 
205
        else:
 
206
            nested_pb = None
211
207
 
212
208
        from_branch.lock_read()
213
209
        try:
221
217
                    last_revision = NULL_REVISION
222
218
            return self.repository.fetch(from_branch.repository,
223
219
                                         revision_id=last_revision,
224
 
                                         pb=pb)
 
220
                                         pb=nested_pb)
225
221
        finally:
 
222
            if nested_pb is not None:
 
223
                nested_pb.finished()
226
224
            from_branch.unlock()
227
225
 
228
226
    def get_bound_location(self):
655
653
    This format has:
656
654
     - a revision-history file.
657
655
     - a format string
658
 
     - a lock file.
 
656
     - a lock dir guarding the branch itself
 
657
     - all of this stored in a branch/ subdirectory
659
658
     - works with shared repositories.
 
659
 
 
660
    This format is new in bzr 0.8.
660
661
    """
661
662
 
662
663
    def get_format_string(self):
665
666
        
666
667
    def initialize(self, a_bzrdir):
667
668
        """Create a branch of this format in a_bzrdir."""
668
 
        mutter('creating branch in %s', a_bzrdir.transport.base)
 
669
        mutter('creating branch %r in %s', self, a_bzrdir.transport.base)
669
670
        branch_transport = a_bzrdir.get_branch_transport(self)
670
 
 
671
671
        utf8_files = [('revision-history', ''),
672
672
                      ('branch-name', ''),
673
673
                      ]
674
 
        control_files = LockableFiles(branch_transport, 'lock', TransportLock)
 
674
        control_files = LockableFiles(branch_transport, 'lock', LockDir)
675
675
        control_files.create_lock()
676
676
        control_files.lock_write()
677
677
        control_files.put_utf8('format', self.get_format_string())
696
696
            format = BranchFormat.find_format(a_bzrdir)
697
697
            assert format.__class__ == self.__class__
698
698
        transport = a_bzrdir.get_branch_transport(None)
699
 
        control_files = LockableFiles(transport, 'lock', TransportLock)
 
699
        control_files = LockableFiles(transport, 'lock', LockDir)
700
700
        return BzrBranch5(_format=self,
701
701
                          _control_files=control_files,
702
702
                          a_bzrdir=a_bzrdir,
961
961
        """See Branch.set_revision_history."""
962
962
        self.control_files.put_utf8(
963
963
            'revision-history', '\n'.join(rev_history))
 
964
        transaction = self.get_transaction()
 
965
        history = transaction.map.find_revision_history()
 
966
        if history is not None:
 
967
            # update the revision history in the identity map.
 
968
            history[:] = list(rev_history)
 
969
            # this call is disabled because revision_history is 
 
970
            # not really an object yet, and the transaction is for objects.
 
971
            # transaction.register_dirty(history)
 
972
        else:
 
973
            transaction.map.add_revision_history(rev_history)
 
974
            # this call is disabled because revision_history is 
 
975
            # not really an object yet, and the transaction is for objects.
 
976
            # transaction.register_clean(history)
964
977
 
965
978
    def get_revision_delta(self, revno):
966
979
        """Return the delta for one revision.
985
998
    @needs_read_lock
986
999
    def revision_history(self):
987
1000
        """See Branch.revision_history."""
988
 
        # FIXME are transactions bound to control files ? RBC 20051121
989
1001
        transaction = self.get_transaction()
990
1002
        history = transaction.map.find_revision_history()
991
1003
        if history is not None: