~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

  • Committer: Robert Collins
  • Date: 2005-10-29 23:48:45 UTC
  • Revision ID: robertc@robertcollins.net-20051029234845-7ae4e7d118bdd3ed
Implement a 'bzr push' command, with saved locations; update diff to return 1.

    * 'bzr diff' now returns 1 when there are changes in the working 
      tree.

    * 'bzr push' now exists and can push changes to a remote location. 
      This uses the transport infrastructure, and can store the remote
      location in the ~/.bazaar/branches.conf configuration file.

    * WorkingTree.pull has been split across Branch and WorkingTree,
      to allow Branch only pulls.

    * commands.display_command now returns the result of the decorated 
      function.

    * LocationConfig now has a set_user_option(key, value) call to save
      a setting in its matching location section (a new one is created
      if needed).

    * Branch has two new methods, get_push_location and set_push_location
      to respectively, get and set the push location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
288
288
        self.example_branch()
289
289
        file('hello', 'wt').write('hello world!')
290
290
        self.runbzr('commit -m fixing hello')
291
 
        output = self.runbzr('diff -r 2..3', backtick=1)
 
291
        output = self.runbzr('diff -r 2..3', backtick=1, retcode=1)
292
292
        self.assert_('\n+hello world!' in output)
293
 
        output = self.runbzr('diff -r last:3..last:1', backtick=1)
 
293
        output = self.runbzr('diff -r last:3..last:1', backtick=1, retcode=1)
294
294
        self.assert_('\n+baz' in output)
295
295
 
296
296
    def test_diff_branches(self):
303
303
        branch2 = Branch.open('branch2')
304
304
        branch2.commit('update file')
305
305
        # should open branch1 and diff against branch2, 
306
 
        output = self.run_bzr_captured(['diff', '-r', 'branch:branch2', 'branch1'])
 
306
        output = self.run_bzr_captured(['diff', '-r', 'branch:branch2', 
 
307
                                        'branch1'],
 
308
                                       retcode=1)
307
309
        self.assertEquals(("=== modified file 'file'\n"
308
310
                           "--- file\n"
309
311
                           "+++ file\n"
598
600
        finally:
599
601
            bzrlib.gpg.GPGStrategy = oldstrategy
600
602
 
 
603
    def test_push(self):
 
604
        # create a source branch
 
605
        os.mkdir('my-branch')
 
606
        os.chdir('my-branch')
 
607
        self.example_branch()
 
608
 
 
609
        # with no push target, fail
 
610
        self.runbzr('push', retcode=1)
 
611
        # with an explicit target work
 
612
        self.runbzr('push ../output-branch')
 
613
        # with an implicit target work
 
614
        self.runbzr('push')
 
615
        # nothing missing
 
616
        self.runbzr('missing ../output-branch')
 
617
        # advance this branch
 
618
        self.runbzr('commit --unchanged -m unchanged')
 
619
 
 
620
        os.chdir('../output-branch')
 
621
        # should be a diff as we have not pushed the tree
 
622
        self.runbzr('diff', retcode=1)
 
623
        self.runbzr('revert')
 
624
        # but not now.
 
625
        self.runbzr('diff')
 
626
        # diverge the branches
 
627
        self.runbzr('commit --unchanged -m unchanged')
 
628
        os.chdir('../my-branch')
 
629
        # cannot push now
 
630
        self.runbzr('push', retcode=1)
 
631
        # and there are difference
 
632
        self.runbzr('missing ../output-branch', retcode=1)
 
633
        # but we can force a push
 
634
        self.runbzr('push --overwrite')
 
635
        # nothing missing
 
636
        self.runbzr('missing ../output-branch')
 
637
 
601
638
 
602
639
def listdir_sorted(dir):
603
640
    L = os.listdir(dir)
772
809
        mkdir('sub directory')
773
810
        file('sub directory/file with spaces ', 'wt').write('see how this works\n')
774
811
        runbzr('add .')
775
 
        runbzr('diff')
 
812
        runbzr('diff', retcode=1)
776
813
        runbzr('commit -m add-spaces')
777
814
        runbzr('check')
778
815
 
809
846
            assert os.readlink("./link2") == "NOWHERE2"
810
847
            assert os.readlink("d2/link1") == "NOWHERE1"
811
848
            runbzr('add d2/link3')
812
 
            runbzr('diff')
 
849
            runbzr('diff', retcode=1)
813
850
            runbzr(['commit', '-m', '3: rename of dir, move symlinks, add link3'])
814
851
    
815
852
            os.unlink("link2")
816
853
            os.symlink("TARGET 2", "link2")
817
854
            os.unlink("d2/link1")
818
855
            os.symlink("TARGET 1", "d2/link1")
819
 
            runbzr('diff')
 
856
            runbzr('diff', retcode=1)
820
857
            assert self.capture("relpath d2/link1") == "d2/link1\n"
821
858
            runbzr(['commit', '-m', '4: retarget of two links'])
822
859