/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to roundtrip.py

  • Committer: Jelmer Vernooij
  • Date: 2010-04-30 23:03:01 UTC
  • mto: (0.200.912 trunk)
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@samba.org-20100430230301-w4xncjn5svh2ghl4
Support storing revision id data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""Roundtripping support."""
 
18
 
 
19
 
 
20
from cStringIO import StringIO
 
21
 
 
22
 
 
23
class BzrGitRevisionMetadata(object):
 
24
    """Metadata for a Bazaar revision roundtripped into Git.
 
25
    
 
26
    :ivar revision_id: Revision id, as string
 
27
    :ivar properties: Revision properties, as dictionary
 
28
    :ivar file_ids: File ids, as map from path -> file id
 
29
    """
 
30
 
 
31
    revision_id = None
 
32
 
 
33
    file_ids = {}
 
34
 
 
35
    properties = {}
 
36
 
 
37
 
 
38
def parse_roundtripping_metadata(text):
 
39
    """Parse Bazaar roundtripping metadata."""
 
40
    ret = BzrGitRevisionMetadata()
 
41
    f = StringIO(text)
 
42
    for l in f.readlines():
 
43
        (key, value) = l.split(":", 1)
 
44
        if key == "revision-id":
 
45
            ret.revision_id = value.strip()
 
46
        else:
 
47
            raise ValueError
 
48
    return ret