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

  • Committer: John Arbash Meinel
  • Date: 2005-09-23 18:30:46 UTC
  • mto: (1185.31.24 bzr-jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1512.
  • Revision ID: john@arbash-meinel.com-20050923183046-1d5dc250bb7d4e4d
Adding ability to revert back to earlier revisions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    In the future, uncommit will create a changeset, which can then
21
21
    be re-applied.
22
22
    """
23
 
    takes_options = ['remove', 'dry-run', 'verbose']
 
23
    takes_options = ['remove', 'dry-run', 'verbose', 'revision']
24
24
    takes_args = ['location?']
25
25
    aliases = []
26
26
 
27
27
    def run(self, location=None, remove=False,
28
 
            dry_run=False, verbose=False):
 
28
            dry_run=False, verbose=False,
 
29
            revision=None):
29
30
        from bzrlib.branch import Branch
30
31
        from bzrlib.log import log_formatter
31
32
        import uncommit, sys
34
35
            location = '.'
35
36
        b = Branch.open_containing(location)
36
37
 
37
 
        revno = b.revno()
38
 
        rev_id = b.last_patch()
 
38
        if revision is None:
 
39
            revno = b.revno()
 
40
            rev_id = b.last_patch()
 
41
        else:
 
42
            revno, rev_id = revision[0].in_history(b)
39
43
        if rev_id is None:
40
44
            print 'No revisions to uncommit.'
41
45
 
42
 
        lf = log_formatter('short', to_file=sys.stdout,show_timezone='original')
43
 
        lf.show(revno, b.get_revision(rev_id), None)
 
46
        for r in range(revno, b.revno()+1):
 
47
            rev_id = b.get_rev_id(revno)
 
48
            lf = log_formatter('short', to_file=sys.stdout,show_timezone='original')
 
49
            lf.show(r, b.get_revision(rev_id), None)
44
50
 
45
 
        print 'The above revision will be removed.'
 
51
        print 'The above revision(s) will be removed.'
46
52
        val = raw_input('Are you sure [y/N]? ')
47
53
        if val.lower() not in ('y', 'yes'):
48
54
            print 'Canceled'
49
55
            return 0
50
56
 
51
57
        uncommit.uncommit(b, remove_files=remove,
52
 
                dry_run=dry_run, verbose=verbose)
 
58
                dry_run=dry_run, verbose=verbose,
 
59
                revno=revno)
53
60
 
54
61
bzrlib.commands.register_command(cmd_uncommit)
55
62
bzrlib.commands.OPTIONS['remove'] = None