~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-08-27 04:42:41 UTC
  • mfrom: (1092.1.43)
  • mto: (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1178.
  • Revision ID: aaron.bentley@utoronto.ca-20050827044241-23d676133b9fc981
Merge of robertc@robertcollins.net-20050826013321-52eee1f1da679ee9

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
 
 
19
# FIXME: "bzr commit doc/format" commits doc/format.txt!
 
20
 
19
21
def commit(branch, message,
20
22
           timestamp=None,
21
23
           timezone=None,
57
59
        If null (default), a time/random revision id is generated.
58
60
    """
59
61
 
60
 
    import time, tempfile, re
 
62
    import time, tempfile
61
63
 
62
64
    from bzrlib.osutils import local_time_offset, username
63
65
    from bzrlib.branch import gen_file_id
64
66
    from bzrlib.errors import BzrError, PointlessCommit
65
67
    from bzrlib.revision import Revision, RevisionReference
66
68
    from bzrlib.trace import mutter, note
67
 
    from bzrlib.xml import serializer_v4
 
69
    from bzrlib.xml import pack_xml
68
70
 
69
71
    branch.lock_write()
70
72
 
121
123
        inv_id = rev_id
122
124
 
123
125
        inv_tmp = tempfile.TemporaryFile()
124
 
        
125
 
        serializer_v4.write_inventory(new_inv, inv_tmp)
 
126
        pack_xml(new_inv, inv_tmp)
126
127
        inv_tmp.seek(0)
127
128
        branch.inventory_store.add(inv_tmp, inv_id)
128
129
        mutter('new inventory_id is {%s}' % inv_id)
144
145
            timezone = local_time_offset()
145
146
 
146
147
        mutter("building commit log message")
147
 
        # Python strings can include characters that can't be
148
 
        # represented in well-formed XML; escape characters that
149
 
        # aren't listed in the XML specification
150
 
        # (http://www.w3.org/TR/REC-xml/#NT-Char).
151
 
        if isinstance(message, unicode):
152
 
            char_pattern = u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]'
153
 
        else:
154
 
            # Use a regular 'str' as pattern to avoid having re.subn
155
 
            # return 'unicode' results.
156
 
            char_pattern = '[^x09\x0A\x0D\x20-\xFF]'
157
 
        message, escape_count = re.subn(
158
 
            char_pattern,
159
 
            lambda match: match.group(0).encode('unicode_escape'),
160
 
            message)
161
 
        if escape_count:
162
 
            note("replaced %d control characters in message", escape_count)
163
148
        rev = Revision(timestamp=timestamp,
164
149
                       timezone=timezone,
165
150
                       committer=committer,
177
162
            rev.parents.append(RevisionReference(merge_rev))            
178
163
 
179
164
        rev_tmp = tempfile.TemporaryFile()
180
 
        serializer_v4.write_revision(rev, rev_tmp)
 
165
        pack_xml(rev, rev_tmp)
181
166
        rev_tmp.seek(0)
182
167
        branch.revision_store.add(rev_tmp, rev_id)
183
168
        mutter("new revision_id is {%s}" % rev_id)
264
249
        if not work_tree.has_id(file_id):
265
250
            if verbose:
266
251
                print('deleted %s%s' % (path, kind_marker(entry.kind)))
267
 
            any_changes = True
 
252
                any_changes = True
268
253
            mutter("    file is missing, removing from inventory")
269
254
            missing_ids.append(file_id)
270
255
            continue
326
311
            else:
327
312
                print 'renamed', marked
328
313
                any_changes = True
329
 
        elif old_ie != entry:
330
 
            any_changes = True
331
 
 
 
314
                        
332
315
    return missing_ids, inv, any_changes
333
316
 
334
317