コード例 #1
0
ファイル: test_push.py プロジェクト: c0ns0le/cygwin
    def test_push_remember(self):
        """Push changes from one branch to another and test push location."""
        transport = self.get_transport()
        tree_a = self.make_branch_and_tree('branch_a')
        branch_a = tree_a.branch
        self.build_tree(['branch_a/a'])
        tree_a.add('a')
        tree_a.commit('commit a')
        tree_b = branch_a.bzrdir.sprout('branch_b').open_workingtree()
        branch_b = tree_b.branch
        tree_c = branch_a.bzrdir.sprout('branch_c').open_workingtree()
        branch_c = tree_c.branch
        self.build_tree(['branch_a/b'])
        tree_a.add('b')
        tree_a.commit('commit b')
        self.build_tree(['branch_b/c'])
        tree_b.add('c')
        tree_b.commit('commit c')
        # initial push location must be empty
        self.assertEqual(None, branch_b.get_push_location())

        # test push for failure without push location set
        os.chdir('branch_a')
        out = self.run_bzr('push', retcode=3)
        self.assertEquals(out,
                ('','bzr: ERROR: No push location known or specified.\n'))

        # test not remembered if cannot actually push
        self.run_bzr('push ../path/which/doesnt/exist', retcode=3)
        out = self.run_bzr('push', retcode=3)
        self.assertEquals(
                ('', 'bzr: ERROR: No push location known or specified.\n'),
                out)

        # test implicit --remember when no push location set, push fails
        out = self.run_bzr('push ../branch_b', retcode=3)
        self.assertEquals(out,
                ('','bzr: ERROR: These branches have diverged.  '
                    'Try using "merge" and then "push".\n'))
        self.assertEquals(abspath(branch_a.get_push_location()),
                          abspath(branch_b.bzrdir.root_transport.base))

        # test implicit --remember after resolving previous failure
        uncommit(branch=branch_b, tree=tree_b)
        transport.delete('branch_b/c')
        out, err = self.run_bzr('push')
        path = branch_a.get_push_location()
        self.assertEquals(out,
                          'Using saved location: %s\n' 
                          'Pushed up to revision 2.\n'
                          % local_path_from_url(path))
        self.assertEqual(err,
                         'All changes applied successfully.\n')
        self.assertEqual(path,
                         branch_b.bzrdir.root_transport.base)
        # test explicit --remember
        self.run_bzr('push ../branch_c --remember')
        self.assertEquals(branch_a.get_push_location(),
                          branch_c.bzrdir.root_transport.base)
コード例 #2
0
ファイル: test_push.py プロジェクト: saminigod/cygwin
    def test_push_remember(self):
        """Push changes from one branch to another and test push location."""
        transport = self.get_transport()
        tree_a = self.make_branch_and_tree('branch_a')
        branch_a = tree_a.branch
        self.build_tree(['branch_a/a'])
        tree_a.add('a')
        tree_a.commit('commit a')
        tree_b = branch_a.bzrdir.sprout('branch_b').open_workingtree()
        branch_b = tree_b.branch
        tree_c = branch_a.bzrdir.sprout('branch_c').open_workingtree()
        branch_c = tree_c.branch
        self.build_tree(['branch_a/b'])
        tree_a.add('b')
        tree_a.commit('commit b')
        self.build_tree(['branch_b/c'])
        tree_b.add('c')
        tree_b.commit('commit c')
        # initial push location must be empty
        self.assertEqual(None, branch_b.get_push_location())

        # test push for failure without push location set
        os.chdir('branch_a')
        out = self.run_bzr('push', retcode=3)
        self.assertEquals(
            out, ('', 'bzr: ERROR: No push location known or specified.\n'))

        # test not remembered if cannot actually push
        self.run_bzr('push ../path/which/doesnt/exist', retcode=3)
        out = self.run_bzr('push', retcode=3)
        self.assertEquals(
            ('', 'bzr: ERROR: No push location known or specified.\n'), out)

        # test implicit --remember when no push location set, push fails
        out = self.run_bzr('push ../branch_b', retcode=3)
        self.assertEquals(out,
                          ('', 'bzr: ERROR: These branches have diverged.  '
                           'Try using "merge" and then "push".\n'))
        self.assertEquals(abspath(branch_a.get_push_location()),
                          abspath(branch_b.bzrdir.root_transport.base))

        # test implicit --remember after resolving previous failure
        uncommit(branch=branch_b, tree=tree_b)
        transport.delete('branch_b/c')
        out, err = self.run_bzr('push')
        path = branch_a.get_push_location()
        self.assertEquals(
            out, 'Using saved location: %s\n'
            'Pushed up to revision 2.\n' % local_path_from_url(path))
        self.assertEqual(err, 'All changes applied successfully.\n')
        self.assertEqual(path, branch_b.bzrdir.root_transport.base)
        # test explicit --remember
        self.run_bzr('push ../branch_c --remember')
        self.assertEquals(branch_a.get_push_location(),
                          branch_c.bzrdir.root_transport.base)
コード例 #3
0
ファイル: test_win32utils.py プロジェクト: Distrotech/bzr
 def test_dot_bzr_in_unicode_dir(self):
     # we should not raise traceback if we try to set hidden attribute
     # on .bzr directory below unicode path
     self.requireFeature(features.UnicodeFilenameFeature)
     os.makedirs(u'\u1234\\.bzr')
     path = osutils.abspath(u'\u1234\\.bzr')
     win32utils.set_file_attr_hidden(path)
コード例 #4
0
ファイル: test_serve.py プロジェクト: Distrotech/bzr
 def test_get_base_path(self):
     """cmd_serve will turn the --directory option into a LocalTransport
     (optionally decorated with 'readonly+').  BzrServerFactory can
     determine the original --directory from that transport.
     """
     # URLs always include the trailing slash, and get_base_path returns it
     base_dir = osutils.abspath('/a/b/c') + '/'
     base_url = urlutils.local_path_to_url(base_dir) + '/'
     # Define a fake 'protocol' to capture the transport that cmd_serve
     # passes to serve_bzr.
     def capture_transport(transport, host, port, inet, timeout):
         self.bzr_serve_transport = transport
     cmd = builtins.cmd_serve()
     # Read-only
     cmd.run(directory=base_dir, protocol=capture_transport)
     server_maker = BzrServerFactory()
     self.assertEqual(
         'readonly+%s' % base_url, self.bzr_serve_transport.base)
     self.assertEqual(
         base_dir, server_maker.get_base_path(self.bzr_serve_transport))
     # Read-write
     cmd.run(directory=base_dir, protocol=capture_transport,
         allow_writes=True)
     server_maker = BzrServerFactory()
     self.assertEqual(base_url, self.bzr_serve_transport.base)
     self.assertEqual(base_dir,
         server_maker.get_base_path(self.bzr_serve_transport))
     # Read-only, from a URL
     cmd.run(directory=base_url, protocol=capture_transport)
     server_maker = BzrServerFactory()
     self.assertEqual(
         'readonly+%s' % base_url, self.bzr_serve_transport.base)
     self.assertEqual(
         base_dir, server_maker.get_base_path(self.bzr_serve_transport))
