/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: John Arbash Meinel
  • Date: 2006-07-07 15:22:42 UTC
  • mfrom: (1843 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1846.
  • Revision ID: john@arbash-meinel.com-20060707152242-a7b5e0afd64d9d5a
[merge] bzr.dev 1843

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
1777
1788
 
1778
1789
 
1779
1790
class cmd_whoami(Command):
1780
 
    """Show bzr user id."""
1781
 
    takes_options = ['email']
 
1791
    """Show or set bzr user id.
 
1792
    
 
1793
    examples:
 
1794
        bzr whoami --email
 
1795
        bzr whoami 'Frank Chu <fchu@example.com>'
 
1796
    """
 
1797
    takes_options = [ Option('email',
 
1798
                             help='display email address only'),
 
1799
                      Option('branch',
 
1800
                             help='set identity for the current branch instead of '
 
1801
                                  'globally'),
 
1802
                    ]
 
1803
    takes_args = ['name?']
 
1804
    encoding_type = 'replace'
1782
1805
    
1783
1806
    @display_command
1784
 
    def run(self, email=False):
1785
 
        try:
1786
 
            c = WorkingTree.open_containing(u'.')[0].branch.get_config()
1787
 
        except NotBranchError:
 
1807
    def run(self, email=False, branch=False, name=None):
 
1808
        if name is None:
 
1809
            # use branch if we're inside one; otherwise global config
 
1810
            try:
 
1811
                c = Branch.open_containing('.')[0].get_config()
 
1812
            except NotBranchError:
 
1813
                c = config.GlobalConfig()
 
1814
            if email:
 
1815
                self.outf.write(c.user_email() + '\n')
 
1816
            else:
 
1817
                self.outf.write(c.username() + '\n')
 
1818
            return
 
1819
 
 
1820
        # use global config unless --branch given
 
1821
        if branch:
 
1822
            c = Branch.open_containing('.')[0].get_config()
 
1823
        else:
1788
1824
            c = config.GlobalConfig()
1789
 
        if email:
1790
 
            print c.user_email()
1791
 
        else:
1792
 
            print c.username()
 
1825
        c.set_user_option('email', name)
1793
1826
 
1794
1827
 
1795
1828
class cmd_nick(Command):
2186
2219
            base_tree = repository.revision_tree(base_revision)
2187
2220
            other_tree = repository.revision_tree(pending_merges[0])
2188
2221
            interesting_ids = None
 
2222
            new_conflicts = []
 
2223
            conflicts = tree.conflicts()
2189
2224
            if file_list is not None:
2190
2225
                interesting_ids = set()
2191
2226
                for filename in file_list:
2198
2233
                    
2199
2234
                    for name, ie in tree.inventory.iter_entries(file_id):
2200
2235
                        interesting_ids.add(ie.file_id)
 
2236
                new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
2201
2237
            transform_tree(tree, tree.basis_tree(), interesting_ids)
 
2238
            tree.set_conflicts(ConflictList(new_conflicts))
2202
2239
            if file_list is None:
2203
2240
                restore_files = list(tree.iter_conflicts())
2204
2241
            else:
2208
2245
                    restore(tree.abspath(filename))
2209
2246
                except NotConflicted:
2210
2247
                    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)
 
2248
            conflicts = merge_inner(tree.branch, other_tree, base_tree,
 
2249
                                    this_tree=tree,
 
2250
                                    interesting_ids=interesting_ids, 
 
2251
                                    other_rev_id=pending_merges[0], 
 
2252
                                    merge_type=merge_type, 
 
2253
                                    show_base=show_base,
 
2254
                                    reprocess=reprocess)
2218
2255
        finally:
2219
2256
            tree.unlock()
2220
2257
        if conflicts > 0: