Merge lp:~jelmer/brz/depth into lp:brz

Proposed by Jelmer Vernooij
Status: Superseded
Proposed branch: lp:~jelmer/brz/depth
Merge into: lp:brz
Diff against target: 900 lines (+214/-111)
18 files modified
breezy/branch.py (+8/-4)
breezy/bzr/bzrdir.py (+7/-3)
breezy/controldir.py (+2/-1)
breezy/errors.py (+8/-0)
breezy/git/branch.py (+11/-11)
breezy/git/dir.py (+3/-2)
breezy/git/interrepo.py (+48/-37)
breezy/git/remote.py (+13/-11)
breezy/git/repository.py (+1/-0)
breezy/git/tests/test_blackbox.py (+1/-0)
breezy/git/transportgit.py (+40/-35)
breezy/plugins/weave_fmt/bzrdir.py (+3/-1)
breezy/repository.py (+4/-0)
breezy/tests/per_controldir/test_controldir.py (+17/-2)
breezy/tests/per_interbranch/test_fetch.py (+41/-1)
breezy/tests/per_repository/test_repository.py (+3/-0)
breezy/tests/test_foreign.py (+3/-2)
setup.py (+1/-1)
To merge this branch: bzr merge lp:~jelmer/brz/depth
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+362957@code.launchpad.net

This proposal has been superseded by a proposal from 2019-02-14.

Description of the change

Add a depth argument to ControlDir.sprout() and Repository.fetch().

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve
lp:~jelmer/brz/depth updated
7154. By Jelmer Vernooij

Fix tests.

7155. By Jelmer Vernooij

Merge lp:brz/3.1.

7156. By Jelmer Vernooij

Merge lp:brz/3.2.

7157. By Jelmer Vernooij

Merge trunk.

7158. By Jelmer Vernooij

Merge lp:brz/3.3

Unmerged revisions

7158. By Jelmer Vernooij

Merge lp:brz/3.3

7157. By Jelmer Vernooij

Merge trunk.

7156. By Jelmer Vernooij

Merge lp:brz/3.2.

7155. By Jelmer Vernooij

Merge lp:brz/3.1.

7154. By Jelmer Vernooij

Fix tests.

7153. By Jelmer Vernooij

add depth argument to ControlDir.sprout.

7152. By Jelmer Vernooij

Enable depth fetching for Git repositories.

7151. By Jelmer Vernooij

For the moment, Dulwich doesn't support depth fetching locally.

7150. By Jelmer Vernooij

Add Repository.support_fetch_depth.

7149. By Jelmer Vernooij

