~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to read_changeset.py

  • Committer: John Arbash Meinel
  • Date: 2005-06-20 00:41:04 UTC
  • mto: (0.5.85) (1185.82.1 bzr-w-changeset)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: john@arbash-meinel.com-20050620004104-0a462fa1d203c741
Working on properly representing renames.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
class MalformedPatches(BadChangeset): pass
12
12
class MalformedFooter(BadChangeset): pass
13
13
 
 
14
def _unescape(name):
 
15
    """Now we want to find the filename effected.
 
16
    Unfortunately the filename is written out as
 
17
    repr(filename), which means that it surrounds
 
18
    the name with quotes which may be single or double
 
19
    (single is preferred unless there is a single quote in
 
20
    the filename). And some characters will be escaped.
 
21
 
 
22
    TODO:   There has to be some pythonic way of undo-ing the
 
23
            representation of a string rather than using eval.
 
24
    """
 
25
    delimiter = name[0]
 
26
    if name[-1] != delimiter:
 
27
        raise BadChangeset('Could not properly parse the'
 
28
                ' filename: %r' % name)
 
29
    # We need to handle escaped hexadecimals too.
 
30
    return name[1:-1].replace('\"', '"').replace("\'", "'")
14
31
 
15
32
class ChangesetInfo(object):
16
33
    """This is the intermediate class that gets filled out as
84
101
        """Create the actual changeset object.
85
102
        """
86
103
        self.info.create_maps()
 
104
        cset = bzrlib.changeset.Changeset()
 
105
        
 
106
        for info, lines in self.info.actions:
 
107
            parts = info.split(' ')
 
108
            action = parts[0]
 
109
            kind = parts[1]
 
110
            extra = ' '.join(parts[2:])
 
111
            if action == 'renamed':
 
112
                old_name, new_name = extra.split(' => ')
 
113
                old_name = _unescape(old_name)
 
114
                new_name = _unescape(new_name)
 
115
            else:
 
116
                new_name = _unescape(extra)
87
117
        return self.info
88
118
 
89
119
    def _read_header(self):