~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2006-01-06 02:38:13 UTC
  • mto: (1685.1.1 bzr-encoding)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060106023813-8296d0c0bf579a1f
Updated mkdir, added to test_log

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    return tree, new_list
70
70
 
71
71
 
72
 
def _get_encoded_stdout_file():
 
72
def _get_encoded_stdout(errors='replace'):
73
73
    """Return a file linked to stdout, which has proper encoding."""
74
74
    output_encoding = getattr(sys.stdout, 'encoding', None)
75
75
    if not output_encoding:
80
80
 
81
81
    # use 'replace' so that we don't abort if trying to write out
82
82
    # in e.g. the default C locale.
83
 
    return codecs.getwriter(output_encoding)(sys.stdout, errors='replace')
 
83
    return codecs.getwriter(output_encoding)(sys.stdout, errors=errors)
84
84
 
85
85
 
86
86
 
142
142
 
143
143
        tree, file_list = tree_files(file_list)
144
144
            
145
 
        outf = _get_encoded_stdout_file()
 
145
        outf = _get_encoded_stdout()
146
146
        show_status(tree.branch, show_unchanged=all, show_ids=show_ids,
147
147
                    specific_files=file_list, revision=revision,
148
148
                    to_file=outf)
247
247
    def run(self, file_list, no_recurse=False, dry_run=False, verbose=False):
248
248
        import bzrlib.add
249
249
 
250
 
        to_file = _get_encoded_stdout_file()
 
250
        to_file = _get_encoded_stdout()
251
251
        action = bzrlib.add.AddAction(to_file=to_file,
252
252
            should_add=(not dry_run), should_print=(not is_quiet()))
253
253
 
275
275
    takes_args = ['dir+']
276
276
 
277
277
    def run(self, dir_list):
 
278
        outf = _get_encoded_stdout()
278
279
        for d in dir_list:
279
280
            os.mkdir(d)
280
281
            wt, dd = WorkingTree.open_containing(d)
281
282
            wt.add([dd])
282
 
            print 'added', d
 
283
            outf.write('added ')
 
284
            outf.write(d)
 
285
            outf.write('\n')
283
286
 
284
287
 
285
288
class cmd_relpath(Command):
967
970
        if rev1 > rev2:
968
971
            (rev2, rev1) = (rev1, rev2)
969
972
 
970
 
        outf = _get_encoded_stdout_file()
 
973
        outf = _get_encoded_stdout()
971
974
 
972
975
        log_format = get_log_format(long=long, short=short, line=line)
973
976
        lf = log_formatter(log_format,
1049
1052
            tree = tree.branch.revision_tree(
1050
1053
                revision[0].in_history(tree.branch).rev_id)
1051
1054
 
1052
 
        outf = _get_encoded_stdout_file()
 
1055
        outf = _get_encoded_stdout()
1053
1056
        for fp, fc, kind, fid, entry in tree.list_files():
1054
1057
            if fp.startswith(relpath):
1055
1058
                fp = fp[len(relpath):]