コード例 #5
0
 def test_dot_bzr_in_unicode_dir(self):
     # we should not raise traceback if we try to set hidden attribute
     # on .bzr directory below unicode path
     self.requireFeature(features.UnicodeFilenameFeature)
     os.makedirs(u'\u1234\\.bzr')
     path = osutils.abspath(u'\u1234\\.bzr')
     win32utils.set_file_attr_hidden(path)
コード例 #6
0
 def _set_location(self, location):
     if not location:
         self.ui.local_location.setText('-')
         return
     if location != '.':
         self.ui.local_location.setText(url_for_display(location))
         return
     self.ui.local_location.setText(osutils.abspath(location))
コード例 #7
0
ファイル: test_transport.py プロジェクト: GymWenFLL/tpp_libs
 def get_base_location(self):
     path = osutils.abspath('/foo/bar')
     if path.startswith('/'):
         url = 'file://%s' % (path,)
     else:
         # On Windows, abspaths start with the drive letter, so we have to
         # add in the extra '/'
         url = 'file:///%s' % (path,)
     return path, url
コード例 #8
0
 def get_base_location(self):
     path = osutils.abspath('/foo/bar')
     if path.startswith('/'):
         url = 'file://%s' % (path, )
     else:
         # On Windows, abspaths start with the drive letter, so we have to
         # add in the extra '/'
         url = 'file:///%s' % (path, )
     return path, url
コード例 #9
0
ファイル: test_whitebox.py プロジェクト: c0ns0le/cygwin
    def test_relpath(self):
        """test for branch path lookups
    
        bzrlib.osutils._relpath do a simple but subtle
        job: given a path (either relative to cwd or absolute), work out
        if it is inside a branch and return the path relative to the base.
        """
        import tempfile
        
        savedir = os.getcwdu()
        dtmp = tempfile.mkdtemp()
        # On Mac OSX, /tmp actually expands to /private/tmp
        dtmp = realpath(dtmp)

        def rp(p):
            return relpath(dtmp, p)
        
        try:
            # check paths inside dtmp while standing outside it
            self.assertEqual(rp(pathjoin(dtmp, 'foo')), 'foo')

            # root = nothing
            self.assertEqual(rp(dtmp), '')

            self.assertRaises(PathNotChild,
                              rp,
                              '/etc')

            # now some near-miss operations -- note that
            # os.path.commonprefix gets these wrong!
            self.assertRaises(PathNotChild,
                              rp,
                              dtmp.rstrip('\\/') + '2')

            self.assertRaises(PathNotChild,
                              rp,
                              dtmp.rstrip('\\/') + '2/foo')

            # now operations based on relpath of files in current
            # directory, or nearby
            os.chdir(dtmp)

            self.assertEqual(rp('foo/bar/quux'), 'foo/bar/quux')

            self.assertEqual(rp('foo'), 'foo')

            self.assertEqual(rp('./foo'), 'foo')

            self.assertEqual(rp(abspath('foo')), 'foo')

            self.assertRaises(PathNotChild,
                              rp, '../foo')

        finally:
            os.chdir(savedir)
            osutils.rmtree(dtmp)
コード例 #10
0
ファイル: test_commit.py プロジェクト: c0ns0le/cygwin
    def test_verbose_commit_includes_master_location(self):
        """Location of master is displayed when committing to bound branch"""
        a_tree = self.make_branch_and_tree('a')
        self.build_tree(['a/b'])
        a_tree.add('b')
        a_tree.commit(message='Initial message')

        b_tree = a_tree.branch.create_checkout('b')
        expected = "%s/" % (osutils.abspath('a'), )
        out, err = self.run_bzr('commit -m blah --unchanged', working_dir='b')
        self.assertEqual(err, 'Committing to: %s\n'
                         'Committed revision 2.\n' % expected)
コード例 #11
0
ファイル: test_transport.py プロジェクト: GymWenFLL/tpp_libs
 def test_local_transport_mkdir_permission_denied(self):
     # See https://bugs.launchpad.net/bzr/+bug/606537
     here = osutils.abspath('.')
     t = transport.get_transport(here)
     def fake_chmod(path, mode):
         e = OSError('permission denied')
         e.errno = errno.EPERM
         raise e
     self.overrideAttr(os, 'chmod', fake_chmod)
     t.mkdir('test')
     t.mkdir('test2', mode=0707)
     self.assertTrue(os.path.exists('test'))
     self.assertTrue(os.path.exists('test2'))
コード例 #12
0
    def test_verbose_commit_includes_master_location(self):
        """Location of master is displayed when committing to bound branch"""
        a_tree = self.make_branch_and_tree('a')
        self.build_tree(['a/b'])
        a_tree.add('b')
        a_tree.commit(message='Initial message')

        b_tree = a_tree.branch.create_checkout('b')
        expected = "%s/" % (osutils.abspath('a'), )
        out, err = self.run_bzr('commit -m blah --unchanged', working_dir='b')
        self.assertEqual(
            err, 'Committing to: %s\n'
            'Committed revision 2.\n' % expected)
コード例 #13
0
ファイル: test_whitebox.py プロジェクト: saminigod/cygwin
    def test_relpath(self):
        """test for branch path lookups
    
        bzrlib.osutils._relpath do a simple but subtle
        job: given a path (either relative to cwd or absolute), work out
        if it is inside a branch and return the path relative to the base.
        """
        import tempfile

        savedir = os.getcwdu()
        dtmp = tempfile.mkdtemp()
        # On Mac OSX, /tmp actually expands to /private/tmp
        dtmp = realpath(dtmp)

        def rp(p):
            return relpath(dtmp, p)

        try:
            # check paths inside dtmp while standing outside it
            self.assertEqual(rp(pathjoin(dtmp, 'foo')), 'foo')

            # root = nothing
            self.assertEqual(rp(dtmp), '')

            self.assertRaises(PathNotChild, rp, '/etc')

            # now some near-miss operations -- note that
            # os.path.commonprefix gets these wrong!
            self.assertRaises(PathNotChild, rp, dtmp.rstrip('\\/') + '2')

            self.assertRaises(PathNotChild, rp, dtmp.rstrip('\\/') + '2/foo')

            # now operations based on relpath of files in current
            # directory, or nearby
            os.chdir(dtmp)

            self.assertEqual(rp('foo/bar/quux'), 'foo/bar/quux')

            self.assertEqual(rp('foo'), 'foo')

            self.assertEqual(rp('./foo'), 'foo')

            self.assertEqual(rp(abspath('foo')), 'foo')

            self.assertRaises(PathNotChild, rp, '../foo')

        finally:
            os.chdir(savedir)
            osutils.rmtree(dtmp)
コード例 #14
0
    def test_local_transport_mkdir_permission_denied(self):
        # See https://bugs.launchpad.net/bzr/+bug/606537
        here = osutils.abspath('.')
        t = transport.get_transport(here)

        def fake_chmod(path, mode):
            e = OSError('permission denied')
            e.errno = errno.EPERM
            raise e

        self.overrideAttr(os, 'chmod', fake_chmod)
        t.mkdir('test')
        t.mkdir('test2', mode=0707)
        self.assertTrue(os.path.exists('test'))
        self.assertTrue(os.path.exists('test2'))
コード例 #15
0
ファイル: test_merge.py プロジェクト: Techlord-RCE/cygwin
    def test_merge_remember(self):
        """Merge changes from one branch to another, test submit location."""
        tree_a = self.make_branch_and_tree('branch_a')
        branch_a = tree_a.branch
        self.build_tree(['branch_a/a'])
        tree_a.add('a')
        tree_a.commit('commit a')
        branch_b = branch_a.bzrdir.sprout('branch_b').open_branch()
        tree_b = branch_b.bzrdir.open_workingtree()
        branch_c = branch_a.bzrdir.sprout('branch_c').open_branch()
        tree_c = branch_c.bzrdir.open_workingtree()
        self.build_tree(['branch_a/b'])
        tree_a.add('b')
        tree_a.commit('commit b')
        self.build_tree(['branch_c/c'])
        tree_c.add('c')
        tree_c.commit('commit c')
        # reset parent
        parent = branch_b.get_parent()
        branch_b.set_parent(None)
        self.assertEqual(None, branch_b.get_parent())
        # test merge for failure without parent set
        os.chdir('branch_b')
        out = self.run_bzr('merge', retcode=3)
        self.assertEquals(
            out, ('', 'bzr: ERROR: No location specified or remembered\n'))
        # test implicit --remember when no parent set, this merge conflicts
        self.build_tree(['d'])
        tree_b.add('d')
        self.run_bzr_error(['Working tree ".*" has uncommitted changes'],
                           'merge ../branch_a')
        self.assertEquals(abspath(branch_b.get_submit_branch()),
                          abspath(parent))
        # test implicit --remember after resolving conflict
        tree_b.commit('commit d')
        out, err = self.run_bzr('merge')

        base = urlutils.local_path_from_url(branch_a.base)
        self.assertStartsWith(
            err, 'Merging from remembered location %s\n' % (base, ))
        self.assertEndsWith(err, '+N  b\nAll changes applied successfully.\n')
        self.assertEquals(abspath(branch_b.get_submit_branch()),
                          abspath(parent))
        # re-open tree as external run_bzr modified it
        tree_b = branch_b.bzrdir.open_workingtree()
        tree_b.commit('merge branch_a')
        # test explicit --remember
        out, err = self.run_bzr('merge ../branch_c --remember')
        self.assertEquals(out, '')
        self.assertEquals(err, '+N  c\nAll changes applied successfully.\n')
        self.assertEquals(abspath(branch_b.get_submit_branch()),
                          abspath(branch_c.bzrdir.root_transport.base))
        # re-open tree as external run_bzr modified it
        tree_b = branch_b.bzrdir.open_workingtree()
        tree_b.commit('merge branch_c')
コード例 #16
0
ファイル: plugin.py プロジェクト: ArslanRafique/dist-packages
def get_core_plugin_path():
    core_path = None
    bzr_exe = bool(getattr(sys, 'frozen', None))
    if bzr_exe:    # expand path for bzr.exe
        # We need to use relative path to system-wide plugin
        # directory because bzrlib from standalone bzr.exe
        # could be imported by another standalone program
        # (e.g. bzr-config; or TortoiseBzr/Olive if/when they
        # will become standalone exe). [bialix 20071123]
        # __file__ typically is
        # C:\Program Files\Bazaar\lib\library.zip\bzrlib\plugin.pyc
        # then plugins directory is
        # C:\Program Files\Bazaar\plugins
        # so relative path is ../../../plugins
        core_path = osutils.abspath(osutils.pathjoin(
                osutils.dirname(__file__), '../../../plugins'))
    else:     # don't look inside library.zip
        # search the plugin path before the bzrlib installed dir
        core_path = os.path.dirname(_mod_plugins.__file__)
    return core_path
コード例 #17
0
def get_core_plugin_path():
    core_path = None
    bzr_exe = bool(getattr(sys, 'frozen', None))
    if bzr_exe:  # expand path for bzr.exe
        # We need to use relative path to system-wide plugin
        # directory because bzrlib from standalone bzr.exe
        # could be imported by another standalone program
        # (e.g. bzr-config; or TortoiseBzr/Olive if/when they
        # will become standalone exe). [bialix 20071123]
        # __file__ typically is
        # C:\Program Files\Bazaar\lib\library.zip\bzrlib\plugin.pyc
        # then plugins directory is
        # C:\Program Files\Bazaar\plugins
        # so relative path is ../../../plugins
        core_path = osutils.abspath(
            osutils.pathjoin(osutils.dirname(__file__), '../../../plugins'))
    else:  # don't look inside library.zip
        # search the plugin path before the bzrlib installed dir
        core_path = os.path.dirname(_mod_plugins.__file__)
    return core_path
