~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Robert Collins
  • Date: 2007-03-07 08:02:58 UTC
  • mfrom: (2255.2.239 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20070307080258-fi172acyjga89fz5
(robertc) Merge dirstate and subtrees. (Robert Collins, Martin Pool, Aaaron Bentley, John A Meinel, James Westby)

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
               local=False,
174
174
               reporter=None,
175
175
               config=None,
176
 
               message_callback=None):
 
176
               message_callback=None,
 
177
               recursive='down'):
177
178
        """Commit working copy as a new revision.
178
179
 
179
180
        branch -- the deprecated branch to commit to. New callers should pass in 
200
201
 
201
202
        revprops -- Properties for new revision
202
203
        :param local: Perform a local only commit.
 
204
        :param recursive: If set to 'down', commit in any subtrees that have
 
205
            pending changes of any sort during this commit.
203
206
        """
204
207
        mutter('preparing to commit')
205
208
 
214
217
        else:
215
218
            self.work_tree = working_tree
216
219
            self.branch = self.work_tree.branch
 
220
            if getattr(self.work_tree, 'requires_rich_root', lambda: False)():
 
221
                if not self.branch.repository.supports_rich_root():
 
222
                    raise errors.RootNotRich()
217
223
        if message_callback is None:
218
224
            if message is not None:
219
225
                if isinstance(message, str):
230
236
        self.rev_id = None
231
237
        self.specific_files = specific_files
232
238
        self.allow_pointless = allow_pointless
 
239
        self.recursive = recursive
 
240
        self.revprops = revprops
 
241
        self.message_callback = message_callback
 
242
        self.timestamp = timestamp
 
243
        self.timezone = timezone
 
244
        self.committer = committer
 
245
        self.specific_files = specific_files
 
246
        self.strict = strict
 
247
        self.verbose = verbose
 
248
        self.local = local
233
249
 
234
250
        if reporter is None and self.reporter is None:
235
251
            self.reporter = NullCommitReporter()
238
254
 
239
255
        self.work_tree.lock_write()
240
256
        self.pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
257
        self.basis_tree = self.work_tree.basis_tree()
 
258
        self.basis_tree.lock_read()
241
259
        try:
242
260
            # Cannot commit with conflicts present.
243
261
            if len(self.work_tree.conflicts())>0:
273
291
                self.config = self.branch.get_config()
274
292
 
275
293
            self.work_inv = self.work_tree.inventory
276
 
            self.basis_tree = self.work_tree.basis_tree()
277
294
            self.basis_inv = self.basis_tree.inventory
278
295
            if specific_files is not None:
279
296
                # Ensure specified files are versioned
280
297
                # (We don't actually need the ids here)
281
 
                tree.find_ids_across_trees(specific_files, 
 
298
                # XXX: Dont we have filter_unversioned to do this more
 
299
                # cheaply?
 
300
                tree.find_ids_across_trees(specific_files,
282
301
                                           [self.basis_tree, self.work_tree])
283
302
            # one to finish, one for rev and inventory, and one for each
284
303
            # inventory entry, and the same for the new inventory.
293
312
                raise NotImplementedError('selected-file commit of merges is not supported yet: files %r',
294
313
                        self.specific_files)
295
314
            
296
 
            self.builder = self.branch.get_commit_builder(self.parents, 
 
315
            self.builder = self.branch.get_commit_builder(self.parents,
297
316
                self.config, timestamp, timezone, committer, revprops, rev_id)
298
317
            
299
318
            self._remove_deleted()
393
412
                    and (this.parent_id == other.parent_id)
394
413
                    and (this.kind == other.kind)
395
414
                    and (this.executable == other.executable)
 
415
                    and (this.reference_revision == other.reference_revision)
396
416
                    )
397
417
        if not ie_equal_no_revision(new_root_ie, basis_root_ie):
398
418
            return True
469
489
    def _cleanup(self):
470
490
        """Cleanup any open locks, progress bars etc."""
471
491
        cleanups = [self._cleanup_bound_branch,
 
492
                    self.basis_tree.unlock,
472
493
                    self.work_tree.unlock,
473
494
                    self.pb.finished]
474
495
        found_exception = None
588
609
            file_id = new_ie.file_id
589
610
            try:
590
611
                kind = self.work_tree.kind(file_id)
 
612
                if kind == 'tree-reference' and self.recursive == 'down':
 
613
                    # nested tree: commit in it
 
614
                    sub_tree = WorkingTree.open(self.work_tree.abspath(path))
 
615
                    # FIXME: be more comprehensive here:
 
616
                    # this works when both trees are in --trees repository,
 
617
                    # but when both are bound to a different repository,
 
618
                    # it fails; a better way of approaching this is to 
 
619
                    # finally implement the explicit-caches approach design
 
620
                    # a while back - RBC 20070306.
 
621
                    if (sub_tree.branch.repository.bzrdir.root_transport.base
 
622
                        ==
 
623
                        self.work_tree.branch.repository.bzrdir.root_transport.base):
 
624
                        sub_tree.branch.repository = \
 
625
                            self.work_tree.branch.repository
 
626
                    try:
 
627
                        sub_tree.commit(message=None, revprops=self.revprops,
 
628
                            recursive=self.recursive,
 
629
                            message_callback=self.message_callback,
 
630
                            timestamp=self.timestamp, timezone=self.timezone,
 
631
                            committer=self.committer,
 
632
                            allow_pointless=self.allow_pointless,
 
633
                            strict=self.strict, verbose=self.verbose,
 
634
                            local=self.local, reporter=self.reporter)
 
635
                    except errors.PointlessCommit:
 
636
                        pass
591
637
                if kind != new_ie.kind:
592
638
                    new_ie = inventory.make_entry(kind, new_ie.name,
593
639
                                                  new_ie.parent_id, file_id)