~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: John Arbash Meinel
  • Date: 2005-07-11 21:51:33 UTC
  • mto: (1185.11.1)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: john@arbash-meinel.com-20050711215132-00f679f5221df5c4
Branch objects now automatically create Cached stores if the protocol is_remote.

Show diffs side-by-side

added added

removed removed

Lines of Context:
525
525
 
526
526
    def run(self, location=None):
527
527
        from bzrlib.merge import merge
528
 
        import tempfile
529
 
        from shutil import rmtree
530
528
        import errno
531
529
        
532
530
        br_to = find_branch('.')
542
540
            else:
543
541
                print "Using last location: %s" % stored_loc
544
542
                location = stored_loc
545
 
        cache_root = tempfile.mkdtemp()
 
543
 
546
544
        from bzrlib.branch import DivergedBranches
547
545
        br_from = find_branch(location)
548
546
        location = br_from.base
549
547
        old_revno = br_to.revno()
550
548
        try:
551
 
            from branch import find_cached_branch, DivergedBranches
552
 
            br_from = find_cached_branch(location, cache_root)
553
 
            location = br_from.base
554
 
            old_revno = br_to.revno()
555
549
            try:
556
550
                br_to.update_revisions(br_from)
557
551
            except DivergedBranches:
558
552
                raise BzrCommandError("These branches have diverged."
559
553
                    "  Try merge.")
560
 
                
 
554
                    
561
555
            merge(('.', -1), ('.', old_revno), check_clean=False)
562
556
            if location != stored_loc:
563
557
                br_to.put_controlfile('x-pull', location+'\n')
564
558
        finally:
565
 
            rmtree(cache_root)
566
 
 
 
559
            if br_from.cache_root is not None:
 
560
                import shutil
 
561
                shutil.rmtree(br_from.cache_root)
 
562
                br_from.cache_root = None
567
563
 
568
564
 
569
565
class cmd_branch(Command):
582
578
        import errno
583
579
        from bzrlib.merge import merge
584
580
        from bzrlib.branch import DivergedBranches, NoSuchRevision, \
585
 
             find_cached_branch, find_branch
586
 
        from shutil import rmtree
587
 
        from meta_store import CachedStore
588
 
        import tempfile
589
 
        cache_root = tempfile.mkdtemp()
 
581
             find_branch
590
582
 
591
583
        if revision is None:
592
584
            revision = [None]
593
585
        else:
594
586
            if len(revision) > 1:
595
587
                raise BzrCommandError('bzr branch --revision takes exactly 1 revision value')
 
588
 
 
589
        br_from = None
596
590
        try:
597
591
            try:
598
 
                br_from = find_cached_branch(from_location, cache_root)
 
592
                br_from = find_branch(from_location)
599
593
            except OSError, e:
600
594
                if e.errno == errno.ENOENT:
601
595
                    raise BzrCommandError('Source location "%s" does not'
632
626
            from_location = br_from.base
633
627
            br_to.put_controlfile('x-pull', from_location+'\n')
634
628
        finally:
635
 
            rmtree(cache_root)
 
629
            if br_from and br_from.cache_root is not None:
 
630
                import shutil
 
631
                shutil.rmtree(br_from.cache_root)
 
632
                br_from.cache_root = None
636
633
 
637
634
 
638
635
class cmd_renames(Command):