コード例 #18
0
ファイル: __init__.py プロジェクト: harsh-a1/repeater-testing
 def __init__(self, stream=None):
     self.commit_info = []
     self.stream = stream
     self._process = None
     self._counter = 0
     self._branch = 'refs/heads/master'
     if stream is None:
         # Write the marks file into the git sandbox.
         self._marks_file_name = osutils.abspath('marks')
         self._process = subprocess.Popen(
             ['git', 'fast-import', '--quiet',
              # GIT doesn't support '--export-marks foo'
              # it only supports '--export-marks=foo'
              # And gives a 'unknown option' otherwise.
              '--export-marks=' + self._marks_file_name,
             ],
             stdout=subprocess.PIPE,
             stderr=subprocess.PIPE,
             stdin=subprocess.PIPE,
             )
         self.stream = self._process.stdin
     else:
         self._process = None
コード例 #19
0
    def test_get_base_path(self):
        """cmd_serve will turn the --directory option into a LocalTransport
        (optionally decorated with 'readonly+').  BzrServerFactory can
        determine the original --directory from that transport.
        """
        # URLs always include the trailing slash, and get_base_path returns it
        base_dir = osutils.abspath('/a/b/c') + '/'
        base_url = urlutils.local_path_to_url(base_dir) + '/'

        # Define a fake 'protocol' to capture the transport that cmd_serve
        # passes to serve_bzr.
        def capture_transport(transport, host, port, inet, timeout):
            self.bzr_serve_transport = transport

        cmd = builtins.cmd_serve()
        # Read-only
        cmd.run(directory=base_dir, protocol=capture_transport)
        server_maker = BzrServerFactory()
        self.assertEqual('readonly+%s' % base_url,
                         self.bzr_serve_transport.base)
        self.assertEqual(base_dir,
                         server_maker.get_base_path(self.bzr_serve_transport))
        # Read-write
        cmd.run(directory=base_dir,
                protocol=capture_transport,
                allow_writes=True)
        server_maker = BzrServerFactory()
        self.assertEqual(base_url, self.bzr_serve_transport.base)
        self.assertEqual(base_dir,
                         server_maker.get_base_path(self.bzr_serve_transport))
        # Read-only, from a URL
        cmd.run(directory=base_url, protocol=capture_transport)
        server_maker = BzrServerFactory()
        self.assertEqual('readonly+%s' % base_url,
                         self.bzr_serve_transport.base)
        self.assertEqual(base_dir,
                         server_maker.get_base_path(self.bzr_serve_transport))
コード例 #20
0
ファイル: test_add.py プロジェクト: Distrotech/bzr
 def test_add_symlink_to_abspath(self):
     self.requireFeature(features.SymlinkFeature)
     self.make_branch_and_tree('tree')
     os.symlink(osutils.abspath('target'), 'tree/link')
     out = self.run_bzr(['add', 'tree/link'])[0]
     self.assertEquals(out, 'adding link\n')
コード例 #21
0
    def __init__(self, branch, bzrdir, location, ui_mode = None):

        super(QBzrSwitchWindow, self).__init__(
                                  gettext("Switch"),
                                  name = "switch",
                                  default_size = (400, 400),
                                  ui_mode = ui_mode,
                                  dialog = True,
                                  parent = None,
                                  hide_progress=False,
                                  )

        self.branch = branch

        gbSwitch = QtGui.QGroupBox(gettext("Switch checkout"), self)

        switch_box = QtGui.QFormLayout(gbSwitch)

        branchbase = None

        boundloc = branch.get_bound_location()
        if boundloc is not None:
            label = gettext("Heavyweight checkout:")
            branchbase = branch.base
        else:
            if bzrdir.root_transport.base != branch.bzrdir.root_transport.base:
                label = gettext("Lightweight checkout:")
                boundloc = branch.bzrdir.root_transport.base
                branchbase = bzrdir.root_transport.base
            else:
                raise errors.BzrError("This branch is not checkout.")

        switch_box.addRow(label, QtGui.QLabel(url_for_display(branchbase)))
        switch_box.addRow(gettext("Checkout of branch:"),
                          QtGui.QLabel(url_for_display(boundloc)))
        self.boundloc = url_for_display(boundloc)

        throb_hbox = QtGui.QHBoxLayout()

        self.throbber = ThrobberWidget(self)
        throb_hbox.addWidget(self.throbber)
        self.throbber.hide()
        switch_box.addRow(throb_hbox)

        switch_hbox = QtGui.QHBoxLayout()

        branch_label = QtGui.QLabel(gettext("Switch to branch:"))
        branch_combo = QtGui.QComboBox()   
        branch_combo.setEditable(True)

        self.branch_combo = branch_combo

        if location is not None:
            branch_combo.addItem(osutils.abspath(location))
        elif boundloc is not None:
            branch_combo.addItem(url_for_display(boundloc))

        browse_button = QtGui.QPushButton(gettext("Browse"))
        QtCore.QObject.connect(browse_button, QtCore.SIGNAL("clicked(bool)"), self.browse_clicked)

        switch_hbox.addWidget(branch_label)
        switch_hbox.addWidget(branch_combo)
        switch_hbox.addWidget(browse_button)

        switch_hbox.setStretchFactor(branch_label,0)
        switch_hbox.setStretchFactor(branch_combo,1)
        switch_hbox.setStretchFactor(browse_button,0)

        switch_box.addRow(switch_hbox)

        create_branch_box = QtGui.QCheckBox(gettext("Create Branch before switching"))
        create_branch_box.setChecked(False)
        switch_box.addRow(create_branch_box)
        self.create_branch_box = create_branch_box

        layout = QtGui.QVBoxLayout(self)

        layout.addWidget(gbSwitch)

        layout.addWidget(self.make_default_status_box())
        layout.addWidget(self.buttonbox)
        self.branch_combo.setFocus()
コード例 #22
0
    def __init__(self, dest=None, branch=None, ui_mode=False, parent=None):
        """Create export dialog.
        @param  dest:   path to export to (either archive name or directory).
        @param  branch: exported branch.
        @param  ui_mode:    does dialog should stay on the screen after
            operation completed successfully.
        @param  parent: parent window.
        """
        title = gettext("Export")
        super(QBzrExportDialog, self).__init__(
            title,
            name="export",
            default_size=(400, 400),
            ui_mode=ui_mode,
            dialog=True,
            parent=parent,
            hide_progress=False,
        )
        self.branch = branch

        # Create the branch information panel
        info_hbox = QtGui.QHBoxLayout()
        branch_info = gettext("Branch: %s") % url_for_display(branch.base)
        info_label = QtGui.QLabel(branch_info)
        info_hbox.addWidget(info_label)

        # Create the export group box
        gbExportDestination = QtGui.QGroupBox(gettext("Export"), self)
        vboxExportDestination = QtGui.QVBoxLayout(gbExportDestination)
        vboxExportDestination.addStrut(0)

        # Build export as archive section
        exportarch_radio = QtGui.QRadioButton("Export as archive")
        exportarch_radio.setChecked(True)
        self.exportarch_radio = exportarch_radio
        vboxExportDestination.addWidget(exportarch_radio)
        vboxExportDestination.addLayout(self._build_archive_location_layout())
        vboxExportDestination.addLayout(self._build_archive_root_layout())
        vboxExportDestination.addLayout(self._build_archive_type_layout())

        # Build export as directory section
        exportdir_radio = QtGui.QRadioButton("Export as directory")
        self.exportdir_radio = exportdir_radio
        vboxExportDestination.addWidget(exportdir_radio)
        vboxExportDestination.addLayout(
            self._build_directory_location_layout())

        # Build the options group box
        gbExportOptions = self._build_options_group_box()

        # Put the form together
        layout = QtGui.QVBoxLayout(self)
        layout.addLayout(info_hbox)
        layout.addWidget(gbExportDestination)
        layout.addWidget(gbExportOptions)
        layout.addWidget(self.make_default_status_box())
        layout.addWidget(self.buttonbox)

        # Initialise the locations with sensible defaults
        if dest is not None:
            if os.path.isdir(dest) or self.detect_format(dest) is None:
                self.locationdir_edit.setText(osutils.abspath(dest))
                self.locationdir_edit.setFocus()
                exportdir_radio.setChecked(True)
                self.locationdir_edit.setFocus()
            else:
                self.locationdir_edit.setText(osutils.abspath(dest))
                self.update_root_n_format()
                exportarch_radio.setChecked(True)
                self.locationfil_edit.setFocus()
        else:
            self.update_export_path(use_parent=True)
            self.update_root_n_format()

        # Disable the group boxes while doing the real work
        QtCore.QObject.connect(self, QtCore.SIGNAL("disableUi(bool)"),
                               gbExportDestination,
                               QtCore.SLOT("setDisabled(bool)"))
        QtCore.QObject.connect(self, QtCore.SIGNAL("disableUi(bool)"),
                               gbExportOptions,
                               QtCore.SLOT("setDisabled(bool)"))

        # Setup smart setting of fields as others are edited.
        # We could do more here (e.g. make the root directory change
        # when the location changes or vice versa) but opinions vary on
        # whether that increases or decreases usability so KISS for now.
        QtCore.QObject.connect(self.format_combo,
                               QtCore.SIGNAL("currentIndexChanged(int)"),
                               self.format_changed)
コード例 #23
0
    def __init__(self, branch, location=None, ui_mode=None):
        self.branch = branch
        super(QBzrBindDialog, self).__init__(
            gettext("Bind branch"),
            name="bind",
            default_size=(400, 400),
            ui_mode=ui_mode,
            dialog=True,
            parent=None,
            hide_progress=False,
        )

        # Display information fields
        gbBind = QtGui.QGroupBox(gettext("Bind"), self)
        bind_box = QtGui.QFormLayout(gbBind)
        bind_box.addRow(gettext("Branch location:"),
                        QtGui.QLabel(url_for_display(branch.base)))
        self.currbound = branch.get_bound_location()
        if self.currbound != None:
            bind_box.addRow(gettext("Currently bound to:"),
                            QtGui.QLabel(url_for_display(self.currbound)))

        # Build the "Bind to" widgets
        branch_label = QtGui.QLabel(gettext("Bind to:"))
        branch_combo = QtGui.QComboBox()
        branch_combo.setEditable(True)
        self.branch_combo = branch_combo
        browse_button = QtGui.QPushButton(gettext("Browse"))
        QtCore.QObject.connect(browse_button, QtCore.SIGNAL("clicked(bool)"),
                               self.browse_clicked)

        # Add some useful values into the combo box. If a location was given,
        # default to it. If an old bound location exists, suggest it.
        # Otherwise suggest the parent branch, if any.
        suggestions = []
        if location:
            suggestions.append(osutils.abspath(location))
        self._maybe_add_suggestion(suggestions,
                                   branch.get_old_bound_location())
        self._maybe_add_suggestion(suggestions, branch.get_parent())
        self._maybe_add_suggestion(suggestions, branch.get_push_location())
        if suggestions:
            branch_combo.addItems(suggestions)

        # Build the "Bind to" row/panel
        bind_hbox = QtGui.QHBoxLayout()
        bind_hbox.addWidget(branch_label)
        bind_hbox.addWidget(branch_combo)
        bind_hbox.addWidget(browse_button)
        bind_hbox.setStretchFactor(branch_label, 0)
        bind_hbox.setStretchFactor(branch_combo, 1)
        bind_hbox.setStretchFactor(browse_button, 0)
        bind_box.addRow(bind_hbox)

        # Put the form together
        layout = QtGui.QVBoxLayout(self)
        layout.addWidget(gbBind)
        layout.addWidget(self.make_default_status_box())
        layout.addWidget(self.buttonbox)

        branch_combo.setFocus()
コード例 #24
0
 def test_get_transport_from_abspath(self):
     here = osutils.abspath('.')
     t = transport.get_transport(here)
     self.assertIsInstance(t, local.LocalTransport)
     self.assertEqual(t.base, urlutils.local_path_to_url(here) + '/')
コード例 #25
0
 def test_local_transport_mkdir(self):
     here = osutils.abspath('.')
     t = transport.get_transport(here)
     t.mkdir('test')
     self.assertTrue(os.path.exists('test'))
コード例 #26
0
 def test_get_transport_from_local_url(self):
     here = osutils.abspath('.')
     here_url = urlutils.local_path_to_url(here) + '/'
     t = get_transport(here_url)
     self.assertIsInstance(t, LocalTransport)
     self.assertEquals(t.base, here_url)
コード例 #27
0
 def test_local_abspath(self):
     here = osutils.abspath('.')
     t = get_transport(here)
     self.assertEquals(t.local_abspath(''), here)
