~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-03 13:48:52 UTC
  • mfrom: (1835 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1836.
  • Revision ID: john@arbash-meinel.com-20060703134852-295eeb195b8e2811
[merge] bzr.dev 1835

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import codecs
21
21
import errno
22
22
import os
 
23
import os.path
23
24
import sys
24
25
 
25
26
import bzrlib
28
29
    repository, log)
29
30
from bzrlib.bundle import read_bundle_from_url
30
31
from bzrlib.bundle.apply_bundle import install_bundle, merge_bundle
 
32
from bzrlib.conflicts import ConflictList
31
33
from bzrlib.commands import Command, display_command
32
34
from bzrlib.errors import (BzrError, BzrCheckError, BzrCommandError, 
33
35
                           NotBranchError, DivergedBranches, NotConflicted,
800
802
        tree = WorkingTree.open_containing(dir)[0]
801
803
        tree.lock_write()
802
804
        try:
803
 
            if tree.last_revision() == tree.branch.last_revision():
 
805
            last_rev = tree.last_revision() 
 
806
            if last_rev == tree.branch.last_revision():
804
807
                # may be up to date, check master too.
805
808
                master = tree.branch.get_master_branch()
806
 
                if master is None or master.last_revision == tree.last_revision():
807
 
                    note("Tree is up to date.")
808
 
                    return
 
809
                if master is None or last_rev == master.last_revision():
 
810
                    revno = tree.branch.revision_id_to_revno(last_rev)
 
811
                    note("Tree is up to date at revision %d." % (revno,))
 
812
                    return 0
809
813
            conflicts = tree.update()
810
 
            note('Updated to revision %d.' %
811
 
                 (tree.branch.revision_id_to_revno(tree.last_revision()),))
 
814
            revno = tree.branch.revision_id_to_revno(tree.last_revision())
 
815
            note('Updated to revision %d.' % (revno,))
812
816
            if conflicts != 0:
813
817
                return 1
814
818
            else:
1453
1457
        bzr ignore '*.class'
1454
1458
    """
1455
1459
    # TODO: Complain if the filename is absolute
1456
 
    takes_args = ['name_pattern']
 
1460
    takes_args = ['name_pattern?']
 
1461
    takes_options = [
 
1462
                     Option('old-default-rules',
 
1463
                            help='Out the ignore rules bzr < 0.9 always used.')
 
1464
                     ]
1457
1465
    
1458
 
    def run(self, name_pattern):
 
1466
    def run(self, name_pattern=None, old_default_rules=None):
1459
1467
        from bzrlib.atomicfile import AtomicFile
1460
 
        import os.path
1461
 
 
 
1468
        if old_default_rules is not None:
 
1469
            # dump the rules and exit
 
1470
            for pattern in bzrlib.DEFAULT_IGNORE:
 
1471
                print pattern
 
1472
            return
 
1473
        if name_pattern is None:
 
1474
            raise BzrCommandError("ignore requires a NAME_PATTERN")
1462
1475
        tree, relpath = WorkingTree.open_containing(u'.')
1463
1476
        ifn = tree.abspath('.bzrignore')
1464
 
 
1465
1477
        if os.path.exists(ifn):
1466
1478
            f = open(ifn, 'rt')
1467
1479
            try:
1552
1564
    takes_args = ['dest']
1553
1565
    takes_options = ['revision', 'format', 'root']
1554
1566
    def run(self, dest, revision=None, format=None, root=None):
1555
 
        import os.path
1556
1567
        from bzrlib.export import export
1557
1568
        tree = WorkingTree.open_containing(u'.')[0]
1558
1569
        b = tree.branch
2186
2197
            base_tree = repository.revision_tree(base_revision)
2187
2198
            other_tree = repository.revision_tree(pending_merges[0])
2188
2199
            interesting_ids = None
 
2200
            new_conflicts = []
 
2201
            conflicts = tree.conflicts()
2189
2202
            if file_list is not None:
2190
2203
                interesting_ids = set()
2191
2204
                for filename in file_list:
2198
2211
                    
2199
2212
                    for name, ie in tree.inventory.iter_entries(file_id):
2200
2213
                        interesting_ids.add(ie.file_id)
 
2214
                new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
2201
2215
            transform_tree(tree, tree.basis_tree(), interesting_ids)
 
2216
            tree.set_conflicts(ConflictList(new_conflicts))
2202
2217
            if file_list is None:
2203
2218
                restore_files = list(tree.iter_conflicts())
2204
2219
            else:
2208
2223
                    restore(tree.abspath(filename))
2209
2224
                except NotConflicted:
2210
2225
                    pass
2211
 
            conflicts =  merge_inner(tree.branch, other_tree, base_tree,
2212
 
                                     this_tree=tree,
2213
 
                                     interesting_ids = interesting_ids, 
2214
 
                                     other_rev_id=pending_merges[0], 
2215
 
                                     merge_type=merge_type, 
2216
 
                                     show_base=show_base,
2217
 
                                     reprocess=reprocess)
 
2226
            conflicts = merge_inner(tree.branch, other_tree, base_tree,
 
2227
                                    this_tree=tree,
 
2228
                                    interesting_ids=interesting_ids, 
 
2229
                                    other_rev_id=pending_merges[0], 
 
2230
                                    merge_type=merge_type, 
 
2231
                                    show_base=show_base,
 
2232
                                    reprocess=reprocess)
2218
2233
        finally:
2219
2234
            tree.unlock()
2220
2235
        if conflicts > 0: