~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Aaron Bentley
  • Date: 2005-07-26 15:25:58 UTC
  • mto: (1092.1.41) (1185.3.4) (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 1020.
  • Revision ID: abentley@panoramicfeedback.com-20050726152558-c47bb2bd0163e1a8
Replaced popen with subprocess in patch..py

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