~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Martin Pool
  • Date: 2005-07-11 04:53:07 UTC
  • Revision ID: mbp@sourcefrog.net-20050711045307-2b38378d043dc25c
- Refactor weave calculation of inclusions

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,
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
 
83
85
        basis_inv = basis.inventory
84
86
 
85
87
        if verbose:
86
 
            # note('looking for changes...')
87
 
            # print 'looking for changes...'
88
 
            # disabled; should be done at a higher level
89
 
            pass
 
88
            note('looking for changes...')
90
89
 
91
90
        pending_merges = branch.pending_merges()
92
91
 
116
115
            if work_inv.has_id(file_id):
117
116
                del work_inv[file_id]
118
117
 
 
118
 
119
119
        if rev_id is None:
120
 
            rev_id = _gen_revision_id(branch, time.time())
 
120
            rev_id = _gen_revision_id(time.time())
121
121
        inv_id = rev_id
122
122
 
123
123
        inv_tmp = tempfile.TemporaryFile()
124
 
        
125
 
        serializer_v4.write_inventory(new_inv, inv_tmp)
 
124
        pack_xml(new_inv, inv_tmp)
126
125
        inv_tmp.seek(0)
127
126
        branch.inventory_store.add(inv_tmp, inv_id)
128
127
        mutter('new inventory_id is {%s}' % inv_id)
138
137
            timestamp = time.time()
139
138
 
140
139
        if committer == None:
141
 
            committer = username(branch)
 
140
            committer = username()
142
141
 
143
142
        if timezone == None:
144
143
            timezone = local_time_offset()
161
160
            rev.parents.append(RevisionReference(merge_rev))            
162
161
 
163
162
        rev_tmp = tempfile.TemporaryFile()
164
 
        serializer_v4.write_revision(rev, rev_tmp)
 
163
        pack_xml(rev, rev_tmp)
165
164
        rev_tmp.seek(0)
166
165
        branch.revision_store.add(rev_tmp, rev_id)
167
166
        mutter("new revision_id is {%s}" % rev_id)
181
180
        branch.set_pending_merges([])
182
181
 
183
182
        if verbose:
184
 
            # disabled; should go through logging
185
 
            # note("commited r%d" % branch.revno())
186
 
            # print ("commited r%d" % branch.revno())
187
 
            pass
 
183
            note("commited r%d" % branch.revno())
188
184
    finally:
189
185
        branch.unlock()
190
186
 
191
187
 
192
188
 
193
 
def _gen_revision_id(branch, when):
 
189
def _gen_revision_id(when):
194
190
    """Return new revision-id."""
195
191
    from binascii import hexlify
196
 
    from bzrlib.osutils import rand_bytes, compact_date, user_email
 
192
    from osutils import rand_bytes, compact_date, user_email
197
193
 
198
 
    s = '%s-%s-' % (user_email(branch), compact_date(when))
 
194
    s = '%s-%s-' % (user_email(), compact_date(when))
199
195
    s += hexlify(rand_bytes(8))
200
196
    return s
201
197
 
215
211
        working inventory.
216
212
    """
217
213
    from bzrlib.inventory import Inventory
218
 
    from bzrlib.osutils import isdir, isfile, sha_string, quotefn, \
 
214
    from osutils import isdir, isfile, sha_string, quotefn, \
219
215
         local_time_offset, username, kind_marker, is_inside_any
220
216
    
221
 
    from bzrlib.branch import gen_file_id
222
 
    from bzrlib.errors import BzrError
223
 
    from bzrlib.revision import Revision
 
217
    from branch import gen_file_id
 
218
    from errors import BzrError
 
219
    from revision import Revision
224
220
    from bzrlib.trace import mutter, note
225
221
 
226
222
    any_changes = False
227
 
    inv = Inventory(work_inv.root.file_id)
 
223
    inv = Inventory()
228
224
    missing_ids = []
229
225
    
230
226
    for path, entry in work_inv.iter_entries():