コード例 #28
0
ファイル: test_merge.py プロジェクト: Distrotech/bzr
    def test_merge_remember(self):
        """Merge changes from one branch to another, test submit location."""
        tree_a = self.make_branch_and_tree('branch_a')
        branch_a = tree_a.branch
        self.build_tree(['branch_a/a'])
        tree_a.add('a')
        tree_a.commit('commit a')
        branch_b = branch_a.bzrdir.sprout('branch_b').open_branch()
        tree_b = branch_b.bzrdir.open_workingtree()
        branch_c = branch_a.bzrdir.sprout('branch_c').open_branch()
        tree_c = branch_c.bzrdir.open_workingtree()
        self.build_tree(['branch_a/b'])
        tree_a.add('b')
        tree_a.commit('commit b')
        self.build_tree(['branch_c/c'])
        tree_c.add('c')
        tree_c.commit('commit c')
        # reset parent
        parent = branch_b.get_parent()
        branch_b.set_parent(None)
        self.assertEqual(None, branch_b.get_parent())
        # test merge for failure without parent set
        out = self.run_bzr('merge', retcode=3, working_dir='branch_b')
        self.assertEquals(out,
                ('','bzr: ERROR: No location specified or remembered\n'))

        # test uncommitted changes
        self.build_tree(['branch_b/d'])
        tree_b.add('d')
        self.run_bzr_error(['Working tree ".*" has uncommitted changes'],
                           'merge', working_dir='branch_b')

        # merge should now pass and implicitly remember merge location
        tree_b.commit('commit d')
        out, err = self.run_bzr('merge ../branch_a', working_dir='branch_b')

        base = urlutils.local_path_from_url(branch_a.base)
        self.assertEndsWith(err, '+N  b\nAll changes applied successfully.\n')
        # re-open branch as external run_bzr modified it
        branch_b = branch_b.bzrdir.open_branch()
        self.assertEquals(osutils.abspath(branch_b.get_submit_branch()),
                          osutils.abspath(parent))
        # test implicit --remember when committing new file
        self.build_tree(['branch_b/e'])
        tree_b.add('e')
        tree_b.commit('commit e')
        out, err = self.run_bzr('merge', working_dir='branch_b')
        self.assertStartsWith(
            err, 'Merging from remembered submit location %s\n' % (base,))
        # re-open tree as external run_bzr modified it
        tree_b = branch_b.bzrdir.open_workingtree()
        tree_b.commit('merge branch_a')
        # test explicit --remember
        out, err = self.run_bzr('merge ../branch_c --remember',
                                working_dir='branch_b')
        self.assertEquals(out, '')
        self.assertEquals(err, '+N  c\nAll changes applied successfully.\n')
        # re-open branch as external run_bzr modified it
        branch_b = branch_b.bzrdir.open_branch()
        self.assertEquals(osutils.abspath(branch_b.get_submit_branch()),
                          osutils.abspath(branch_c.bzrdir.root_transport.base))
        # re-open tree as external run_bzr modified it
        tree_b = branch_b.bzrdir.open_workingtree()
        tree_b.commit('merge branch_c')
コード例 #29
0
 def test_get_transport_from_relpath(self):
     here = osutils.abspath('.')
     t = get_transport('.')
     self.assertIsInstance(t, LocalTransport)
     self.assertEquals(t.base, urlutils.local_path_to_url('.') + '/')
コード例 #30
0
ファイル: test_transport.py プロジェクト: GymWenFLL/tpp_libs
 def test_local_transport_mkdir(self):
     here = osutils.abspath('.')
     t = transport.get_transport(here)
     t.mkdir('test')
     self.assertTrue(os.path.exists('test'))
コード例 #31
0
ファイル: test_transport.py プロジェクト: GymWenFLL/tpp_libs
 def test_local_abspath(self):
     here = osutils.abspath('.')
     t = transport.get_transport(here)
     self.assertEquals(t.local_abspath(''), here)
コード例 #32
0
ファイル: test_transport.py プロジェクト: GymWenFLL/tpp_libs
 def test_get_transport_from_local_url(self):
     here = osutils.abspath('.')
     here_url = urlutils.local_path_to_url(here) + '/'
     t = transport.get_transport(here_url)
     self.assertIsInstance(t, local.LocalTransport)
     self.assertEquals(t.base, here_url)
コード例 #33
0
    def test_bzr_connect_to_bzr_ssh(self):
        """User acceptance that get_transport of a bzr+ssh:// behaves correctly.

        bzr+ssh:// should cause bzr to run a remote bzr smart server over SSH.
        """
        try:
            from bzrlib.transport.sftp import SFTPServer
        except ParamikoNotPresent:
            raise TestSkipped('Paramiko not installed')
        from bzrlib.tests.stub_sftp import StubServer

        # Make a branch
        self.make_branch('a_branch')

        # Start an SSH server
        self.command_executed = []

        # XXX: This is horrible -- we define a really dumb SSH server that
        # executes commands, and manage the hooking up of stdin/out/err to the
        # SSH channel ourselves.  Surely this has already been implemented
        # elsewhere?
        class StubSSHServer(StubServer):

            test = self

            def check_channel_exec_request(self, channel, command):
                self.test.command_executed.append(command)
                proc = subprocess.Popen(command,
                                        shell=True,
                                        stdin=subprocess.PIPE,
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE)

                # XXX: horribly inefficient, not to mention ugly.
                # Start a thread for each of stdin/out/err, and relay bytes from
                # the subprocess to channel and vice versa.
                def ferry_bytes(read, write, close):
                    while True:
                        bytes = read(1)
                        if bytes == '':
                            close()
                            break
                        write(bytes)

                file_functions = [
                    (channel.recv, proc.stdin.write, proc.stdin.close),
                    (proc.stdout.read, channel.sendall, channel.close),
                    (proc.stderr.read, channel.sendall_stderr, channel.close)
                ]
                for read, write, close in file_functions:
                    t = threading.Thread(target=ferry_bytes,
                                         args=(read, write, close))
                    t.start()

                return True

        ssh_server = SFTPServer(StubSSHServer)
        # XXX: We *don't* want to override the default SSH vendor, so we set
        # _vendor to what _get_ssh_vendor returns.
        ssh_server.setUp()
        self.addCleanup(ssh_server.tearDown)
        port = ssh_server._listener.port

        # Access the branch via a bzr+ssh URL.  The BZR_REMOTE_PATH environment
        # variable is used to tell bzr what command to run on the remote end.
        path_to_branch = osutils.abspath('a_branch')

        orig_bzr_remote_path = os.environ.get('BZR_REMOTE_PATH')
        bzr_remote_path = self.get_bzr_path()
        if sys.platform == 'win32':
            bzr_remote_path = sys.executable + ' ' + self.get_bzr_path()
        os.environ['BZR_REMOTE_PATH'] = bzr_remote_path
        try:
            if sys.platform == 'win32':
                path_to_branch = os.path.splitdrive(path_to_branch)[1]
            branch = Branch.open('bzr+ssh://fred:secret@localhost:%d%s' %
                                 (port, path_to_branch))
            self.make_read_requests(branch)
            # Check we can perform write operations
            branch.bzrdir.root_transport.mkdir('foo')
        finally:
            # Restore the BZR_REMOTE_PATH environment variable back to its
            # original state.
            if orig_bzr_remote_path is None:
                del os.environ['BZR_REMOTE_PATH']
            else:
                os.environ['BZR_REMOTE_PATH'] = orig_bzr_remote_path

        self.assertEqual(
            ['%s serve --inet --directory=/ --allow-writes' % bzr_remote_path],
            self.command_executed)
