~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: John Arbash Meinel
  • Date: 2005-10-27 21:31:30 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-20051027213130-d2c5a6c65a3bfbb2
Updated to latest bzr.dev code, and added tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    In the future, uncommit will create a changeset, which can then
22
22
    be re-applied.
23
23
    """
24
 
    takes_options = ['all', 'dry-run', 'verbose', 'revision']
 
24
    takes_options = ['all', 'verbose', 'revision',
 
25
                    Option('dry-run', help='Don\'t actually make changes'),
 
26
                    Option('force', help='Say yes to all questions.')]
25
27
    takes_args = ['location?']
26
28
    aliases = []
27
29
 
28
30
    def run(self, location=None, all=False,
29
31
            dry_run=False, verbose=False,
30
 
            revision=None):
 
32
            revision=None, force=False):
31
33
        from bzrlib.branch import Branch
32
34
        from bzrlib.log import log_formatter
33
35
        import uncommit, sys
34
36
 
35
37
        if location is None:
36
38
            location = '.'
37
 
        b = Branch.open_containing(location)
 
39
        b, relpath = Branch.open_containing(location)
38
40
 
39
41
        if revision is None:
40
42
            revno = b.revno()
51
53
 
52
54
        if dry_run:
53
55
            print 'Dry-run, pretending to remove the above revisions.'
54
 
            val = raw_input('Press <enter> to continue')
 
56
            if not force:
 
57
                val = raw_input('Press <enter> to continue')
55
58
        else:
56
59
            print 'The above revision(s) will be removed.'
57
 
            val = raw_input('Are you sure [y/N]? ')
58
 
            if val.lower() not in ('y', 'yes'):
59
 
                print 'Canceled'
60
 
                return 0
 
60
            if not force:
 
61
                val = raw_input('Are you sure [y/N]? ')
 
62
                if val.lower() not in ('y', 'yes'):
 
63
                    print 'Canceled'
 
64
                    return 0
61
65
 
62
66
        uncommit.uncommit(b, remove_files=all,
63
67
                dry_run=dry_run, verbose=verbose,
64
68
                revno=revno)
65
69
 
66
70
bzrlib.commands.register_command(cmd_uncommit)
67
 
Option.OPTIONS['dry-run'] = Option('dry-run')
 
71
 
 
72
def test_suite():
 
73
    from unittest import TestSuite, TestLoader
 
74
    import test_uncommit
 
75
 
 
76
    suite = TestSuite()
 
77
 
 
78
    suite.addTest(TestLoader().loadTestsFromModule(test_uncommit))
 
79
 
 
80
    return suite
 
81