~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2006-02-12 12:57:15 UTC
  • mto: (1534.1.22 integration)
  • mto: This revision was merged to the branch mainline in revision 1554.
  • Revision ID: robertc@robertcollins.net-20060212125715-75abf487b5ee1f5a
Add update command for use with checkouts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
599
599
                rmtree(to_location)
600
600
                msg = "The branch %s cannot be used as a --basis"
601
601
                raise BzrCommandError(msg)
602
 
            WorkingTree.create(branch, to_location)
603
602
            if name:
604
603
                branch.control_files.put_utf8('branch-name', name)
605
604
 
675
674
            print "%s => %s" % (old_name, new_name)        
676
675
 
677
676
 
 
677
class cmd_update(Command):
 
678
    """Update a tree to have the latest code committed to its branch.
 
679
    
 
680
    This will perform a merge into the working tree, and may generate
 
681
    conflicts. If you have any uncommitted changes, you will still 
 
682
    need to commit them after the update.
 
683
    """
 
684
    takes_args = ['dir?']
 
685
 
 
686
    def run(self, dir='.'):
 
687
        tree = WorkingTree.open_containing(dir)[0]
 
688
        tree.lock_write()
 
689
        try:
 
690
            if tree.last_revision() == tree.branch.last_revision():
 
691
                note("Tree is up to date.")
 
692
                return
 
693
            conflicts = tree.update()
 
694
            note('Updated to revision %d.' %
 
695
                 (tree.branch.revision_id_to_revno(tree.last_revision()),))
 
696
            if conflicts != 0:
 
697
                return 1
 
698
            else:
 
699
                return 0
 
700
        finally:
 
701
            tree.unlock()
 
702
 
 
703
 
678
704
class cmd_info(Command):
679
705
    """Show statistical information about a branch."""
680
706
    takes_args = ['branch?']