~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.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:
348
348
            return hook
349
349
        return self._get_global_config()._post_commit()
350
350
 
 
351
    def set_user_option(self, option, value):
 
352
        """Save option and its value in the configuration."""
 
353
        # FIXME: RBC 20051029 This should refresh the parser and also take a
 
354
        # file lock on branches.conf.
 
355
        if not os.path.isdir(os.path.dirname(self._get_filename())):
 
356
            os.mkdir(os.path.dirname(self._get_filename()))
 
357
        location = self.location
 
358
        if location.endswith('/'):
 
359
            location = location[:-1]
 
360
        if (not location in self._get_parser() and
 
361
            not location + '/' in self._get_parser()):
 
362
            self._get_parser()[location]={}
 
363
        elif location + '/' in self._get_parser():
 
364
            location = location + '/'
 
365
        self._get_parser()[location][option]=value
 
366
        self._get_parser().write()
 
367
 
351
368
 
352
369
class BranchConfig(Config):
353
370
    """A configuration object giving the policy for a branch."""