~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Patch Queue Manager
  • Date: 2016-01-31 13:36:59 UTC
  • mfrom: (6613.1.5 1538480-match-hostname)
  • Revision ID: pqm@pqm.ubuntu.com-20160131133659-ouy92ee2wlv9xz8m
(vila) Use ssl.match_hostname instead of our own. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    revision as _mod_revision,
61
61
    revisiontree,
62
62
    rio as _mod_rio,
 
63
    shelf,
63
64
    transform,
64
65
    transport,
65
66
    ui,
534
535
        else:
535
536
            # TODO now merge from tree.last_revision to revision (to preserve
536
537
            # user local changes)
537
 
            merge.transform_tree(tree, self)
 
538
            try:
 
539
                other_tree = self.revision_tree(revision_id)
 
540
            except errors.NoSuchRevision:
 
541
                other_tree = self.branch.repository.revision_tree(revision_id)
 
542
 
 
543
            merge.transform_tree(tree, other_tree)
538
544
            if revision_id == _mod_revision.NULL_REVISION:
539
545
                new_parents = []
540
546
            else:
1351
1357
                basis_tree.unlock()
1352
1358
        return conflicts
1353
1359
 
 
1360
    @needs_write_lock
 
1361
    def store_uncommitted(self):
 
1362
        """Store uncommitted changes from the tree in the branch."""
 
1363
        target_tree = self.basis_tree()
 
1364
        shelf_creator = shelf.ShelfCreator(self, target_tree)
 
1365
        try:
 
1366
            if not shelf_creator.shelve_all():
 
1367
                return
 
1368
            self.branch.store_uncommitted(shelf_creator)
 
1369
            shelf_creator.transform()
 
1370
        finally:
 
1371
            shelf_creator.finalize()
 
1372
        note('Uncommitted changes stored in branch "%s".', self.branch.nick)
 
1373
 
 
1374
    @needs_write_lock
 
1375
    def restore_uncommitted(self):
 
1376
        """Restore uncommitted changes from the branch into the tree."""
 
1377
        unshelver = self.branch.get_unshelver(self)
 
1378
        if unshelver is None:
 
1379
            return
 
1380
        try:
 
1381
            merger = unshelver.make_merger()
 
1382
            merger.ignore_zero = True
 
1383
            merger.do_merge()
 
1384
            self.branch.store_uncommitted(None)
 
1385
        finally:
 
1386
            unshelver.finalize()
 
1387
 
1354
1388
    def revision_tree(self, revision_id):
1355
1389
        """See Tree.revision_tree.
1356
1390
 
3078
3112
    def __ne__(self, other):
3079
3113
        return not (self == other)
3080
3114
 
3081
 
    @classmethod
3082
 
    @symbol_versioning.deprecated_method(
3083
 
        symbol_versioning.deprecated_in((2, 4, 0)))
3084
 
    def get_default_format(klass):
3085
 
        """Return the current default format."""
3086
 
        return format_registry.get_default()
3087
 
 
3088
3115
    def get_format_description(self):
3089
3116
        """Return the short description for this format."""
3090
3117
        raise NotImplementedError(self.get_format_description)
3106
3133
        """True if this format supports stored views."""
3107
3134
        return False
3108
3135
 
3109
 
    @classmethod
3110
 
    @symbol_versioning.deprecated_method(
3111
 
        symbol_versioning.deprecated_in((2, 4, 0)))
3112
 
    def register_format(klass, format):
3113
 
        format_registry.register(format)
3114
 
 
3115
 
    @classmethod
3116
 
    @symbol_versioning.deprecated_method(
3117
 
        symbol_versioning.deprecated_in((2, 4, 0)))
3118
 
    def register_extra_format(klass, format):
3119
 
        format_registry.register_extra(format)
3120
 
 
3121
 
    @classmethod
3122
 
    @symbol_versioning.deprecated_method(
3123
 
        symbol_versioning.deprecated_in((2, 4, 0)))
3124
 
    def unregister_extra_format(klass, format):
3125
 
        format_registry.unregister_extra(format)
3126
 
 
3127
 
    @classmethod
3128
 
    @symbol_versioning.deprecated_method(
3129
 
        symbol_versioning.deprecated_in((2, 4, 0)))
3130
 
    def get_formats(klass):
3131
 
        return format_registry._get_all()
3132
 
 
3133
 
    @classmethod
3134
 
    @symbol_versioning.deprecated_method(
3135
 
        symbol_versioning.deprecated_in((2, 4, 0)))
3136
 
    def set_default_format(klass, format):
3137
 
        format_registry.set_default(format)
3138
 
 
3139
 
    @classmethod
3140
 
    @symbol_versioning.deprecated_method(
3141
 
        symbol_versioning.deprecated_in((2, 4, 0)))
3142
 
    def unregister_format(klass, format):
3143
 
        format_registry.remove(format)
 
3136
    def get_controldir_for_branch(self):
 
3137
        """Get the control directory format for creating branches.
 
3138
 
 
3139
        This is to support testing of working tree formats that can not exist
 
3140
        in the same control directory as a branch.
 
3141
        """
 
3142
        return self._matchingbzrdir
 
3143
 
 
3144
 
 
3145
class WorkingTreeFormatMetaDir(bzrdir.BzrFormat, WorkingTreeFormat):
 
3146
    """Base class for working trees that live in bzr meta directories."""
 
3147
 
 
3148
    def __init__(self):
 
3149
        WorkingTreeFormat.__init__(self)
 
3150
        bzrdir.BzrFormat.__init__(self)
 
3151
 
 
3152
    @classmethod
 
3153
    def find_format_string(klass, controldir):
 
3154
        """Return format name for the working tree object in controldir."""
 
3155
        try:
 
3156
            transport = controldir.get_workingtree_transport(None)
 
3157
            return transport.get_bytes("format")
 
3158
        except errors.NoSuchFile:
 
3159
            raise errors.NoWorkingTree(base=transport.base)
 
3160
 
 
3161
    @classmethod
 
3162
    def find_format(klass, controldir):
 
3163
        """Return the format for the working tree object in controldir."""
 
3164
        format_string = klass.find_format_string(controldir)
 
3165
        return klass._find_format(format_registry, 'working tree',
 
3166
                format_string)
 
3167
 
 
3168
    def check_support_status(self, allow_unsupported, recommend_upgrade=True,
 
3169
            basedir=None):
 
3170
        WorkingTreeFormat.check_support_status(self,
 
3171
            allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
 
3172
            basedir=basedir)
 
3173
        bzrdir.BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
 
3174
            recommend_upgrade=recommend_upgrade, basedir=basedir)
3144
3175
 
3145
3176
    def get_controldir_for_branch(self):
3146
3177
        """Get the control directory format for creating branches.