~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Aaron Bentley
  • Date: 2006-08-24 03:35:48 UTC
  • mto: (1910.2.43 format-bumps)
  • mto: This revision was merged to the branch mainline in revision 1997.
  • Revision ID: aaron.bentley@utoronto.ca-20060824033548-104450f485b42c75
Fix bugs in basis inventory handling, change filename

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
 
 
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
16
16
 
17
17
 
18
18
# XXX: Can we do any better about making interrupted commits change
19
 
# nothing?  Perhaps the best approach is to integrate commit of
20
 
# AtomicFiles with releasing the lock on the Branch.
 
19
# nothing?  
21
20
 
22
21
# TODO: Separate 'prepare' phase where we find a list of potentially
23
22
# committed files.  We then can then pause the commit to prompt for a
67
66
import re
68
67
import sys
69
68
import time
70
 
import warnings
71
69
 
72
70
from cStringIO import StringIO
73
71
 
74
 
from bzrlib.atomicfile import AtomicFile
75
72
import bzrlib.config
76
73
import bzrlib.errors as errors
77
74
from bzrlib.errors import (BzrError, PointlessCommit,
85
82
from bzrlib.trace import mutter, note, warning
86
83
from bzrlib.xml5 import serializer_v5
87
84
from bzrlib.inventory import Inventory, ROOT_ID, InventoryEntry
 
85
from bzrlib import symbol_versioning
88
86
from bzrlib.symbol_versioning import (deprecated_passed,
89
87
        deprecated_function,
90
 
        zero_seven,
91
88
        DEPRECATED_PARAMETER)
92
89
from bzrlib.workingtree import WorkingTree
93
90
 
94
91
 
95
 
@deprecated_function(zero_seven)
96
 
def commit(*args, **kwargs):
97
 
    """Commit a new revision to a branch.
98
 
 
99
 
    Function-style interface for convenience of old callers.
100
 
 
101
 
    New code should use the Commit class instead.
102
 
    """
103
 
    ## XXX: Remove this in favor of WorkingTree.commit?
104
 
    Commit().commit(*args, **kwargs)
105
 
 
106
 
 
107
92
class NullCommitReporter(object):
108
93
    """I report on progress of a commit."""
109
94
 
223
208
        mutter('preparing to commit')
224
209
 
225
210
        if deprecated_passed(branch):
226
 
            warnings.warn("Commit.commit (branch, ...): The branch parameter is "
 
211
            symbol_versioning.warn("Commit.commit (branch, ...): The branch parameter is "
227
212
                 "deprecated as of bzr 0.8. Please use working_tree= instead.",
228
213
                 DeprecationWarning, stacklevel=2)
229
214
            self.branch = branch
308
293
                raise PointlessCommit()
309
294
 
310
295
            self._emit_progress_update()
311
 
            # TODO: Now the new inventory is known, check for conflicts and prompt the 
312
 
            # user for a commit message.
 
296
            # TODO: Now the new inventory is known, check for conflicts and
 
297
            # prompt the user for a commit message.
 
298
            # ADHB 2006-08-08: If this is done, populate_new_inv should not add
 
299
            # weave lines, because nothing should be recorded until it is known
 
300
            # that commit will succeed.
313
301
            self.builder.finish_inventory()
314
302
            self._emit_progress_update()
315
303
            self.rev_id = self.builder.commit(self.message)
499
487
        """
500
488
        # ESEPARATIONOFCONCERNS: this function is diffing and using the diff
501
489
        # results to create a new inventory at the same time, which results
502
 
        # in bugs like #46635.  Any reason not to use/enhance compare_trees?
 
490
        # in bugs like #46635.  Any reason not to use/enhance Tree.changes_from?
503
491
        # ADHB 11-07-2006
504
492
        mutter("Selecting files for commit with filter %s", self.specific_files)
505
 
        # iter_entries does not visit the ROOT_ID node so we need to call
506
 
        # self._emit_progress_update once by hand.
507
 
        self._emit_progress_update()
508
 
        for path, new_ie in self.work_inv.iter_entries():
 
493
        entries = self.work_inv.iter_entries()
 
494
        if not self.builder.record_root_entry:
 
495
            symbol_versioning.warn('CommitBuilders should support recording'
 
496
                ' the root entry as of bzr 0.10.', DeprecationWarning, 
 
497
                stacklevel=1)
 
498
            self.builder.new_inventory.add(self.basis_inv.root.copy())
 
499
            entries.next()
 
500
            self._emit_progress_update()
 
501
        for path, new_ie in entries:
509
502
            self._emit_progress_update()
510
503
            file_id = new_ie.file_id
511
 
            mutter('check %s {%s}', path, file_id)
 
504
            # mutter('check %s {%s}', path, file_id)
512
505
            if (not self.specific_files or 
513
506
                is_inside_or_parent_of_any(self.specific_files, path)):
514
 
                    mutter('%s selected for commit', path)
 
507
                    # mutter('%s selected for commit', path)
515
508
                    ie = new_ie.copy()
516
509
                    ie.revision = None
517
510
            else:
518
 
                mutter('%s not selected for commit', path)
 
511
                # mutter('%s not selected for commit', path)
519
512
                if self.basis_inv.has_id(file_id):
520
513
                    ie = self.basis_inv[file_id].copy()
521
514
                else: