/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/builtins.py

  • Committer: Aaron Bentley
  • Date: 2007-12-04 03:36:03 UTC
  • mfrom: (3073 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3133.
  • Revision ID: aaron.bentley@utoronto.ca-20071204033603-equ8y41vfk8vkway
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
3574
3574
    def run(self, location=None,
3575
3575
            dry_run=False, verbose=False,
3576
3576
            revision=None, force=False):
3577
 
        from bzrlib.log import log_formatter, show_log
3578
 
        from bzrlib.uncommit import uncommit
3579
 
 
3580
3577
        if location is None:
3581
3578
            location = u'.'
3582
3579
        control, relpath = bzrdir.BzrDir.open_containing(location)
3587
3584
            tree = None
3588
3585
            b = control.open_branch()
3589
3586
 
 
3587
        if tree is not None:
 
3588
            tree.lock_write()
 
3589
        else:
 
3590
            b.lock_write()
 
3591
        try:
 
3592
            return self._run(b, tree, dry_run, verbose, revision, force)
 
3593
        finally:
 
3594
            if tree is not None:
 
3595
                tree.unlock()
 
3596
            else:
 
3597
                b.unlock()
 
3598
 
 
3599
    def _run(self, b, tree, dry_run, verbose, revision, force):
 
3600
        from bzrlib.log import log_formatter, show_log
 
3601
        from bzrlib.uncommit import uncommit
 
3602
 
 
3603
        last_revno, last_rev_id = b.last_revision_info()
 
3604
 
3590
3605
        rev_id = None
3591
3606
        if revision is None:
3592
 
            revno = b.revno()
 
3607
            revno = last_revno
 
3608
            rev_id = last_rev_id
3593
3609
        else:
3594
3610
            # 'bzr uncommit -r 10' actually means uncommit
3595
3611
            # so that the final tree is at revno 10.
3596
3612
            # but bzrlib.uncommit.uncommit() actually uncommits
3597
3613
            # the revisions that are supplied.
3598
3614
            # So we need to offset it by one
3599
 
            revno = revision[0].in_history(b).revno+1
 
3615
            revno = revision[0].in_history(b).revno + 1
 
3616
            if revno <= last_revno:
 
3617
                rev_id = b.get_rev_id(revno)
3600
3618
 
3601
 
        if revno <= b.revno():
3602
 
            rev_id = b.get_rev_id(revno)
3603
3619
        if rev_id is None or _mod_revision.is_null(rev_id):
3604
3620
            self.outf.write('No revisions to uncommit.\n')
3605
3621
            return 1
3613
3629
                 verbose=False,
3614
3630
                 direction='forward',
3615
3631
                 start_revision=revno,
3616
 
                 end_revision=b.revno())
 
3632
                 end_revision=last_revno)
3617
3633
 
3618
3634
        if dry_run:
3619
3635
            print 'Dry-run, pretending to remove the above revisions.'
3628
3644
                    return 0
3629
3645
 
3630
3646
        uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
3631
 
                revno=revno)
 
3647
                 revno=revno)
3632
3648
 
3633
3649
 
3634
3650
class cmd_break_lock(Command):