/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-06-27 21:57:33 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-20050627215733-f4419eee3c33dd37
Updated for new log_formatter.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
"""\
 
3
Remove the last committed revision.
 
4
Does not modify the working tree, use 'bzr revert' for that.
 
5
"""
 
6
 
 
7
import bzrlib, bzrlib.commands
 
8
 
 
9
class cmd_uncommit(bzrlib.commands.Command):
 
10
    """Remove the last committed revision.
 
11
 
 
12
    By supplying the --remove flag, it will not only remove the entry 
 
13
    from revision_history, but also remove all of the entries in the
 
14
    stores.
 
15
 
 
16
    --verbose will print out what is being removed.
 
17
    --dry-run will go through all the motions, but not actually
 
18
    remove anything.
 
19
    
 
20
    In the future, uncommit will create a changeset, which can then
 
21
    be re-applied.
 
22
    """
 
23
    takes_options = ['remove', 'dry-run', 'verbose']
 
24
    takes_args = ['location?']
 
25
    aliases = []
 
26
 
 
27
    def run(self, location=None, remove=False,
 
28
            dry_run=False, verbose=False):
 
29
        from bzrlib.branch import find_branch
 
30
        from bzrlib.log import log_formatter
 
31
        import uncommit, sys
 
32
 
 
33
        if location is None:
 
34
            location = '.'
 
35
        b = find_branch(location)
 
36
 
 
37
        revno = b.revno()
 
38
        rev_id = b.last_patch()
 
39
        if rev_id is None:
 
40
            print 'No revisions to uncommit.'
 
41
 
 
42
        lf = log_formatter('short', to_file=sys.stdout)
 
43
        lf.show(revno, b.get_revision(rev_id), None)
 
44
 
 
45
        print 'The above revision will be removed.'
 
46
        val = raw_input('Are you sure [y/N]? ')
 
47
        if val.lower() not in ('y', 'yes'):
 
48
            print 'Canceled'
 
49
            return 0
 
50
 
 
51
        uncommit.uncommit(b, remove_files=remove,
 
52
                dry_run=dry_run, verbose=verbose)
 
53
 
 
54
bzrlib.commands.register_command(cmd_uncommit)
 
55
bzrlib.commands.OPTIONS['remove'] = None
 
56
bzrlib.commands.OPTIONS['dry-run'] = None