コード例 #34
0
    def test_bzr_connect_to_bzr_ssh(self):
        """get_transport of a bzr+ssh:// behaves correctly.

        bzr+ssh:// should cause bzr to run a remote bzr smart server over SSH.
        """
        # This test actually causes a bzr instance to be invoked, which is very
        # expensive: it should be the only such test in the test suite.
        # A reasonable evolution for this would be to simply check inside
        # check_channel_exec_request that the command is appropriate, and then
        # satisfy requests in-process.
        self.requireFeature(features.paramiko)
        # SFTPFullAbsoluteServer has a get_url method, and doesn't
        # override the interface (doesn't change self._vendor).
        # Note that this does encryption, so can be slow.
        from bzrlib.tests import stub_sftp

        # Start an SSH server
        self.command_executed = []
        # XXX: This is horrible -- we define a really dumb SSH server that
        # executes commands, and manage the hooking up of stdin/out/err to the
        # SSH channel ourselves.  Surely this has already been implemented
        # elsewhere?
        started = []

        class StubSSHServer(stub_sftp.StubServer):

            test = self

            def check_channel_exec_request(self, channel, command):
                self.test.command_executed.append(command)
                proc = subprocess.Popen(command,
                                        shell=True,
                                        stdin=subprocess.PIPE,
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE)

                # XXX: horribly inefficient, not to mention ugly.
                # Start a thread for each of stdin/out/err, and relay bytes
                # from the subprocess to channel and vice versa.
                def ferry_bytes(read, write, close):
                    while True:
                        bytes = read(1)
                        if bytes == '':
                            close()
                            break
                        write(bytes)

                file_functions = [
                    (channel.recv, proc.stdin.write, proc.stdin.close),
                    (proc.stdout.read, channel.sendall, channel.close),
                    (proc.stderr.read, channel.sendall_stderr, channel.close)
                ]
                started.append(proc)
                for read, write, close in file_functions:
                    t = threading.Thread(target=ferry_bytes,
                                         args=(read, write, close))
                    t.start()
                    started.append(t)

                return True

        ssh_server = stub_sftp.SFTPFullAbsoluteServer(StubSSHServer)
        # We *don't* want to override the default SSH vendor: the detected one
        # is the one to use.

        # FIXME: I don't understand the above comment, SFTPFullAbsoluteServer
        # inherits from SFTPServer which forces the SSH vendor to
        # ssh.ParamikoVendor(). So it's forced, not detected. --vila 20100623
        self.start_server(ssh_server)
        port = ssh_server.port

        if sys.platform == 'win32':
            bzr_remote_path = sys.executable + ' ' + self.get_bzr_path()
        else:
            bzr_remote_path = self.get_bzr_path()
        self.overrideEnv('BZR_REMOTE_PATH', bzr_remote_path)

        # Access the branch via a bzr+ssh URL.  The BZR_REMOTE_PATH environment
        # variable is used to tell bzr what command to run on the remote end.
        path_to_branch = osutils.abspath('.')
        if sys.platform == 'win32':
            # On Windows, we export all drives as '/C:/, etc. So we need to
            # prefix a '/' to get the right path.
            path_to_branch = '/' + path_to_branch
        url = 'bzr+ssh://fred:secret@localhost:%d%s' % (port, path_to_branch)
        t = transport.get_transport(url)
        self.permit_url(t.base)
        t.mkdir('foo')

        self.assertEqual(
            ['%s serve --inet --directory=/ --allow-writes' % bzr_remote_path],
            self.command_executed)
        # Make sure to disconnect, so that the remote process can stop, and we
        # can cleanup. Then pause the test until everything is shutdown
        t._client._medium.disconnect()
        if not started:
            return
        # First wait for the subprocess
        started[0].wait()
        # And the rest are threads
        for t in started[1:]:
            t.join()
