~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.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:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
17
18
 
18
19
import errno
19
20
import re
20
21
 
 
22
from bzrlib.lazy_import import lazy_import
 
23
lazy_import(globals(), """
21
24
from bzrlib import (
22
25
    bencode,
23
26
    errors,
26
29
    pack,
27
30
    transform,
28
31
)
 
32
""")
29
33
 
30
34
 
31
35
class ShelfCreator(object):
62
66
        """Iterable of tuples describing shelvable changes.
63
67
 
64
68
        As well as generating the tuples, this updates several members.
65
 
        Tuples may be:
 
69
        Tuples may be::
 
70
 
66
71
           ('add file', file_id, work_kind, work_path)
67
72
           ('delete file', file_id, target_kind, target_path)
68
73
           ('rename', file_id, target_path, work_path)
78
83
            # when a tree root was deleted / renamed.
79
84
            if kind[0] is None and names[1] == '':
80
85
                continue
 
86
            # Also don't shelve deletion of tree root.
 
87
            if kind[1] is None and names[0] == '':
 
88
                continue
81
89
            if kind[0] is None or versioned[0] == False:
82
90
                self.creation[file_id] = (kind[1], names[1], parents[1],
83
91
                                          versioned)