~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

[merge] add --dry-run option (mpe)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
"""builtin bzr commands"""
 
18
 
17
19
# DO NOT change this to cStringIO - it results in control files 
18
20
# written as UCS4
19
21
# FIXIT! (Only deal with byte streams OR unicode at any one layer.)
20
22
# RBC 20051018
 
23
 
21
24
from StringIO import StringIO
22
25
import sys
23
26
import os
213
216
    implicitly add the parent, and so on up to the root. This means
214
217
    you should never need to explictly add a directory, they'll just
215
218
    get added when you add a file in the directory.
 
219
 
 
220
    --dry-run will show which files would be added, but not actually 
 
221
    add them.
216
222
    """
217
223
    takes_args = ['file*']
218
 
    takes_options = ['no-recurse']
219
 
    
220
 
    def run(self, file_list, no_recurse=False):
221
 
        from bzrlib.add import smart_add, add_reporter_print, add_reporter_null
222
 
        if is_quiet():
223
 
            reporter = add_reporter_null
 
224
    takes_options = ['no-recurse', 'dry-run']
 
225
 
 
226
    def run(self, file_list, no_recurse=False, dry_run=False):
 
227
        import bzrlib.add
 
228
 
 
229
        if dry_run:
 
230
            if is_quiet():
 
231
                # This is pointless, but I'd rather not raise an error
 
232
                action = bzrlib.add.add_action_null
 
233
            else:
 
234
                action = bzrlib.add.add_action_print
 
235
        elif is_quiet():
 
236
            action = bzrlib.add.add_action_add
224
237
        else:
225
 
            reporter = add_reporter_print
226
 
        smart_add(file_list, not no_recurse, reporter)
 
238
            action = bzrlib.add.add_action_add_and_print
 
239
 
 
240
        bzrlib.add.smart_add(file_list, not no_recurse, action)
227
241
 
228
242
 
229
243
class cmd_mkdir(Command):