~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Martin Pool
  • Date: 2005-09-06 07:39:09 UTC
  • Revision ID: mbp@sourcefrog.net-20050906073909-234eb078dfff15d9
- improved check for branch version

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
 
 
21
19
def commit(branch, message,
22
20
           timestamp=None,
23
21
           timezone=None,
66
64
    from bzrlib.errors import BzrError, PointlessCommit
67
65
    from bzrlib.revision import Revision, RevisionReference
68
66
    from bzrlib.trace import mutter, note
69
 
    from bzrlib.xml import pack_xml
 
67
    from bzrlib.xml import serializer_v4
70
68
 
71
69
    branch.lock_write()
72
70
 
85
83
        basis_inv = basis.inventory
86
84
 
87
85
        if verbose:
88
 
            note('looking for changes...')
 
86
            # note('looking for changes...')
 
87
            # print 'looking for changes...'
 
88
            # disabled; should be done at a higher level
 
89
            pass
89
90
 
90
91
        pending_merges = branch.pending_merges()
91
92
 
115
116
            if work_inv.has_id(file_id):
116
117
                del work_inv[file_id]
117
118
 
118
 
 
119
119
        if rev_id is None:
120
 
            rev_id = _gen_revision_id(time.time())
 
120
            rev_id = _gen_revision_id(branch, time.time())
121
121
        inv_id = rev_id
122
122
 
123
123
        inv_tmp = tempfile.TemporaryFile()
124
 
        pack_xml(new_inv, inv_tmp)
 
124
        
 
125
        serializer_v4.write_inventory(new_inv, inv_tmp)
125
126
        inv_tmp.seek(0)
126
127
        branch.inventory_store.add(inv_tmp, inv_id)
127
128
        mutter('new inventory_id is {%s}' % inv_id)
137
138
            timestamp = time.time()
138
139
 
139
140
        if committer == None:
140
 
            committer = username()
 
141
            committer = username(branch)
141
142
 
142
143
        if timezone == None:
143
144
            timezone = local_time_offset()
160
161
            rev.parents.append(RevisionReference(merge_rev))            
161
162
 
162
163
        rev_tmp = tempfile.TemporaryFile()
163
 
        pack_xml(rev, rev_tmp)
 
164
        serializer_v4.write_revision(rev, rev_tmp)
164
165
        rev_tmp.seek(0)
165
166
        branch.revision_store.add(rev_tmp, rev_id)
166
167
        mutter("new revision_id is {%s}" % rev_id)
180
181
        branch.set_pending_merges([])
181
182
 
182
183
        if verbose:
183
 
            note("commited r%d" % branch.revno())
 
184
            # disabled; should go through logging
 
185
            # note("commited r%d" % branch.revno())
 
186
            # print ("commited r%d" % branch.revno())
 
187
            pass
184
188
    finally:
185
189
        branch.unlock()
186
190
 
187
191
 
188
192
 
189
 
def _gen_revision_id(when):
 
193
def _gen_revision_id(branch, when):
190
194
    """Return new revision-id."""
191
195
    from binascii import hexlify
192
 
    from osutils import rand_bytes, compact_date, user_email
 
196
    from bzrlib.osutils import rand_bytes, compact_date, user_email
193
197
 
194
 
    s = '%s-%s-' % (user_email(), compact_date(when))
 
198
    s = '%s-%s-' % (user_email(branch), compact_date(when))
195
199
    s += hexlify(rand_bytes(8))
196
200
    return s
197
201