/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/builtins.py

  • Committer: Martin Pool
  • Date: 2008-07-14 07:47:45 UTC
  • mfrom: (3536 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3537.
  • Revision ID: mbp@sourcefrog.net-20080714074745-ow7wqktgjbn6xb6q
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1895
1895
        ]
1896
1896
    
1897
1897
    def run(self, name_pattern_list=None, old_default_rules=None):
1898
 
        from bzrlib.atomicfile import AtomicFile
 
1898
        from bzrlib import ignores
1899
1899
        if old_default_rules is not None:
1900
1900
            # dump the rules and exit
1901
1901
            for pattern in ignores.OLD_DEFAULTS:
1912
1912
                raise errors.BzrCommandError(
1913
1913
                    "NAME_PATTERN should not be an absolute path")
1914
1914
        tree, relpath = WorkingTree.open_containing(u'.')
1915
 
        ifn = tree.abspath('.bzrignore')
1916
 
        if os.path.exists(ifn):
1917
 
            f = open(ifn, 'rt')
1918
 
            try:
1919
 
                igns = f.read().decode('utf-8')
1920
 
            finally:
1921
 
                f.close()
1922
 
        else:
1923
 
            igns = ''
1924
 
 
1925
 
        # TODO: If the file already uses crlf-style termination, maybe
1926
 
        # we should use that for the newly added lines?
1927
 
 
1928
 
        if igns and igns[-1] != '\n':
1929
 
            igns += '\n'
1930
 
        for name_pattern in name_pattern_list:
1931
 
            igns += name_pattern + '\n'
1932
 
 
1933
 
        f = AtomicFile(ifn, 'wb')
1934
 
        try:
1935
 
            f.write(igns.encode('utf-8'))
1936
 
            f.commit()
1937
 
        finally:
1938
 
            f.close()
1939
 
 
1940
 
        if not tree.path2id('.bzrignore'):
1941
 
            tree.add(['.bzrignore'])
1942
 
 
 
1915
        ignores.tree_ignores_add_patterns(tree, name_pattern_list)
1943
1916
        ignored = globbing.Globster(name_pattern_list)
1944
1917
        matches = []
1945
1918
        tree.lock_read()
2304
2277
 
2305
2278
 
2306
2279
class cmd_check(Command):
2307
 
    """Validate consistency of branch history.
2308
 
 
2309
 
    This command checks various invariants about the branch storage to
2310
 
    detect data corruption or bzr bugs.
2311
 
 
2312
 
    Output fields:
 
2280
    """Validate working tree structure, branch consistency and repository
 
2281
    history.
 
2282
 
 
2283
    This command checks various invariants about branch and repository storage
 
2284
    to detect data corruption or bzr bugs.
 
2285
 
 
2286
    The working tree and branch checks will only give output if a problem is
 
2287
    detected. The output fields of the repository check are:
2313
2288
 
2314
2289
        revisions: This is just the number of revisions checked.  It doesn't
2315
2290
            indicate a problem.
2327
2302
    """
2328
2303
 
2329
2304
    _see_also = ['reconcile']
2330
 
    takes_args = ['branch?']
 
2305
    takes_args = ['path?']
2331
2306
    takes_options = ['verbose']
2332
2307
 
2333
 
    def run(self, branch=None, verbose=False):
2334
 
        from bzrlib.check import check
2335
 
        if branch is None:
2336
 
            branch_obj = Branch.open_containing('.')[0]
2337
 
        else:
2338
 
            branch_obj = Branch.open(branch)
2339
 
        check(branch_obj, verbose)
2340
 
        # bit hacky, check the tree parent is accurate
2341
 
        try:
2342
 
            if branch is None:
2343
 
                tree = WorkingTree.open_containing('.')[0]
2344
 
            else:
2345
 
                tree = WorkingTree.open(branch)
2346
 
        except (errors.NoWorkingTree, errors.NotLocalUrl):
2347
 
            pass
2348
 
        else:
2349
 
            # This is a primitive 'check' for tree state. Currently this is not
2350
 
            # integrated into the main check logic as yet.
2351
 
            tree.lock_read()
2352
 
            try:
2353
 
                tree_basis = tree.basis_tree()
2354
 
                tree_basis.lock_read()
2355
 
                try:
2356
 
                    repo_basis = tree.branch.repository.revision_tree(
2357
 
                        tree.last_revision())
2358
 
                    if len(list(repo_basis.iter_changes(tree_basis))):
2359
 
                        raise errors.BzrCheckError(
2360
 
                            "Mismatched basis inventory content.")
2361
 
                    tree._validate()
2362
 
                finally:
2363
 
                    tree_basis.unlock()
2364
 
            finally:
2365
 
                tree.unlock()
 
2308
    def run(self, path=None, verbose=False):
 
2309
        from bzrlib.check import check_dwim
 
2310
        if path is None:
 
2311
            path = '.'
 
2312
        check_dwim(path, verbose)
2366
2313
 
2367
2314
 
2368
2315
class cmd_upgrade(Command):
4073
4020
    To use a specific mail program, set the mail_client configuration option.
4074
4021
    (For Thunderbird 1.5, this works around some bugs.)  Supported values for
4075
4022
    specific clients are "evolution", "kmail", "mutt", and "thunderbird";
4076
 
    generic options are "default", "editor", "mapi", and "xdg-email".
 
4023
    generic options are "default", "editor", "emacsclient", "mapi", and
 
4024
    "xdg-email".
4077
4025
 
4078
4026
    If mail is being sent, a to address is required.  This can be supplied
4079
4027
    either on the commandline, by setting the submit_to configuration