~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Jelmer Vernooij
  • Date: 2009-04-06 02:54:14 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4255.
  • Revision ID: jelmer@samba.org-20090406025414-65tpjwcmjp5wa5oj
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
from bzrlib.osutils import (
58
58
    sha_string,
59
59
    )
 
60
from bzrlib.push import (
 
61
    PushResult,
 
62
    )
60
63
from bzrlib.smart.client import _SmartClient
61
64
from bzrlib.store.versioned import WeaveStore
62
65
from bzrlib.transactions import WriteTransaction
1196
1199
                    basis.unlock()
1197
1200
        return result
1198
1201
 
 
1202
    def push_branch(self, source, revision_id=None, overwrite=False, 
 
1203
        remember=False):
 
1204
        """Push the source branch into this BzrDir."""
 
1205
        br_to = None
 
1206
        # If we can open a branch, use its direct repository, otherwise see
 
1207
        # if there is a repository without a branch.
 
1208
        try:
 
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()
 
1213
        else:
 
1214
            # Found a branch, so we must have found a repository
 
1215
            repository_to = br_to.repository
 
1216
 
 
1217
        push_result = PushResult()
 
1218
        push_result.source_branch = source
 
1219
        if br_to is None:
 
1220
            # We have a repository but no branch, copy the revisions, and then
 
1221
            # create a branch.
 
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
 
1233
        else:
 
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)
 
1237
            try:
 
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
 
1247
            else:
 
1248
                tree_to.lock_write()
 
1249
                try:
 
1250
                    push_result.branch_push_result = source.push(
 
1251
                        tree_to.branch, overwrite, stop_revision=revision_id)
 
1252
                    tree_to.update()
 
1253
                finally:
 
1254
                    tree_to.unlock()
 
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
 
1260
        return push_result
 
1261
 
1199
1262
 
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
2755
2823
 
2756
2824
 
3342
3410
    branch_format='bzrlib.branch.BzrBranchFormat7',
3343
3411
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3344
3412
    )
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',
3350
 
    experimental=True,
3351
3418
    )
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',
3358
 
    experimental=True,
3359
3425
    )
3360
3426
# The following two formats should always just be aliases.
3361
3427
format_registry.register_metadir('development',
3407
3473
    hidden=True,
3408
3474
    experimental=True,
3409
3475
    )
 
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. '
 
3481
        'Please read '
 
3482
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
 
3483
        'before use.',
 
3484
    branch_format='bzrlib.branch.BzrBranchFormat7',
 
3485
    tree_format='bzrlib.workingtree.WorkingTreeFormat6',
 
3486
    hidden=True,
 
3487
    experimental=True,
 
3488
    )
 
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',
 
3495
    hidden=True,
 
3496
    experimental=True,
 
3497
    )
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',