/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: Robert Collins
  • Date: 2006-04-21 01:36:11 UTC
  • mto: (1711.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1712.
  • Revision ID: robertc@robertcollins.net-20060421013611-ab6ba40b07f615e2
Add a progress bar during commit operations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
245
245
            self.reporter = reporter
246
246
 
247
247
        self.work_tree.lock_write()
 
248
        self.pb = bzrlib.ui.ui_factory.nested_progress_bar()
248
249
        try:
 
250
            # Cannot commit with conflicts present.
 
251
            if len(self.work_tree.conflicts())>0:
 
252
                raise ConflictsInTree
 
253
 
249
254
            # setup the bound branch variables as needed.
250
255
            self._check_bound_branch()
251
256
 
293
298
            self.work_inv = self.work_tree.inventory
294
299
            self.basis_tree = self.work_tree.basis_tree()
295
300
            self.basis_inv = self.basis_tree.inventory
 
301
            # one to finish, one for rev and inventory, and one for each
 
302
            # inventory entry, and the same for the new inventory.
 
303
            # note that this estimate is too long when we do a partial tree
 
304
            # commit which excludes some new files from being considered.
 
305
            # The estimate is corrected when we populate the new inv.
 
306
            self.pb_total = len(self.basis_inv) + len(self.work_inv) + 3 - 1
 
307
            self.pb_count = 0
296
308
 
297
309
            self._gather_parents()
298
310
            if len(self.parents) > 1 and self.specific_files:
309
321
                    or self.new_inv != self.basis_inv):
310
322
                raise PointlessCommit()
311
323
 
312
 
            if len(self.work_tree.conflicts())>0:
313
 
                raise ConflictsInTree
314
 
 
 
324
            self._update()
315
325
            self.inv_sha1 = self.branch.repository.add_inventory(
316
326
                self.rev_id,
317
327
                self.new_inv,
318
328
                self.present_parents
319
329
                )
 
330
            self._update()
320
331
            self._make_revision()
321
332
            # revision data is in the local branch now.
322
333
            
346
357
                                  {'branch':self.branch,
347
358
                                   'bzrlib':bzrlib,
348
359
                                   'rev_id':self.rev_id})
 
360
            self._update()
349
361
        finally:
350
 
            self._cleanup_bound_branch()
351
 
            self.work_tree.unlock()
 
362
            self._cleanup()
352
363
 
353
364
    def _check_bound_branch(self):
354
365
        """Check to see if the local branch is bound.
400
411
####                self.master_branch.repository.fetch(self.bound_branch.repository,
401
412
####                                                    revision_id=revision_id)
402
413
 
 
414
    def _cleanup(self):
 
415
        """Cleanup any open locks, progress bars etc."""
 
416
        cleanups = [self._cleanup_bound_branch,
 
417
                    self.work_tree.unlock,
 
418
                    self.pb.finished]
 
419
        found_exception = None
 
420
        for cleanup in cleanups:
 
421
            try:
 
422
                cleanup()
 
423
            # we want every cleanup to run no matter what.
 
424
            # so we have a catchall here, but we will raise the
 
425
            # last encountered exception up the stack: and
 
426
            # typically this will be useful enough.
 
427
            except Exception, e:
 
428
                found_exception = e
 
429
        if found_exception is not None: 
 
430
            # dont do a plan raise, because the last exception may have been
 
431
            # trashed, e is our sure-to-work exception even though it loses the
 
432
            # full traceback. XXX: RBC 20060421 perhaps we could check the
 
433
            # exc_info and if its the same one do a plain raise otherwise 
 
434
            # 'raise e' as we do now.
 
435
            raise e
 
436
 
403
437
    def _cleanup_bound_branch(self):
404
438
        """Executed at the end of a try/finally to cleanup a bound branch.
405
439
 
503
537
        # XXX: Need to think more here about when the user has
504
538
        # made a specific decision on a particular value -- c.f.
505
539
        # mark-merge.  
 
540
 
 
541
        # iter_entries does not visit the ROOT_ID node so we need to call
 
542
        # self._update once by hand.
 
543
        self._update()
506
544
        for path, ie in self.new_inv.iter_entries():
 
545
            self._update()
507
546
            previous_entries = ie.find_previous_heads(
508
547
                self.parent_invs,
509
548
                self.weave_store,
528
567
        """
529
568
        mutter("Selecting files for commit with filter %s", self.specific_files)
530
569
        self.new_inv = Inventory(revision_id=self.rev_id)
 
570
        # iter_entries does not visit the ROOT_ID node so we need to call
 
571
        # self._update once by hand.
 
572
        self._update()
531
573
        for path, new_ie in self.work_inv.iter_entries():
 
574
            self._update()
532
575
            file_id = new_ie.file_id
533
576
            mutter('check %s {%s}', path, new_ie.file_id)
534
577
            if self.specific_files:
554
597
            mutter('%s selected for commit', path)
555
598
            self._select_entry(new_ie)
556
599
 
 
600
    def _update(self):
 
601
        """Emit an update to the progress bar."""
 
602
        self.pb.update("Committing", self.pb_count, self.pb_total)
 
603
        self.pb_count += 1
 
604
 
557
605
    def _select_entry(self, new_ie):
558
606
        """Make new_ie be considered for committing."""
559
607
        ie = new_ie.copy()
565
613
        """Carry the file unchanged from the basis revision."""
566
614
        if self.basis_inv.has_id(file_id):
567
615
            self.new_inv.add(self.basis_inv[file_id].copy())
 
616
        else:
 
617
            # this entry is new and not being committed
 
618
            self.pb_total -= 1
568
619
 
569
620
    def _report_deletes(self):
570
621
        for file_id in self.basis_inv: