/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 bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2005-05-16 02:39:42 UTC
  • Revision ID: mbp@sourcefrog.net-20050516023942-efa5514b55d0be3e
bugfix for bzr ignore reported by ddaa:
 - read in old .bzrignore file correctly
 - make sure files get closed properly

Show diffs side-by-side

added added

removed removed

Lines of Context:
677
677
        b = Branch('.')
678
678
        ifn = b.abspath('.bzrignore')
679
679
 
680
 
        # FIXME: probably doesn't handle non-ascii patterns
681
 
 
682
680
        if os.path.exists(ifn):
683
 
            f = b.controlfile(ifn, 'rt')
684
 
            igns = f.read()
685
 
            f.close()
 
681
            f = open(ifn, 'rt')
 
682
            try:
 
683
                igns = f.read().decode('utf-8')
 
684
            finally:
 
685
                f.close()
686
686
        else:
687
687
            igns = ''
688
688
 
690
690
            igns += '\n'
691
691
        igns += name_pattern + '\n'
692
692
 
693
 
        f = AtomicFile(ifn, 'wt')
694
 
        f.write(igns)
695
 
        f.commit()
 
693
        try:
 
694
            f = AtomicFile(ifn, 'wt')
 
695
            f.write(igns.encode('utf-8'))
 
696
            f.commit()
 
697
        finally:
 
698
            f.close()
696
699
 
697
700
        inv = b.working_tree().inventory
698
701
        if inv.path2id('.bzrignore'):