/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Martin Pool
  • Date: 2005-07-04 12:11:40 UTC
  • Revision ID: mbp@sourcefrog.net-20050704121140-fc4ab493bedc2e2f
- Deferred patch that uses Python ndiff format.

  This highlights the changes within a line, which is rather nice.  But it also
  outputs the entire file, which is less good.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
           committer=None,
25
25
           verbose=True,
26
26
           specific_files=None,
27
 
           rev_id=None,
28
 
           allow_pointless=True):
 
27
           rev_id=None):
29
28
    """Commit working copy as a new revision.
30
29
 
31
30
    The basic approach is to add all the file texts into the
42
41
    be robust against files disappearing, moving, etc.  So the
43
42
    whole thing is a bit hard.
44
43
 
45
 
    This raises PointlessCommit if there are no changes, no new merges,
46
 
    and allow_pointless  is false.
47
 
 
48
44
    timestamp -- if not None, seconds-since-epoch for a
49
45
         postdated/predated commit.
50
46
 
63
59
 
64
60
    from bzrlib.osutils import local_time_offset, username
65
61
    from bzrlib.branch import gen_file_id
66
 
    from bzrlib.errors import BzrError, PointlessCommit
 
62
    from bzrlib.errors import BzrError
67
63
    from bzrlib.revision import Revision, RevisionReference
68
64
    from bzrlib.trace import mutter, note
69
65
    from bzrlib.xml import pack_xml
89
85
 
90
86
        pending_merges = branch.pending_merges()
91
87
 
92
 
        missing_ids, new_inv, any_changes = \
93
 
                     _gather_commit(branch,
94
 
                                    work_tree,
95
 
                                    work_inv,
96
 
                                    basis_inv,
97
 
                                    specific_files,
98
 
                                    verbose)
99
 
 
100
 
        if not (any_changes or allow_pointless or pending_merges):
101
 
            raise PointlessCommit()
 
88
        missing_ids, new_inv = _gather_commit(branch,
 
89
                                              work_tree,
 
90
                                              work_inv,
 
91
                                              basis_inv,
 
92
                                              specific_files,
 
93
                                              verbose)
102
94
 
103
95
        for file_id in missing_ids:
104
96
            # Any files that have been deleted are now removed from the
177
169
 
178
170
        branch.append_revision(rev_id)
179
171
 
180
 
        branch.set_pending_merges([])
181
 
 
182
172
        if verbose:
183
173
            note("commited r%d" % branch.revno())
184
174
    finally:
200
190
                   verbose):
201
191
    """Build inventory preparatory to commit.
202
192
 
203
 
    Returns missing_ids, new_inv, any_changes.
204
 
 
205
193
    This adds any changed files into the text store, and sets their
206
194
    test-id, sha and size in the returned inventory appropriately.
207
195
 
211
199
        working inventory.
212
200
    """
213
201
    from bzrlib.inventory import Inventory
214
 
    from bzrlib.osutils import isdir, isfile, sha_string, quotefn, \
 
202
    from osutils import isdir, isfile, sha_string, quotefn, \
215
203
         local_time_offset, username, kind_marker, is_inside_any
216
204
    
217
 
    from bzrlib.branch import gen_file_id
218
 
    from bzrlib.errors import BzrError
219
 
    from bzrlib.revision import Revision
 
205
    from branch import gen_file_id
 
206
    from errors import BzrError
 
207
    from revision import Revision
220
208
    from bzrlib.trace import mutter, note
221
209
 
222
 
    any_changes = False
223
 
    inv = Inventory(work_inv.root.file_id)
 
210
    inv = Inventory()
224
211
    missing_ids = []
225
212
    
226
213
    for path, entry in work_inv.iter_entries():
232
219
        mutter('commit prep file %s, id %r ' % (p, file_id))
233
220
 
234
221
        if specific_files and not is_inside_any(specific_files, path):
235
 
            mutter('  skipping file excluded from commit')
236
222
            if basis_inv.has_id(file_id):
237
223
                # carry over with previous state
238
224
                inv.add(basis_inv[file_id].copy())
244
230
        if not work_tree.has_id(file_id):
245
231
            if verbose:
246
232
                print('deleted %s%s' % (path, kind_marker(entry.kind)))
247
 
                any_changes = True
248
233
            mutter("    file is missing, removing from inventory")
249
234
            missing_ids.append(file_id)
250
235
            continue
296
281
            marked = path + kind_marker(entry.kind)
297
282
            if not old_ie:
298
283
                print 'added', marked
299
 
                any_changes = True
300
284
            elif old_ie == entry:
301
285
                pass                    # unchanged
302
286
            elif (old_ie.name == entry.name
303
287
                  and old_ie.parent_id == entry.parent_id):
304
288
                print 'modified', marked
305
 
                any_changes = True
306
289
            else:
307
290
                print 'renamed', marked
308
 
                any_changes = True
309
291
                        
310
 
    return missing_ids, inv, any_changes
 
292
    return missing_ids, inv
311
293
 
312
294