~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

merge bzr.dev

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
801
802
        tree = WorkingTree.open_containing(dir)[0]
802
803
        tree.lock_write()
803
804
        try:
804
 
            if tree.last_revision() == tree.branch.last_revision():
 
805
            last_rev = tree.last_revision() 
 
806
            if last_rev == tree.branch.last_revision():
805
807
                # may be up to date, check master too.
806
808
                master = tree.branch.get_master_branch()
807
 
                if master is None or master.last_revision == tree.last_revision():
808
 
                    note("Tree is up to date.")
809
 
                    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
810
813
            conflicts = tree.update()
811
 
            note('Updated to revision %d.' %
812
 
                 (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,))
813
816
            if conflicts != 0:
814
817
                return 1
815
818
            else:
1454
1457
        bzr ignore '*.class'
1455
1458
    """
1456
1459
    # TODO: Complain if the filename is absolute
1457
 
    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
                     ]
1458
1465
    
1459
 
    def run(self, name_pattern):
 
1466
    def run(self, name_pattern=None, old_default_rules=None):
1460
1467
        from bzrlib.atomicfile import AtomicFile
1461
 
        import os.path
1462
 
 
 
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")
1463
1475
        tree, relpath = WorkingTree.open_containing(u'.')
1464
1476
        ifn = tree.abspath('.bzrignore')
1465
 
 
1466
1477
        if os.path.exists(ifn):
1467
1478
            f = open(ifn, 'rt')
1468
1479
            try:
1553
1564
    takes_args = ['dest']
1554
1565
    takes_options = ['revision', 'format', 'root']
1555
1566
    def run(self, dest, revision=None, format=None, root=None):
1556
 
        import os.path
1557
1567
        from bzrlib.export import export
1558
1568
        tree = WorkingTree.open_containing(u'.')[0]
1559
1569
        b = tree.branch
1778
1788
 
1779
1789
 
1780
1790
class cmd_whoami(Command):
1781
 
    """Show bzr user id."""
1782
 
    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'
1783
1805
    
1784
1806
    @display_command
1785
 
    def run(self, email=False):
1786
 
        try:
1787
 
            c = WorkingTree.open_containing(u'.')[0].branch.get_config()
1788
 
        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:
1789
1824
            c = config.GlobalConfig()
1790
 
        if email:
1791
 
            print c.user_email()
1792
 
        else:
1793
 
            print c.username()
 
1825
        c.set_user_option('email', name)
1794
1826
 
1795
1827
 
1796
1828
class cmd_nick(Command):