~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Aaron Bentley
  • Date: 2005-07-29 17:19:16 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-20050729171916-322fd81b451d2e3e
Added merge-type parameter to merge.

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