1202
def push_branch(self, source, revision_id=None, overwrite=False,
1204
"""Push the source branch into this BzrDir."""
1206
# If we can open a branch, use its direct repository, otherwise see
1207
# if there is a repository without a branch.
1209
br_to = self.open_branch()
1210
except errors.NotBranchError:
1211
# Didn't find a branch, can we find a repository?
1212
repository_to = self.find_repository()
1214
# Found a branch, so we must have found a repository
1215
repository_to = br_to.repository
1217
push_result = PushResult()
1218
push_result.source_branch = source
1220
# We have a repository but no branch, copy the revisions, and then
1222
repository_to.fetch(source.repository, revision_id=revision_id)
1223
br_to = source.clone(self, revision_id=revision_id)
1224
if source.get_push_location() is None or remember:
1225
source.set_push_location(br_to.base)
1226
push_result.stacked_on = None
1227
push_result.branch_push_result = None
1228
push_result.old_revno = None
1229
push_result.old_revid = _mod_revision.NULL_REVISION
1230
push_result.target_branch = br_to
1231
push_result.master_branch = None
1232
push_result.workingtree_updated = False
1234
# We have successfully opened the branch, remember if necessary:
1235
if source.get_push_location() is None or remember:
1236
source.set_push_location(br_to.base)
1238
tree_to = self.open_workingtree()
1239
except errors.NotLocalUrl:
1240
push_result.branch_push_result = source.push(br_to,
1241
overwrite, stop_revision=revision_id)
1242
push_result.workingtree_updated = False
1243
except errors.NoWorkingTree:
1244
push_result.branch_push_result = source.push(br_to,
1245
overwrite, stop_revision=revision_id)
1246
push_result.workingtree_updated = None # Not applicable
1248
tree_to.lock_write()
1250
push_result.branch_push_result = source.push(
1251
tree_to.branch, overwrite, stop_revision=revision_id)
1255
push_result.workingtree_updated = True
1256
push_result.old_revno = push_result.branch_push_result.old_revno
1257
push_result.old_revid = push_result.branch_push_result.old_revid
1258
push_result.target_branch = \
1259
push_result.branch_push_result.target_branch
1200
1263
class BzrDirHooks(hooks.Hooks):
1201
1264
"""Hooks for BzrDir operations."""
2751
2814
isinstance(self.target_format.workingtree_format,
2752
2815
workingtree_4.WorkingTreeFormat5)):
2753
2816
workingtree_4.Converter4to5().convert(tree)
2817
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and
2818
not isinstance(tree, workingtree_4.WorkingTree6) and
2819
isinstance(self.target_format.workingtree_format,
2820
workingtree_4.WorkingTreeFormat6)):
2821
workingtree_4.Converter4or5to6().convert(tree)
2754
2822
return to_convert
3342
3410
branch_format='bzrlib.branch.BzrBranchFormat7',
3343
3411
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3345
format_registry.register_metadir('development-wt5',
3413
format_registry.register_metadir('1.14',
3346
3414
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3347
help='A working-tree format that supports views and content filtering.',
3415
help='A working-tree format that supports content filtering.',
3348
3416
branch_format='bzrlib.branch.BzrBranchFormat7',
3349
3417
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3352
format_registry.register_metadir('development-wt5-rich-root',
3419
format_registry.register_metadir('1.14-rich-root',
3353
3420
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3354
help='A variant of development-wt5 that supports rich-root data '
3421
help='A variant of 1.14 that supports rich-root data '
3355
3422
'(needed for bzr-svn and bzr-git).',
3356
3423
branch_format='bzrlib.branch.BzrBranchFormat7',
3357
3424
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3360
3426
# The following two formats should always just be aliases.
3361
3427
format_registry.register_metadir('development',
3408
3474
experimental=True,
3476
# These next two formats should be removed when the gc formats are
3477
# updated to use WorkingTreeFormat6 and are merged into bzr.dev
3478
format_registry.register_metadir('development-wt6',
3479
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3480
help='1.14 with filtered views. '
3482
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3484
branch_format='bzrlib.branch.BzrBranchFormat7',
3485
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3489
format_registry.register_metadir('development-wt6-rich-root',
3490
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3491
help='A variant of development-wt6 that supports rich-root data '
3492
'(needed for bzr-svn and bzr-git).',
3493
branch_format='bzrlib.branch.BzrBranchFormat7',
3494
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3410
3498
# The following format should be an alias for the rich root equivalent
3411
3499
# of the default format
3412
3500
format_registry.register_metadir('default-rich-root',