Rev 2749: Add Repository.base on all repositories. in http://sourcefrog.net/bzr/pack-repository
Martin Pool
mbp at sourcefrog.net
Tue Aug 28 11:56:42 BST 2007
At http://sourcefrog.net/bzr/pack-repository
------------------------------------------------------------
revno: 2749
revision-id: mbp at sourcefrog.net-20070828105641-pd0vwkmeop9e09rf
parent: mbp at sourcefrog.net-20070828102850-a8qyqtb948y43rth
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: pack-repository
timestamp: Tue 2007-08-28 20:56:41 +1000
message:
Add Repository.base on all repositories.
Repository.has_same_location now *just* checks the location, not the class -
this seems to fix problems in interaction between remote and vfs repositories.
Add str and repr on RemoteRepository.
RemoteRepository.fetch shortcircuits when given two repositories at the same
location, which is required by the underlying fetch code.
modified:
bzrlib/fetch.py fetch.py-20050818234941-26fea6105696365d
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py 2007-08-28 10:28:50 +0000
+++ b/bzrlib/fetch.py 2007-08-28 10:56:41 +0000
@@ -72,7 +72,7 @@
after running:
count_copied -- number of revisions copied
- This should not be used directory, its essential a object to encapsulate
+ This should not be used directly, it's essential a object to encapsulate
the logic in InterRepository.fetch().
"""
def __init__(self, to_repository, from_repository, last_revision=None, pb=None):
@@ -81,8 +81,9 @@
self.count_copied = 0
if to_repository.has_same_location(from_repository):
# repository.fetch should be taking care of this case.
- raise errors.BzrError('unreachable code - Interrepository fetch'
- 'asked to fetch between two objects at the same location: '
+ import pdb;pdb.set_trace()
+ raise errors.BzrError('RepoFetcher run '
+ 'between two objects at the same location: '
'%r and %r' % (to_repository, from_repository))
self.to_repository = to_repository
self.from_repository = from_repository
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2007-08-22 06:30:25 +0000
+++ b/bzrlib/remote.py 2007-08-28 10:56:41 +0000
@@ -254,6 +254,12 @@
self._leave_lock = False
# for tests
self._reconcile_does_inventory_gc = True
+ self.base = self.bzrdir.transport.base
+
+ def __str__(self):
+ return "%s(%s)" % (self.__class__.__name__, self.base)
+
+ __repr__ = __str__
def abort_write_group(self):
"""Complete a write group on the decorated repository.
@@ -328,8 +334,7 @@
return response[0] == 'yes'
def has_same_location(self, other):
- return (self.__class__ == other.__class__ and
- self.bzrdir.transport.base == other.bzrdir.transport.base)
+ return (self.base == other.base)
def get_graph(self, other_repository=None):
"""Return the graph for this repository format"""
@@ -587,6 +592,8 @@
def fetch(self, source, revision_id=None, pb=None):
self._ensure_real()
+ if self.has_same_location(source) or source.has_same_location(self):
+ return 0, []
return self._real_repository.fetch(
source, revision_id=revision_id, pb=pb)
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-08-28 10:26:38 +0000
+++ b/bzrlib/repository.py 2007-08-28 10:56:41 +0000
@@ -260,10 +260,11 @@
# on whether escaping is required.
self._warn_if_deprecated()
self._write_group = None
+ self.base = control_files._transport.base
def __repr__(self):
- return '%s(%r)' % (self.__class__.__name__,
- self.bzrdir.transport.base)
+ return '%s(%r)' % (self.__class__.__name__,
+ self.base)
def has_same_location(self, other):
"""Returns a boolean indicating if this repository is at the same
@@ -272,10 +273,9 @@
This might return False even when two repository objects are accessing
the same physical repository via different URLs.
"""
- if self.__class__ is not other.__class__:
- return False
- return (self.control_files._transport.base ==
- other.control_files._transport.base)
+ ## if self.__class__ is not other.__class__:
+ ## return False
+ return (self.base == other.base)
def is_in_write_group(self):
"""Return True if there is an open write group.
More information about the bazaar-commits
mailing list