~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/textinv.py

  • Committer: John Arbash Meinel
  • Date: 2008-08-22 21:11:25 UTC
  • mto: This revision was merged to the branch mainline in revision 3653.
  • Revision ID: john@arbash-meinel.com-20080822211125-p9bmwrug1j4ann6d
Shrink the page size so that the three_level and iter_all
tests don't have to use so many keys to get a three-level index.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from __future__ import absolute_import
18
17
 
19
18
from bzrlib.errors import BzrError
20
 
from bzrlib.inventory import Inventory
 
19
from bzrlib.inventory import InventoryEntry, Inventory
21
20
 
22
21
 
23
22
START_MARK = "# bzr inventory format 3\n"
26
25
 
27
26
def escape(s):
28
27
    """Very simple URL-like escaping.
29
 
 
 
28
    
30
29
    (Why not just use backslashes?  Because then we couldn't parse
31
30
    lines just by splitting on spaces.)"""
32
31
    return (s.replace('\\', r'\x5c')
47
46
    # TODO: What if there's anything else?
48
47
 
49
48
    return s
50
 
 
51
 
 
 
49
    
 
50
                     
52
51
 
53
52
 
54
53
def write_text_inventory(inv, outf):
57
56
    for path, ie in inv.iter_entries():
58
57
        if inv.is_root(ie.file_id):
59
58
            continue
60
 
 
 
59
        
61
60
        outf.write(ie.file_id + ' ')
62
61
        outf.write(escape(ie.name) + ' ')
63
62
        outf.write(ie.kind + ' ')
64
63
        outf.write(ie.parent_id + ' ')
65
 
 
 
64
        
66
65
        if ie.kind == 'file':
67
66
            outf.write(ie.text_id)
68
67
            outf.write(' ' + ie.text_sha1)
75
74
    """Return an inventory read in from tf"""
76
75
    if tf.readline() != START_MARK:
77
76
        raise BzrError("missing start mark")
78
 
 
 
77
    
79
78
    inv = Inventory()
80
79
 
81
80
    for l in tf:
87
86
              'kind': fields[2],
88
87
              'parent_id': fields[3]}
89
88
        ##inv.add(ie)
90
 
 
 
89
        
91
90
    if l != END_MARK:
92
91
        raise BzrError("missing end mark")
93
92
    return inv