~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1118
1118
            # Remembers if asked explicitly or no previous location is set
1119
1119
            if (remember
1120
1120
                or (remember is None and branch_to.get_parent() is None)):
1121
 
                branch_to.lock_write()
1122
 
                try:
1123
 
                    # FIXME: This shouldn't be done before the pull
1124
 
                    # succeeds... -- vila 2012-01-02
1125
 
                    branch_to.set_parent(branch_from.base)
1126
 
                finally:
1127
 
                    branch_to.unlock()
 
1121
                # FIXME: This shouldn't be done before the pull
 
1122
                # succeeds... -- vila 2012-01-02
 
1123
                branch_to.set_parent(branch_from.base)
1128
1124
 
1129
1125
        if revision is not None:
1130
1126
            revision_id = revision.as_revision_id(branch_from)
2017
2013
                a_bzrdir.create_workingtree()
2018
2014
        if append_revisions_only:
2019
2015
            try:
2020
 
                branch.lock_write()
2021
 
                try:
2022
 
                    branch.set_append_revisions_only(True)
2023
 
                finally:
2024
 
                    branch.unlock()
 
2016
                branch.set_append_revisions_only(True)
2025
2017
            except errors.UpgradeRequired:
2026
2018
                raise errors.BzrCommandError(gettext('This branch format cannot be set'
2027
2019
                    ' to append-revisions-only.  Try --default.'))
5603
5595
            public_branch = stored_public_branch
5604
5596
        elif stored_public_branch is None:
5605
5597
            # FIXME: Should be done only if we succeed ? -- vila 2012-01-03
5606
 
            branch.lock_write()
5607
 
            try:
5608
 
                branch.set_public_branch(public_branch)
5609
 
            finally:
5610
 
                branch.unlock()
 
5598
            branch.set_public_branch(public_branch)
5611
5599
        if not include_bundle and public_branch is None:
5612
5600
            raise errors.BzrCommandError(gettext('No public branch specified or'
5613
5601
                                         ' known'))