Merge dulwich-compat.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/branch.py'
--- breezy/branch.py 2018-11-30 12:39:04 +0000
+++ breezy/branch.py 2019-02-11 01:23:45 +0000
@@ -680,18 +680,19 @@
680 """Get the tree_path and branch_location for a tree reference."""680 """Get the tree_path and branch_location for a tree reference."""
681 raise errors.UnsupportedOperation(self.get_reference_info, self)681 raise errors.UnsupportedOperation(self.get_reference_info, self)
682682
683 def fetch(self, from_branch, last_revision=None, limit=None):683 def fetch(self, from_branch, last_revision=None, limit=None, depth=None):
684 """Copy revisions from from_branch into this branch.684 """Copy revisions from from_branch into this branch.
685685
686 :param from_branch: Where to copy from.686 :param from_branch: Where to copy from.
687 :param last_revision: What revision to stop at (None for at the end687 :param last_revision: What revision to stop at (None for at the end
688 of the branch.688 of the branch.
689 :param limit: Optional rough limit of revisions to fetch689 :param limit: Optional rough limit of revisions to fetch
690 :param depth: Revision depth
690 :return: None691 :return: None
691 """692 """
692 with self.lock_write():693 with self.lock_write():
693 return InterBranch.get(from_branch, self).fetch(694 return InterBranch.get(from_branch, self).fetch(
694 last_revision, limit=limit)695 last_revision, limit=limit, depth=depth)
695696
696 def get_bound_location(self):697 def get_bound_location(self):
697 """Return the URL of the branch we are bound to.698 """Return the URL of the branch we are bound to.
@@ -2098,11 +2099,12 @@
2098 """2099 """
2099 raise NotImplementedError(self.copy_content_into)2100 raise NotImplementedError(self.copy_content_into)
21002101
2101 def fetch(self, stop_revision=None, limit=None):2102 def fetch(self, stop_revision=None, limit=None, depth=None):
2102 """Fetch revisions.2103 """Fetch revisions.
21032104
2104 :param stop_revision: Last revision to fetch2105 :param stop_revision: Last revision to fetch
2105 :param limit: Optional rough limit of revisions to fetch2106 :param limit: Optional rough limit of revisions to fetch
2107 :param depth: Optional revision depth
2106 """2108 """
2107 raise NotImplementedError(self.fetch)2109 raise NotImplementedError(self.fetch)
21082110
@@ -2154,9 +2156,11 @@
2154 if self.source._push_should_merge_tags():2156 if self.source._push_should_merge_tags():
2155 self.source.tags.merge_to(self.target.tags)2157 self.source.tags.merge_to(self.target.tags)
21562158
2157 def fetch(self, stop_revision=None, limit=None):2159 def fetch(self, stop_revision=None, limit=None, depth=None):
2158 if self.target.base == self.source.base:2160 if self.target.base == self.source.base:
2159 return (0, [])2161 return (0, [])
2162 if depth is not None:
2163 raise errors.FetchDepthUnsupported(self)
2160 with self.source.lock_read(), self.target.lock_write():2164 with self.source.lock_read(), self.target.lock_write():
2161 fetch_spec_factory = fetch.FetchSpecFactory()2165 fetch_spec_factory = fetch.FetchSpecFactory()
2162 fetch_spec_factory.source_branch = self.source2166 fetch_spec_factory.source_branch = self.source
21632167
=== modified file 'breezy/bzr/bzrdir.py'
--- breezy/bzr/bzrdir.py 2018-11-18 19:48:57 +0000
+++ breezy/bzr/bzrdir.py 2019-02-11 01:23:45 +0000
@@ -350,7 +350,7 @@
350 recurse='down', possible_transports=None,350 recurse='down', possible_transports=None,
351 accelerator_tree=None, hardlink=False, stacked=False,351 accelerator_tree=None, hardlink=False, stacked=False,
352 source_branch=None, create_tree_if_local=True,352 source_branch=None, create_tree_if_local=True,
353 lossy=False):353 depth=None):
354 """Create a copy of this controldir prepared for use as a new line of354 """Create a copy of this controldir prepared for use as a new line of
355 development.355 development.
356356
@@ -374,6 +374,7 @@
374 location of this control directory.374 location of this control directory.
375 :param create_tree_if_local: If true, a working-tree will be created375 :param create_tree_if_local: If true, a working-tree will be created
376 when working locally.376 when working locally.
377 :param depth: Optional fetch depth
377 :return: The created control directory378 :return: The created control directory
378 """379 """
379 operation = cleanup.OperationWithCleanups(self._sprout)380 operation = cleanup.OperationWithCleanups(self._sprout)
@@ -382,12 +383,15 @@
382 recurse=recurse, possible_transports=possible_transports,383 recurse=recurse, possible_transports=possible_transports,
383 accelerator_tree=accelerator_tree, hardlink=hardlink,384 accelerator_tree=accelerator_tree, hardlink=hardlink,
384 stacked=stacked, source_branch=source_branch,385 stacked=stacked, source_branch=source_branch,
385 create_tree_if_local=create_tree_if_local)386 create_tree_if_local=create_tree_if_local, depth=depth)
386387
387 def _sprout(self, op, url, revision_id=None, force_new_repo=False,388 def _sprout(self, op, url, revision_id=None, force_new_repo=False,
388 recurse='down', possible_transports=None,389 recurse='down', possible_transports=None,
389 accelerator_tree=None, hardlink=False, stacked=False,390 accelerator_tree=None, hardlink=False, stacked=False,
390 source_branch=None, create_tree_if_local=True, lossy=False):391 source_branch=None, create_tree_if_local=True,
392 depth=None):
393 if depth is not None:
394 raise errors.FetchDepthUnsupported(self)
391 add_cleanup = op.add_cleanup395 add_cleanup = op.add_cleanup
392 fetch_spec_factory = fetch.FetchSpecFactory()396 fetch_spec_factory = fetch.FetchSpecFactory()
393 if revision_id is not None:397 if revision_id is not None:
394398
=== modified file 'breezy/controldir.py'
--- breezy/controldir.py 2018-11-12 01:41:38 +0000
+++ breezy/controldir.py 2019-02-11 01:23:45 +0000
@@ -373,7 +373,7 @@
373 recurse='down', possible_transports=None,373 recurse='down', possible_transports=None,
374 accelerator_tree=None, hardlink=False, stacked=False,374 accelerator_tree=None, hardlink=False, stacked=False,
375 source_branch=None, create_tree_if_local=True,375 source_branch=None, create_tree_if_local=True,
376 lossy=False):376 depth=None):
377 """Create a copy of this controldir prepared for use as a new line of377 """Create a copy of this controldir prepared for use as a new line of
378 development.378 development.
379379
@@ -396,6 +396,7 @@
396 location of this control directory.396 location of this control directory.
397 :param create_tree_if_local: If true, a working-tree will be created397 :param create_tree_if_local: If true, a working-tree will be created
398 when working locally.398 when working locally.
399 :param depth: Possible fetch depth
399 """400 """
400 raise NotImplementedError(self.sprout)401 raise NotImplementedError(self.sprout)
401402
402403
=== modified file 'breezy/errors.py'
--- breezy/errors.py 2018-11-11 04:08:32 +0000
+++ breezy/errors.py 2019-02-11 01:23:45 +0000
@@ -1851,6 +1851,14 @@
1851 self.tname = type(method_self).__name__1851 self.tname = type(method_self).__name__
18521852
18531853
1854class FetchDepthUnsupported(UnsupportedOperation):
1855
1856 fmt = ("InterBranch %(interbranch)r does not support fetching depths.")
1857
1858 def __init__(self, interbranch):
1859 BzrError.__init__(self, interbranch=interbranch)
1860
1861
1854class FetchLimitUnsupported(UnsupportedOperation):1862class FetchLimitUnsupported(UnsupportedOperation):
18551863
1856 fmt = ("InterBranch %(interbranch)r does not support fetching limits.")1864 fmt = ("InterBranch %(interbranch)r does not support fetching limits.")
18571865
=== modified file 'breezy/git/branch.py'
--- breezy/git/branch.py 2019-01-19 17:13:53 +0000
+++ breezy/git/branch.py 2019-02-11 01:23:45 +0000
@@ -656,9 +656,9 @@
656 def break_lock(self):656 def break_lock(self):
657 self.repository._git.refs.unlock_ref(self.ref)657 self.repository._git.refs.unlock_ref(self.ref)
658658
659 def fetch(self, from_branch, last_revision=None, limit=None):659 def fetch(self, from_branch, last_revision=None, limit=None, depth=None):
660 return branch.InterBranch.get(from_branch, self).fetch(660 return branch.InterBranch.get(from_branch, self).fetch(
661 stop_revision=last_revision, limit=limit)661 stop_revision=last_revision, limit=limit, depth=depth)
662662
663 def _gen_revision_history(self):663 def _gen_revision_history(self):
664 if self.head is None:664 if self.head is None:
@@ -885,10 +885,10 @@
885 return False885 return False
886 return True886 return True
887887
888 def fetch(self, stop_revision=None, fetch_tags=None, limit=None):888 def fetch(self, stop_revision=None, fetch_tags=None, limit=None, depth=None):
889 self.fetch_objects(stop_revision, fetch_tags=fetch_tags, limit=limit)889 self.fetch_objects(stop_revision, fetch_tags=fetch_tags, limit=limit, depth=depth)
890890
891 def fetch_objects(self, stop_revision, fetch_tags, limit=None):891 def fetch_objects(self, stop_revision, fetch_tags, limit=None, depth=None):
892 interrepo = self._get_interrepo(self.source, self.target)892 interrepo = self._get_interrepo(self.source, self.target)
893 if fetch_tags is None:893 if fetch_tags is None:
894 c = self.source.get_config_stack()894 c = self.source.get_config_stack()
@@ -909,7 +909,7 @@
909 [self._last_revid], include_tags=fetch_tags)909 [self._last_revid], include_tags=fetch_tags)
910 return real(heads)910 return real(heads)
911 pack_hint, head, refs = interrepo.fetch_objects(911 pack_hint, head, refs = interrepo.fetch_objects(
912 determine_wants, self.source.mapping, limit=limit)912 determine_wants, self.source.mapping, limit=limit, depth=depth)
913 if (pack_hint is not None and913 if (pack_hint is not None and
914 self.target.repository._format.pack_compresses):914 self.target.repository._format.pack_compresses):
915 self.target.repository.pack(hint=pack_hint)915 self.target.repository.pack(hint=pack_hint)
@@ -1034,7 +1034,7 @@
1034class InterGitBranch(branch.GenericInterBranch):1034class InterGitBranch(branch.GenericInterBranch):
1035 """InterBranch implementation that pulls between Git branches."""1035 """InterBranch implementation that pulls between Git branches."""
10361036
1037 def fetch(self, stop_revision=None, fetch_tags=None, limit=None):1037 def fetch(self, stop_revision=None, fetch_tags=None, limit=None, depth=None):
1038 raise NotImplementedError(self.fetch)1038 raise NotImplementedError(self.fetch)
10391039
10401040
@@ -1101,14 +1101,14 @@
1101 return (isinstance(source, GitBranch) and1101 return (isinstance(source, GitBranch) and
1102 isinstance(target, LocalGitBranch))1102 isinstance(target, LocalGitBranch))
11031103
1104 def fetch(self, stop_revision=None, fetch_tags=None, limit=None):1104 def fetch(self, stop_revision=None, fetch_tags=None, limit=None, depth=None):
1105 interrepo = _mod_repository.InterRepository.get(self.source.repository,1105 interrepo = _mod_repository.InterRepository.get(self.source.repository,
1106 self.target.repository)1106 self.target.repository)
1107 if stop_revision is None:1107 if stop_revision is None:
1108 stop_revision = self.source.last_revision()1108 stop_revision = self.source.last_revision()
1109 determine_wants = interrepo.get_determine_wants_revids(1109 determine_wants = interrepo.get_determine_wants_revids(
1110 [stop_revision], include_tags=fetch_tags)1110 [stop_revision], include_tags=fetch_tags)
1111 interrepo.fetch_objects(determine_wants, limit=limit)1111 interrepo.fetch_objects(determine_wants, limit=limit, depth=depth)
11121112
1113 def _basic_push(self, overwrite=False, stop_revision=None):1113 def _basic_push(self, overwrite=False, stop_revision=None):
1114 if overwrite is True:1114 if overwrite is True:
@@ -1298,7 +1298,7 @@
1298 return ret1298 return ret
12991299
1300 def fetch(self, stop_revision=None, fetch_tags=None, lossy=False,1300 def fetch(self, stop_revision=None, fetch_tags=None, lossy=False,
1301 limit=None):1301 limit=None, depth=None):
1302 if stop_revision is None:1302 if stop_revision is None:
1303 stop_revision = self.source.last_revision()1303 stop_revision = self.source.last_revision()
1304 ret = []1304 ret = []
@@ -1307,7 +1307,7 @@
1307 ret.append((None, v))1307 ret.append((None, v))
1308 ret.append((None, stop_revision))1308 ret.append((None, stop_revision))
1309 try:1309 try:
1310 self.interrepo.fetch_objects(ret, lossy=lossy, limit=limit)1310 self.interrepo.fetch_objects(ret, lossy=lossy, limit=limit, depth=depth)
1311 except NoPushSupport:1311 except NoPushSupport:
1312 raise errors.NoRoundtrippingSupport(self.source, self.target)1312 raise errors.NoRoundtrippingSupport(self.source, self.target)
13131313
13141314
=== modified file 'breezy/git/dir.py'
--- breezy/git/dir.py 2018-11-16 11:37:47 +0000
+++ breezy/git/dir.py 2019-02-11 01:23:45 +0000
@@ -149,7 +149,7 @@
149 def sprout(self, url, revision_id=None, force_new_repo=False,149 def sprout(self, url, revision_id=None, force_new_repo=False,
150 recurse='down', possible_transports=None,150 recurse='down', possible_transports=None,
151 accelerator_tree=None, hardlink=False, stacked=False,151 accelerator_tree=None, hardlink=False, stacked=False,
152 source_branch=None, create_tree_if_local=True):152 source_branch=None, create_tree_if_local=True, depth=None):
153 from ..repository import InterRepository153 from ..repository import InterRepository
154 from ..transport.local import LocalTransport154 from ..transport.local import LocalTransport
155 from ..transport import get_transport155 from ..transport import get_transport
@@ -178,7 +178,8 @@
178 else:178 else:
179 determine_wants = interrepo.determine_wants_all179 determine_wants = interrepo.determine_wants_all
180 interrepo.fetch_objects(determine_wants=determine_wants,180 interrepo.fetch_objects(determine_wants=determine_wants,
181 mapping=source_branch.mapping)181 mapping=source_branch.mapping,
182 depth=depth)
182 result_branch = source_branch.sprout(183 result_branch = source_branch.sprout(
183 result, revision_id=revision_id, repository=result_repo)184 result, revision_id=revision_id, repository=result_repo)
184 if (create_tree_if_local and185 if (create_tree_if_local and
185186
=== modified file 'breezy/git/interrepo.py'
--- breezy/git/interrepo.py 2018-11-16 23:15:15 +0000
+++ breezy/git/interrepo.py 2019-02-11 01:23:45 +0000
@@ -39,6 +39,7 @@
3939
40from ..errors import (40from ..errors import (
41 DivergedBranches,41 DivergedBranches,
42 FetchDepthUnsupported,
42 FetchLimitUnsupported,43 FetchLimitUnsupported,
43 InvalidRevisionId,44 InvalidRevisionId,
44 LossyPushToSameVCS,45 LossyPushToSameVCS,
@@ -53,6 +54,7 @@
53 )54 )
54from ..sixish import (55from ..sixish import (
55 viewitems,56 viewitems,
57 viewkeys,
56 viewvalues,58 viewvalues,
57 )59 )
58from .. import (60from .. import (
@@ -124,9 +126,9 @@
124 """126 """
125 raise NotImplementedError(self.fetch_refs)127 raise NotImplementedError(self.fetch_refs)
126128
127 def search_missing_revision_ids(self,129 def search_missing_revision_ids(
128 find_ghosts=True, revision_ids=None,130 self, find_ghosts=True, revision_ids=None, if_present_ids=None,
129 if_present_ids=None, limit=None):131 limit=None, depth=None):
130 if limit is not None:132 if limit is not None:
131 raise FetchLimitUnsupported(self)133 raise FetchLimitUnsupported(self)
132 git_shas = []134 git_shas = []
@@ -190,7 +192,7 @@
190 return False192 return False
191 return self._commit_needs_fetching(sha_id)193 return self._commit_needs_fetching(sha_id)
192194
193 def missing_revisions(self, stop_revisions):195 def _missing_revisions(self, stop_revisions, depth=None):
194 """Find the revisions that are missing from the target repository.196 """Find the revisions that are missing from the target repository.
195197
196 :param stop_revisions: Revisions to check for (tuples with198 :param stop_revisions: Revisions to check for (tuples with
@@ -204,32 +206,35 @@
204 for (sha1, revid) in stop_revisions:206 for (sha1, revid) in stop_revisions:
205 if sha1 is not None and revid is not None:207 if sha1 is not None and revid is not None:
206 revid_sha_map[revid] = sha1208 revid_sha_map[revid] = sha1
207 stop_revids.append(revid)209 stop_revids.append((revid, 1))
208 elif sha1 is not None:210 elif sha1 is not None:
209 if self._commit_needs_fetching(sha1):211 if self._commit_needs_fetching(sha1):
210 for (kind, (revid, tree_sha, verifiers)) in self.source_store.lookup_git_sha(sha1):212 for (kind, (revid, tree_sha, verifiers)) in self.source_store.lookup_git_sha(sha1):
211 revid_sha_map[revid] = sha1213 revid_sha_map[revid] = sha1
212 stop_revids.append(revid)214 stop_revids.append((revid, 1))
213 else:215 else:
214 if revid is None:216 if revid is None:
215 raise AssertionError217 raise AssertionError
216 stop_revids.append(revid)218 stop_revids.append((revid, 1))
217 missing = set()219 missing = set()
218 graph = self.source.get_graph()220 graph = self.source.get_graph()
219 pb = ui.ui_factory.nested_progress_bar()221 pb = ui.ui_factory.nested_progress_bar()
220 try:222 try:
221 while stop_revids:223 while stop_revids:
222 new_stop_revids = []224 new_stop_revids = {}
223 for revid in stop_revids:225 for revid, revid_depth in stop_revids:
224 sha1 = revid_sha_map.get(revid)226 sha1 = revid_sha_map.get(revid)
225 if (revid not in missing and227 if (revid not in missing and
226 self._revision_needs_fetching(sha1, revid)):228 self._revision_needs_fetching(sha1, revid)):
227 missing.add(revid)229 missing.add(revid)
228 new_stop_revids.append(revid)230 if depth is None or revid_depth < depth:
231 new_stop_revids[revid] = revid_depth
229 stop_revids = set()232 stop_revids = set()
230 parent_map = graph.get_parent_map(new_stop_revids)233 parent_map = graph.get_parent_map(viewkeys(new_stop_revids))
231 for parent_revids in viewvalues(parent_map):234 for revid, parent_revids in viewvalues(parent_map):
232 stop_revids.update(parent_revids)235 stop_revids.update(
236 [(parent_revid, new_stop_revids[revid] + 1)
237 for parent_revid in parent_revids])
233 pb.update("determining revisions to fetch", len(missing))238 pb.update("determining revisions to fetch", len(missing))
234 finally:239 finally:
235 pb.finished()240 pb.finished()
@@ -292,7 +297,7 @@
292 result_refs[name] = (gitid, revid if not lossy else self.mapping.revision_id_foreign_to_bzr(gitid))297 result_refs[name] = (gitid, revid if not lossy else self.mapping.revision_id_foreign_to_bzr(gitid))
293 return revidmap, old_refs, result_refs298 return revidmap, old_refs, result_refs
294299
295 def fetch_objects(self, revs, lossy, limit=None):300 def fetch_objects(self, revs, lossy, limit=None, depth=None):
296 if not lossy and not self.mapping.roundtripping:301 if not lossy and not self.mapping.roundtripping:
297 for git_sha, bzr_revid in revs:302 for git_sha, bzr_revid in revs:
298 if (bzr_revid is not None and303 if (bzr_revid is not None and
@@ -300,7 +305,7 @@
300 raise NoPushSupport(self.source, self.target, self.mapping,305 raise NoPushSupport(self.source, self.target, self.mapping,
301 bzr_revid)306 bzr_revid)
302 with self.source_store.lock_read():307 with self.source_store.lock_read():
303 todo = list(self.missing_revisions(revs))[:limit]308 todo = list(self._missing_revisions(revs, depth=depth))[:limit]
304 revidmap = {}309 revidmap = {}
305 pb = ui.ui_factory.nested_progress_bar()310 pb = ui.ui_factory.nested_progress_bar()
306 try:311 try:
@@ -325,7 +330,7 @@
325 pb.finished()330 pb.finished()
326331
327 def fetch(self, revision_id=None, pb=None, find_ghosts=False,332 def fetch(self, revision_id=None, pb=None, find_ghosts=False,
328 fetch_spec=None, mapped_refs=None):333 fetch_spec=None, mapped_refs=None, depth=None):
329 if mapped_refs is not None:334 if mapped_refs is not None:
330 stop_revisions = mapped_refs335 stop_revisions = mapped_refs
331 elif revision_id is not None:336 elif revision_id is not None:
@@ -342,7 +347,7 @@
342 for revid in self.source.all_revision_ids()]347 for revid in self.source.all_revision_ids()]
343 self._warn_slow()348 self._warn_slow()
344 try:349 try:
345 self.fetch_objects(stop_revisions, lossy=False)350 self.fetch_objects(stop_revisions, lossy=False, depth=depth)
346 except NoPushSupport:351 except NoPushSupport:
347 raise NoRoundtrippingSupport(self.source, self.target)352 raise NoRoundtrippingSupport(self.source, self.target)
348353
@@ -501,7 +506,8 @@
501 'Fetching from Git to Bazaar repository. '506 'Fetching from Git to Bazaar repository. '
502 'For better performance, fetch into a Git repository.')507 'For better performance, fetch into a Git repository.')
503508
504 def fetch_objects(self, determine_wants, mapping, limit=None, lossy=False):509 def fetch_objects(self, determine_wants, mapping, limit=None, lossy=False,
510 depth=None):
505 """Fetch objects from a remote server.511 """Fetch objects from a remote server.
506512
507 :param determine_wants: determine_wants callback513 :param determine_wants: determine_wants callback
@@ -522,7 +528,8 @@
522 return self.get_determine_wants_heads(wants, include_tags=include_tags)528 return self.get_determine_wants_heads(wants, include_tags=include_tags)
523529
524 def fetch(self, revision_id=None, find_ghosts=False,530 def fetch(self, revision_id=None, find_ghosts=False,
525 mapping=None, fetch_spec=None, include_tags=False):531 mapping=None, fetch_spec=None, include_tags=False,
532 depth=None):
526 if mapping is None:533 if mapping is None:
527 mapping = self.source.get_mapping()534 mapping = self.source.get_mapping()
528 if revision_id is not None:535 if revision_id is not None:
@@ -543,8 +550,8 @@
543 else:550 else:
544 determine_wants = self.determine_wants_all551 determine_wants = self.determine_wants_all
545552
546 (pack_hint, _, remote_refs) = self.fetch_objects(determine_wants,553 (pack_hint, _, remote_refs) = self.fetch_objects(
547 mapping)554 determine_wants, mapping, depth=depth)
548 if pack_hint is not None and self.target._format.pack_compresses:555 if pack_hint is not None and self.target._format.pack_compresses:
549 self.target.pack(hint=pack_hint)556 self.target.pack(hint=pack_hint)
550 return remote_refs557 return remote_refs
@@ -563,7 +570,8 @@
563 all_parents.update(values)570 all_parents.update(values)
564 return set(all_revs) - all_parents571 return set(all_revs) - all_parents
565572
566 def fetch_objects(self, determine_wants, mapping, limit=None, lossy=False):573 def fetch_objects(self, determine_wants, mapping, limit=None, lossy=False,
574 depth=None):
567 """See `InterGitNonGitRepository`."""575 """See `InterGitNonGitRepository`."""
568 self._warn_slow()576 self._warn_slow()
569 store = get_object_store(self.target, mapping)577 store = get_object_store(self.target, mapping)
@@ -577,7 +585,8 @@
577 pb = ui.ui_factory.nested_progress_bar()585 pb = ui.ui_factory.nested_progress_bar()
578 try:586 try:
579 objects_iter = self.source.fetch_objects(587 objects_iter = self.source.fetch_objects(
580 wants_recorder, graph_walker, store.get_raw)588 wants_recorder, graph_walker, store.get_raw,
589 depth=depth)
581 trace.mutter("Importing %d new revisions",590 trace.mutter("Importing %d new revisions",
582 len(wants_recorder.wants))591 len(wants_recorder.wants))
583 (pack_hint, last_rev) = import_git_objects(592 (pack_hint, last_rev) = import_git_objects(
@@ -605,22 +614,22 @@
605 """InterRepository that copies revisions from a local Git into a non-Git614 """InterRepository that copies revisions from a local Git into a non-Git
606 repository."""615 repository."""
607616
608 def fetch_objects(self, determine_wants, mapping, limit=None, lossy=False):617 def fetch_objects(self, determine_wants, mapping, limit=None, lossy=False,
618 depth=None):
609 """See `InterGitNonGitRepository`."""619 """See `InterGitNonGitRepository`."""
620 if depth is not None:
621 raise FetchDepthUnsupported(self)
610 self._warn_slow()622 self._warn_slow()
611 remote_refs = self.source.controldir.get_refs_container().as_dict()623 remote_refs = self.source.controldir.get_refs_container().as_dict()
612 wants = determine_wants(remote_refs)624 wants = determine_wants(remote_refs)
613 pb = ui.ui_factory.nested_progress_bar()625 pb = ui.ui_factory.nested_progress_bar()
614 target_git_object_retriever = get_object_store(self.target, mapping)626 target_git_object_retriever = get_object_store(self.target, mapping)
615 try:627 try:
616 target_git_object_retriever.lock_write()628 with target_git_object_retriever.lock_write():
617 try:
618 (pack_hint, last_rev) = import_git_objects(629 (pack_hint, last_rev) = import_git_objects(
619 self.target, mapping, self.source._git.object_store,630 self.target, mapping, self.source._git.object_store,
620 target_git_object_retriever, wants, pb, limit)631 target_git_object_retriever, wants, pb, limit)
621 return (pack_hint, last_rev, remote_refs)632 return (pack_hint, last_rev, remote_refs)
622 finally:
623 target_git_object_retriever.unlock()
624 finally:633 finally:
625 pb.finished()634 pb.finished()
626635
@@ -660,7 +669,7 @@
660 return None, old_refs, new_refs669 return None, old_refs, new_refs
661670
662 def fetch_objects(self, determine_wants, mapping=None, limit=None,671 def fetch_objects(self, determine_wants, mapping=None, limit=None,
663 lossy=False):672 lossy=False, depth=None):
664 raise NotImplementedError(self.fetch_objects)673 raise NotImplementedError(self.fetch_objects)
665674
666 def _target_has_shas(self, shas):675 def _target_has_shas(self, shas):
@@ -669,7 +678,7 @@
669678
670 def fetch(self, revision_id=None, find_ghosts=False,679 def fetch(self, revision_id=None, find_ghosts=False,
671 mapping=None, fetch_spec=None, branches=None, limit=None,680 mapping=None, fetch_spec=None, branches=None, limit=None,
672 include_tags=False):681 include_tags=False, depth=None):
673 if mapping is None:682 if mapping is None:
674 mapping = self.source.get_mapping()683 mapping = self.source.get_mapping()
675 if revision_id is not None:684 if revision_id is not None:
@@ -698,7 +707,7 @@
698 determine_wants = self.get_determine_wants_revids(707 determine_wants = self.get_determine_wants_revids(
699 args, include_tags=include_tags)708 args, include_tags=include_tags)
700 wants_recorder = DetermineWantsRecorder(determine_wants)709 wants_recorder = DetermineWantsRecorder(determine_wants)
701 self.fetch_objects(wants_recorder, mapping, limit=limit)710 self.fetch_objects(wants_recorder, mapping, limit=limit, depth=depth)
702 return wants_recorder.remote_refs711 return wants_recorder.remote_refs
703712
704 def get_determine_wants_revids(self, revids, include_tags=False):713 def get_determine_wants_revids(self, revids, include_tags=False):
@@ -720,7 +729,7 @@
720class InterLocalGitLocalGitRepository(InterGitGitRepository):729class InterLocalGitLocalGitRepository(InterGitGitRepository):
721730
722 def fetch_objects(self, determine_wants, mapping=None, limit=None,731 def fetch_objects(self, determine_wants, mapping=None, limit=None,
723 lossy=False):732 lossy=False, depth=None):
724 if lossy:733 if lossy:
725 raise LossyPushToSameVCS(self.source, self.target)734 raise LossyPushToSameVCS(self.source, self.target)
726 if limit is not None:735 if limit is not None:
@@ -731,7 +740,7 @@
731 try:740 try:
732 refs = self.source._git.fetch(741 refs = self.source._git.fetch(
733 self.target._git, determine_wants,742 self.target._git, determine_wants,
734 progress=progress)743 progress=progress, depth=depth)
735 finally:744 finally:
736 pb.finished()745 pb.finished()
737 return (None, None, refs)746 return (None, None, refs)
@@ -746,7 +755,7 @@
746class InterRemoteGitLocalGitRepository(InterGitGitRepository):755class InterRemoteGitLocalGitRepository(InterGitGitRepository):
747756
748 def fetch_objects(self, determine_wants, mapping=None, limit=None,757 def fetch_objects(self, determine_wants, mapping=None, limit=None,
749 lossy=False):758 lossy=False, depth=None):
750 if lossy:759 if lossy:
751 raise LossyPushToSameVCS(self.source, self.target)760 raise LossyPushToSameVCS(self.source, self.target)
752 if limit is not None:761 if limit is not None:
@@ -768,10 +777,12 @@
768 else:777 else:
769 f, commit, abort = self.target._git.object_store.add_pack()778 f, commit, abort = self.target._git.object_store.add_pack()
770 try:779 try:
771 refs = self.source.controldir.fetch_pack(780 fetch_result = self.source.controldir.fetch_pack(
772 determine_wants, graphwalker, f.write)781 determine_wants, graphwalker, f.write, depth=depth)
773 commit()782 commit()
774 return (None, None, refs)783 self.target._git.update_shallow(
784 fetch_result.new_shallow, fetch_result.new_unshallow)
785 return (None, None, fetch_result.refs)
775 except BaseException:786 except BaseException:
776 abort()787 abort()
777 raise788 raise
778789
=== modified file 'breezy/git/remote.py'
--- breezy/git/remote.py 2019-02-01 16:56:56 +0000
+++ breezy/git/remote.py 2019-02-11 01:23:45 +0000
@@ -416,8 +416,8 @@
416 if pb is not None:416 if pb is not None:
417 pb.finished()417 pb.finished()
418418
419 def fetch_pack(self, determine_wants, graph_walker, pack_data,419 def fetch_pack(self, determine_wants, graph_walker, pack_data, progress=None,
420 progress=None):420 depth=None):
421 if progress is None:421 if progress is None:
422 pb = ui.ui_factory.nested_progress_bar()422 pb = ui.ui_factory.nested_progress_bar()
423 progress = DefaultProgressReporter(pb).progress423 progress = DefaultProgressReporter(pb).progress
@@ -426,7 +426,7 @@
426 try:426 try:
427 result = self._client.fetch_pack(427 result = self._client.fetch_pack(
428 self._client_path, determine_wants, graph_walker, pack_data,428 self._client_path, determine_wants, graph_walker, pack_data,
429 progress)429 progress, depth=depth)
430 if result.refs is None:430 if result.refs is None:
431 result.refs = {}431 result.refs = {}
432 self._refs = remote_refs_dict_to_container(432 self._refs = remote_refs_dict_to_container(
@@ -539,9 +539,10 @@
539 def get_refs_container(self):539 def get_refs_container(self):
540 if self._refs is not None:540 if self._refs is not None:
541 return self._refs541 return self._refs
542 result = self.fetch_pack(lambda x: None, None,542 result = self.fetch_pack(
543 lambda x: None,543 lambda x: None, None,
544 lambda x: trace.mutter("git: %s" % x))544 lambda x: None, lambda x: trace.mutter("git: %s" % x),
545 depth=None)
545 self._refs = remote_refs_dict_to_container(546 self._refs = remote_refs_dict_to_container(
546 result.refs, result.symrefs)547 result.refs, result.symrefs)
547 return self._refs548 return self._refs
@@ -841,19 +842,20 @@
841 return self.controldir.archive(*args, **kwargs)842 return self.controldir.archive(*args, **kwargs)
842843
843 def fetch_pack(self, determine_wants, graph_walker, pack_data,844 def fetch_pack(self, determine_wants, graph_walker, pack_data,
844 progress=None):845 progress=None, depth=None):
845 return self.controldir.fetch_pack(846 return self.controldir.fetch_pack(
846 determine_wants, graph_walker, pack_data, progress)847 determine_wants, graph_walker, pack_data, progress, depth=depth)
847848
848 def send_pack(self, get_changed_refs, generate_pack_data):849 def send_pack(self, get_changed_refs, generate_pack_data):
849 return self.controldir.send_pack(get_changed_refs, generate_pack_data)850 return self.controldir.send_pack(get_changed_refs, generate_pack_data)
850851
851 def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref,852 def fetch_objects(self, determine_wants, graph_walker, resolve_ext_ref,
852 progress=None):853 progress=None, depth=None):
853 fd, path = tempfile.mkstemp(suffix=".pack")854 fd, path = tempfile.mkstemp(suffix=".pack")
854 try:855 try:
855 self.fetch_pack(determine_wants, graph_walker,856 self.fetch_pack(
856 lambda x: os.write(fd, x), progress)857 determine_wants, graph_walker,
858 lambda x: os.write(fd, x), progress, depth=depth)
857 finally:859 finally:
858 os.close(fd)860 os.close(fd)
859 if os.path.getsize(path) == 0:861 if os.path.getsize(path) == 0:
860862
=== modified file 'breezy/git/repository.py'
--- breezy/git/repository.py 2018-11-30 12:39:04 +0000
+++ breezy/git/repository.py 2019-02-11 01:23:45 +0000
@@ -131,6 +131,7 @@
131 _serializer = None131 _serializer = None
132 vcs = foreign_vcs_git132 vcs = foreign_vcs_git
133 chk_bytes = None133 chk_bytes = None
134 supports_fetch_depth = True
134135
135 def __init__(self, gitdir):136 def __init__(self, gitdir):
136 self._transport = gitdir.root_transport137 self._transport = gitdir.root_transport
137138
=== modified file 'breezy/git/tests/test_blackbox.py'
--- breezy/git/tests/test_blackbox.py 2019-01-02 18:49:15 +0000
+++ breezy/git/tests/test_blackbox.py 2019-02-11 01:23:45 +0000
@@ -308,6 +308,7 @@
308 self.repo.stage("foo")308 self.repo.stage("foo")
309 self.repo.do_commit(309 self.repo.do_commit(
310 b"message", committer=b"Somebody <user@example.com>",310 b"message", committer=b"Somebody <user@example.com>",
311 author=b"Somebody <user@example.com>",
311 commit_timestamp=1526330165, commit_timezone=0,312 commit_timestamp=1526330165, commit_timezone=0,
312 author_timestamp=1526330165, author_timezone=0,313 author_timestamp=1526330165, author_timezone=0,
313 merge_heads=[b'aa' * 20])314 merge_heads=[b'aa' * 20])
314315
=== modified file 'breezy/git/transportgit.py'
--- breezy/git/transportgit.py 2018-11-11 14:23:06 +0000
+++ breezy/git/transportgit.py 2019-02-11 01:23:45 +0000
@@ -36,6 +36,7 @@
36from dulwich.object_store import (36from dulwich.object_store import (
37 PackBasedObjectStore,37 PackBasedObjectStore,
38 PACKDIR,38 PACKDIR,
39 read_packs_file,
39 )40 )
40from dulwich.pack import (41from dulwich.pack import (
41 MemoryPackIndex,42 MemoryPackIndex,
@@ -587,16 +588,41 @@
587 ret.append(l)588 ret.append(l)
588 return ret589 return ret
589590
590 @property
591 def packs(self):
592 # FIXME: Never invalidates.
593 if not self._pack_cache:
594 self._update_pack_cache()
595 return self._pack_cache.values()
596
597 def _update_pack_cache(self):591 def _update_pack_cache(self):
598 for pack in self._load_packs():592 pack_files = set()
599 self._pack_cache[pack._basename] = pack593 pack_dir_contents = self._pack_names()
594 for name in pack_dir_contents:
595 if name.startswith("pack-") and name.endswith(".pack"):
596 # verify that idx exists first (otherwise the pack was not yet
597 # fully written)
598 idx_name = os.path.splitext(name)[0] + ".idx"
599 if idx_name in pack_dir_contents:
600 pack_files.add(os.path.splitext(name)[0])
601
602 new_packs = []
603 for basename in pack_files:
604 pack_name = basename + ".pack"
605 if basename not in self._pack_cache:
606 try:
607 size = self.pack_transport.stat(pack_name).st_size
608 except TransportNotPossible:
609 f = self.pack_transport.get(pack_name)
610 pd = PackData(pack_name, f)
611 else:
612 pd = PackData(
613 pack_name, self.pack_transport.get(pack_name),
614 size=size)
615 idxname = basename + ".idx"
616 idx = load_pack_index_file(
617 idxname, self.pack_transport.get(idxname))
618 pack = Pack.from_objects(pd, idx)
619 pack._basename = basename
620 self._pack_cache[basename] = pack
621 new_packs.append(pack)
622 # Remove disappeared pack files
623 for f in set(self._pack_cache) - pack_files:
624 self._pack_cache.pop(f).close()
625 return new_packs
600626
601 def _pack_names(self):627 def _pack_names(self):
602 try:628 try:
@@ -608,9 +634,6 @@
608 # Hmm, warn about running 'git update-server-info' ?634 # Hmm, warn about running 'git update-server-info' ?
609 return iter([])635 return iter([])
610 else:636 else:
611 # TODO(jelmer): Move to top-level after dulwich
612 # 0.19.7 is released.
613 from dulwich.object_store import read_packs_file
614 with f:637 with f:
615 return read_packs_file(f)638 return read_packs_file(f)
616 except NoSuchFile:639 except NoSuchFile:
@@ -619,26 +642,10 @@
619 def _remove_pack(self, pack):642 def _remove_pack(self, pack):
620 self.pack_transport.delete(os.path.basename(pack.index.path))643 self.pack_transport.delete(os.path.basename(pack.index.path))
621 self.pack_transport.delete(pack.data.filename)644 self.pack_transport.delete(pack.data.filename)
622645 try:
623 def _load_packs(self):646 del self._pack_cache[os.path.basename(pack._basename)]
624 ret = []647 except KeyError:
625 for name in self._pack_names():648 pass
626 if name.startswith("pack-") and name.endswith(".pack"):
627 try:
628 size = self.pack_transport.stat(name).st_size
629 except TransportNotPossible:
630 f = self.pack_transport.get(name)
631 pd = PackData(name, f)
632 else:
633 pd = PackData(name, self.pack_transport.get(name),
634 size=size)
635 idxname = name.replace(".pack", ".idx")
636 idx = load_pack_index_file(
637 idxname, self.pack_transport.get(idxname))
638 pack = Pack.from_objects(pd, idx)
639 pack._basename = idxname[:-4]
640 ret.append(pack)
641 return ret
642649
643 def _iter_loose_objects(self):650 def _iter_loose_objects(self):
644 for base in self.transport.list_dir('.'):651 for base in self.transport.list_dir('.'):
@@ -702,7 +709,7 @@
702 idx = load_pack_index_file(basename + ".idx", idxfile)709 idx = load_pack_index_file(basename + ".idx", idxfile)
703 final_pack = Pack.from_objects(p, idx)710 final_pack = Pack.from_objects(p, idx)
704 final_pack._basename = basename711 final_pack._basename = basename
705 self._add_known_pack(basename, final_pack)712 self._add_cached_pack(basename, final_pack)
706 return final_pack713 return final_pack
707714
708 def move_in_thin_pack(self, f):715 def move_in_thin_pack(self, f):
@@ -735,8 +742,6 @@
735 write_pack_index_v2(idxfile, entries, data_sum)742 write_pack_index_v2(idxfile, entries, data_sum)
736 finally:743 finally:
737 idxfile.close()744 idxfile.close()
738 # TODO(jelmer): Just add new pack to the cache
739 self._flush_pack_cache()
740745
741 def add_pack(self):746 def add_pack(self):
742 """Add a new pack to this object store.747 """Add a new pack to this object store.
743748
=== modified file 'breezy/plugins/weave_fmt/bzrdir.py'
--- breezy/plugins/weave_fmt/bzrdir.py 2018-11-11 04:08:32 +0000
+++ breezy/plugins/weave_fmt/bzrdir.py 2019-02-11 01:23:45 +0000
@@ -895,8 +895,10 @@
895 def sprout(self, url, revision_id=None, force_new_repo=False,895 def sprout(self, url, revision_id=None, force_new_repo=False,
896 possible_transports=None, accelerator_tree=None,896 possible_transports=None, accelerator_tree=None,
897 hardlink=False, stacked=False, create_tree_if_local=True,897 hardlink=False, stacked=False, create_tree_if_local=True,
898 source_branch=None):898 source_branch=None, depth=None):
899 """See ControlDir.sprout()."""899 """See ControlDir.sprout()."""
900 if depth is not None:
901 raise errors.FetchDepthUnsupported(self)
900 if source_branch is not None:902 if source_branch is not None:
901 my_branch = self.open_branch()903 my_branch = self.open_branch()
902 if source_branch.base != my_branch.base:904 if source_branch.base != my_branch.base:
903905
=== modified file 'breezy/repository.py'
--- breezy/repository.py 2019-02-01 16:56:56 +0000
+++ breezy/repository.py 2019-02-11 01:23:45 +0000
@@ -260,6 +260,10 @@
260 # items in the tree, or just bulk fetching/pushing of data?260 # items in the tree, or just bulk fetching/pushing of data?
261 supports_random_access = True261 supports_random_access = True
262262
263 # Does this repository implementation support fetching with
264 # a certain graph depth?
265 supports_fetch_depth = False
266
263 def abort_write_group(self, suppress_errors=False):267 def abort_write_group(self, suppress_errors=False):
264 """Commit the contents accrued within the current write group.268 """Commit the contents accrued within the current write group.
265269
266270
=== modified file 'breezy/tests/per_controldir/test_controldir.py'
--- breezy/tests/per_controldir/test_controldir.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/per_controldir/test_controldir.py 2019-02-11 01:23:45 +0000
@@ -86,7 +86,7 @@
8686
87 def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None,87 def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None,
88 force_new_repo=False, accelerator_tree=None,88 force_new_repo=False, accelerator_tree=None,
89 create_tree_if_local=True):89 create_tree_if_local=True, depth=None):
90 """Sprout from_bzrdir into to_url, or raise TestSkipped.90 """Sprout from_bzrdir into to_url, or raise TestSkipped.
9191
92 A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into92 A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
@@ -99,7 +99,8 @@
99 force_new_repo=force_new_repo,99 force_new_repo=force_new_repo,
100 possible_transports=[to_transport],100 possible_transports=[to_transport],
101 accelerator_tree=accelerator_tree,101 accelerator_tree=accelerator_tree,
102 create_tree_if_local=create_tree_if_local)102 create_tree_if_local=create_tree_if_local,
103 depth=depth)
103 return target104 return target
104105
105 def test_uninitializable(self):106 def test_uninitializable(self):
@@ -1050,6 +1051,20 @@
1050 self.addCleanup(repo.lock_read().unlock)1051 self.addCleanup(repo.lock_read().unlock)
1051 self.assertEqual(None, repo.get_parent_map([rev1]).get(rev1))1052 self.assertEqual(None, repo.get_parent_map([rev1]).get(rev1))
10521053
1054 def test_sprout_with_depth(self):
1055 tree = self.make_branch_and_tree('source')
1056 self.build_tree(['source/foo'])
1057 tree.add('foo')
1058 tree.commit('revision 1')
1059 rev2 = tree.commit('revision 2', allow_pointless=True)
1060 dir = tree.controldir
1061 try:
1062 target = self.sproutOrSkip(dir, self.get_url('target'), depth=1)
1063 except errors.FetchDepthUnsupported:
1064 self.assertFalse(tree.branch.repository.supports_fetch_depth)
1065 else:
1066 self.assertEqual({rev2}, target.open_repository().all_revision_ids())
1067
1053 def test_format_initialize_find_open(self):1068 def test_format_initialize_find_open(self):
1054 # loopback test to check the current format initializes to itself.1069 # loopback test to check the current format initializes to itself.
1055 if not self.bzrdir_format.is_initializable():1070 if not self.bzrdir_format.is_initializable():
10561071
=== modified file 'breezy/tests/per_interbranch/test_fetch.py'
--- breezy/tests/per_interbranch/test_fetch.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/per_interbranch/test_fetch.py 2019-02-11 01:23:45 +0000
@@ -16,7 +16,11 @@
1616
17"""Tests for InterBranch.fetch."""17"""Tests for InterBranch.fetch."""
1818
19from breezy.errors import FetchLimitUnsupported, NoRoundtrippingSupport19from breezy.errors import (
20 FetchDepthUnsupported,
21 FetchLimitUnsupported,
22 NoRoundtrippingSupport,
23 )
20from breezy.revision import NULL_REVISION24from breezy.revision import NULL_REVISION
21from breezy.tests import TestNotApplicable25from breezy.tests import TestNotApplicable
22from breezy.tests.per_interbranch import (26from breezy.tests.per_interbranch import (
@@ -113,3 +117,39 @@
113 self.assertEqual(117 self.assertEqual(
114 {rev1, rev2},118 {rev1, rev2},
115 b2.repository.has_revisions([rev1, rev2, rev3]))119 b2.repository.has_revisions([rev1, rev2, rev3]))
120
121 def test_fetch_revisions_depth(self):
122 """Test fetch-revision operation."""
123 builder = self.make_branch_builder(
124 'b1', format=self.branch_format_from._matchingcontroldir)
125 builder.start_series()
126 rev1 = builder.build_commit()
127 rev2 = builder.build_commit()
128 rev3 = builder.build_commit()
129 builder.finish_series()
130 b1 = builder.get_branch()
131 b2 = self.make_to_branch('b2')
132 try:
133 if b2.repository.supports_fetch_depth:
134 b2.fetch(b1, depth=1)
135 else:
136 self.assertRaises(FetchDepthUnsupported, b2.fetch, b1, depth=1)
137 raise TestNotApplicable(
138 'interbranch does not support fetch depths')
139 except NoRoundtrippingSupport:
140 raise TestNotApplicable(
141 'lossless cross-vcs fetch %r to %r not supported' %
142 (b1, b2))
143
144 self.assertEqual(
145 {rev3},
146 b2.repository.has_revisions([rev1, rev2, rev3]))
147
148 # fetch does not update the last revision
149 self.assertEqual(NULL_REVISION, b2.last_revision())
150
151 # Incrementally fetch one more
152 b2.fetch(b1, depth=2)
153
154 self.assertEqual(
155 {rev2, rev3}, b2.repository.has_revisions([rev1, rev2, rev3]))
116156
=== modified file 'breezy/tests/per_repository/test_repository.py'
--- breezy/tests/per_repository/test_repository.py 2019-02-01 16:56:56 +0000
+++ breezy/tests/per_repository/test_repository.py 2019-02-11 01:23:45 +0000
@@ -125,6 +125,9 @@
125 def test_attribute_format_supports_random_access(self):125 def test_attribute_format_supports_random_access(self):
126 self.assertRepositoryAttribute('supports_random_access', (True, False))126 self.assertRepositoryAttribute('supports_random_access', (True, False))
127127
128 def test_attribute_format_supports_fetch_depth(self):
129 self.assertRepositoryAttribute('supports_fetch_depth', (True, False))
130
128 def test_attribute_format_supports_setting_revision_ids(self):131 def test_attribute_format_supports_setting_revision_ids(self):
129 self.assertFormatAttribute('supports_setting_revision_ids',132 self.assertFormatAttribute('supports_setting_revision_ids',
130 (True, False))133 (True, False))
131134
=== modified file 'breezy/tests/test_foreign.py'
--- breezy/tests/test_foreign.py 2018-11-25 20:44:56 +0000
+++ breezy/tests/test_foreign.py 2019-02-11 01:23:45 +0000
@@ -339,14 +339,15 @@
339 def sprout(self, url, revision_id=None, force_new_repo=False,339 def sprout(self, url, revision_id=None, force_new_repo=False,
340 recurse='down', possible_transports=None,340 recurse='down', possible_transports=None,
341 accelerator_tree=None, hardlink=False, stacked=False,341 accelerator_tree=None, hardlink=False, stacked=False,
342 source_branch=None):342 source_branch=None, depth=None):
343 # dirstate doesn't cope with accelerator_trees well343 # dirstate doesn't cope with accelerator_trees well
344 # that have a different control dir344 # that have a different control dir
345 return super(DummyForeignVcsDir, self).sprout(345 return super(DummyForeignVcsDir, self).sprout(
346 url=url,346 url=url,
347 revision_id=revision_id, force_new_repo=force_new_repo,347 revision_id=revision_id, force_new_repo=force_new_repo,
348 recurse=recurse, possible_transports=possible_transports,348 recurse=recurse, possible_transports=possible_transports,
349 hardlink=hardlink, stacked=stacked, source_branch=source_branch)349 hardlink=hardlink, stacked=stacked, source_branch=source_branch,
350 depth=depth)
350351
351352
352def register_dummy_foreign_for_test(testcase):353def register_dummy_foreign_for_test(testcase):
353354
=== modified file 'setup.py'
--- setup.py 2019-01-24 00:23:01 +0000
+++ setup.py 2019-02-11 01:23:45 +0000
@@ -60,7 +60,7 @@
60 # Technically, Breezy works without these two dependencies too. But there's60 # Technically, Breezy works without these two dependencies too. But there's
61 # no way to enable them by default and let users opt out.61 # no way to enable them by default and let users opt out.
62 'fastimport>=0.9.8',62 'fastimport>=0.9.8',
63 'dulwich>=0.19.1',63 'dulwich>=0.19.11',
64 ],64 ],
65 'extras_require': {65 'extras_require': {
66 'fastimport': [],66 'fastimport': [],

Subscribers

People subscribed via source and target branches