コード例 #35
0
ファイル: test_transport.py プロジェクト: GymWenFLL/tpp_libs
    def test_bzr_connect_to_bzr_ssh(self):
        """get_transport of a bzr+ssh:// behaves correctly.

        bzr+ssh:// should cause bzr to run a remote bzr smart server over SSH.
        """
        # This test actually causes a bzr instance to be invoked, which is very
        # expensive: it should be the only such test in the test suite.
        # A reasonable evolution for this would be to simply check inside
        # check_channel_exec_request that the command is appropriate, and then
        # satisfy requests in-process.
        self.requireFeature(features.paramiko)
        # SFTPFullAbsoluteServer has a get_url method, and doesn't
        # override the interface (doesn't change self._vendor).
        # Note that this does encryption, so can be slow.
        from bzrlib.tests import stub_sftp

        # Start an SSH server
        self.command_executed = []
        # XXX: This is horrible -- we define a really dumb SSH server that
        # executes commands, and manage the hooking up of stdin/out/err to the
        # SSH channel ourselves.  Surely this has already been implemented
        # elsewhere?
        started = []

        class StubSSHServer(stub_sftp.StubServer):

            test = self

            def check_channel_exec_request(self, channel, command):
                self.test.command_executed.append(command)
                proc = subprocess.Popen(
                    command, shell=True, stdin=subprocess.PIPE,
                    stdout=subprocess.PIPE, stderr=subprocess.PIPE)

                # XXX: horribly inefficient, not to mention ugly.
                # Start a thread for each of stdin/out/err, and relay bytes
                # from the subprocess to channel and vice versa.
                def ferry_bytes(read, write, close):
                    while True:
                        bytes = read(1)
                        if bytes == '':
                            close()
                            break
                        write(bytes)

                file_functions = [
                    (channel.recv, proc.stdin.write, proc.stdin.close),
                    (proc.stdout.read, channel.sendall, channel.close),
                    (proc.stderr.read, channel.sendall_stderr, channel.close)]
                started.append(proc)
                for read, write, close in file_functions:
                    t = threading.Thread(
                        target=ferry_bytes, args=(read, write, close))
                    t.start()
                    started.append(t)

                return True

        ssh_server = stub_sftp.SFTPFullAbsoluteServer(StubSSHServer)
        # We *don't* want to override the default SSH vendor: the detected one
        # is the one to use.

        # FIXME: I don't understand the above comment, SFTPFullAbsoluteServer
        # inherits from SFTPServer which forces the SSH vendor to
        # ssh.ParamikoVendor(). So it's forced, not detected. --vila 20100623
        self.start_server(ssh_server)
        port = ssh_server.port

        if sys.platform == 'win32':
            bzr_remote_path = sys.executable + ' ' + self.get_bzr_path()
        else:
            bzr_remote_path = self.get_bzr_path()
        self.overrideEnv('BZR_REMOTE_PATH', bzr_remote_path)

        # Access the branch via a bzr+ssh URL.  The BZR_REMOTE_PATH environment
        # variable is used to tell bzr what command to run on the remote end.
        path_to_branch = osutils.abspath('.')
        if sys.platform == 'win32':
            # On Windows, we export all drives as '/C:/, etc. So we need to
            # prefix a '/' to get the right path.
            path_to_branch = '/' + path_to_branch
        url = 'bzr+ssh://fred:secret@localhost:%d%s' % (port, path_to_branch)
        t = transport.get_transport(url)
        self.permit_url(t.base)
        t.mkdir('foo')

        self.assertEqual(
            ['%s serve --inet --directory=/ --allow-writes' % bzr_remote_path],
            self.command_executed)
        # Make sure to disconnect, so that the remote process can stop, and we
        # can cleanup. Then pause the test until everything is shutdown
        t._client._medium.disconnect()
        if not started:
            return
        # First wait for the subprocess
        started[0].wait()
        # And the rest are threads
        for t in started[1:]:
            t.join()
コード例 #36
0
 def test_add_symlink_to_abspath(self):
     self.requireFeature(features.SymlinkFeature)
     self.make_branch_and_tree('tree')
     os.symlink(osutils.abspath('target'), 'tree/link')
     out = self.run_bzr(['add', 'tree/link'])[0]
     self.assertEqual(out, 'adding link\n')
コード例 #37
0
ファイル: test_transport.py プロジェクト: GymWenFLL/tpp_libs
 def test_get_transport_from_relpath(self):
     here = osutils.abspath('.')
     t = transport.get_transport('.')
     self.assertIsInstance(t, local.LocalTransport)
     self.assertEquals(t.base, urlutils.local_path_to_url('.') + '/')
コード例 #38
0
ファイル: test_serve.py プロジェクト: c0ns0le/cygwin
    def test_bzr_connect_to_bzr_ssh(self):
        """User acceptance that get_transport of a bzr+ssh:// behaves correctly.

        bzr+ssh:// should cause bzr to run a remote bzr smart server over SSH.
        """
        try:
            from bzrlib.transport.sftp import SFTPServer
        except ParamikoNotPresent:
            raise TestSkipped('Paramiko not installed')
        from bzrlib.tests.stub_sftp import StubServer
        
        # Make a branch
        self.make_branch('a_branch')

        # Start an SSH server
        self.command_executed = []
        # XXX: This is horrible -- we define a really dumb SSH server that
        # executes commands, and manage the hooking up of stdin/out/err to the
        # SSH channel ourselves.  Surely this has already been implemented
        # elsewhere?
        class StubSSHServer(StubServer):

            test = self

            def check_channel_exec_request(self, channel, command):
                self.test.command_executed.append(command)
                proc = subprocess.Popen(
                    command, shell=True, stdin=subprocess.PIPE,
                    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                
                # XXX: horribly inefficient, not to mention ugly.
                # Start a thread for each of stdin/out/err, and relay bytes from
                # the subprocess to channel and vice versa.
                def ferry_bytes(read, write, close):
                    while True:
                        bytes = read(1)
                        if bytes == '':
                            close()
                            break
                        write(bytes)

                file_functions = [
                    (channel.recv, proc.stdin.write, proc.stdin.close),
                    (proc.stdout.read, channel.sendall, channel.close),
                    (proc.stderr.read, channel.sendall_stderr, channel.close)]
                for read, write, close in file_functions:
                    t = threading.Thread(
                        target=ferry_bytes, args=(read, write, close))
                    t.start()

                return True

        ssh_server = SFTPServer(StubSSHServer)
        # XXX: We *don't* want to override the default SSH vendor, so we set
        # _vendor to what _get_ssh_vendor returns.
        ssh_server.setUp()
        self.addCleanup(ssh_server.tearDown)
        port = ssh_server._listener.port

        # Access the branch via a bzr+ssh URL.  The BZR_REMOTE_PATH environment
        # variable is used to tell bzr what command to run on the remote end.
        path_to_branch = osutils.abspath('a_branch')
        
        orig_bzr_remote_path = os.environ.get('BZR_REMOTE_PATH')
        bzr_remote_path = self.get_bzr_path()
        if sys.platform == 'win32':
            bzr_remote_path = sys.executable + ' ' + self.get_bzr_path()
        os.environ['BZR_REMOTE_PATH'] = bzr_remote_path
        try:
            if sys.platform == 'win32':
                path_to_branch = os.path.splitdrive(path_to_branch)[1]
            branch = Branch.open(
                'bzr+ssh://fred:secret@localhost:%d%s' % (port, path_to_branch))
            self.make_read_requests(branch)
            # Check we can perform write operations
            branch.bzrdir.root_transport.mkdir('foo')
        finally:
            # Restore the BZR_REMOTE_PATH environment variable back to its
            # original state.
            if orig_bzr_remote_path is None:
                del os.environ['BZR_REMOTE_PATH']
            else:
                os.environ['BZR_REMOTE_PATH'] = orig_bzr_remote_path

        self.assertEqual(
            ['%s serve --inet --directory=/ --allow-writes'
             % bzr_remote_path],
            self.command_executed)