~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-15 03:10:36 UTC
  • mfrom: (4288.1.6 push.roundtrips)
  • Revision ID: pqm@pqm.ubuntu.com-20090415031036-ikndntbkaaj5zjya
(robertc) 6 less round trips on smart push by using a verb to get
        bzrdir stacking policy and inheriting set_parent for
        RemoteBranch. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
590
590
    def set_revision_history(self, rev_history):
591
591
        raise NotImplementedError(self.set_revision_history)
592
592
 
 
593
    @needs_write_lock
 
594
    def set_parent(self, url):
 
595
        """See Branch.set_parent."""
 
596
        # TODO: Maybe delete old location files?
 
597
        # URLs should never be unicode, even on the local fs,
 
598
        # FIXUP this and get_parent in a future branch format bump:
 
599
        # read and rewrite the file. RBC 20060125
 
600
        if url is not None:
 
601
            if isinstance(url, unicode):
 
602
                try:
 
603
                    url = url.encode('ascii')
 
604
                except UnicodeEncodeError:
 
605
                    raise errors.InvalidURL(url,
 
606
                        "Urls must be 7-bit ascii, "
 
607
                        "use bzrlib.urlutils.escape")
 
608
            url = urlutils.relative_url(self.base, url)
 
609
        self._set_parent_location(url)
 
610
 
593
611
    def set_stacked_on_url(self, url):
594
612
        """Set the URL this branch is stacked against.
595
613
 
944
962
                raise errors.HookFailed(
945
963
                    'pre_change_branch_tip', hook_name, exc_info)
946
964
 
947
 
    def set_parent(self, url):
948
 
        raise NotImplementedError(self.set_parent)
949
 
 
950
965
    @needs_write_lock
951
966
    def update(self):
952
967
        """Synchronise this branch with the master branch if any.
2194
2209
            'push_location', location,
2195
2210
            store=_mod_config.STORE_LOCATION_NORECURSE)
2196
2211
 
2197
 
    @needs_write_lock
2198
 
    def set_parent(self, url):
2199
 
        """See Branch.set_parent."""
2200
 
        # TODO: Maybe delete old location files?
2201
 
        # URLs should never be unicode, even on the local fs,
2202
 
        # FIXUP this and get_parent in a future branch format bump:
2203
 
        # read and rewrite the file. RBC 20060125
2204
 
        if url is not None:
2205
 
            if isinstance(url, unicode):
2206
 
                try:
2207
 
                    url = url.encode('ascii')
2208
 
                except UnicodeEncodeError:
2209
 
                    raise errors.InvalidURL(url,
2210
 
                        "Urls must be 7-bit ascii, "
2211
 
                        "use bzrlib.urlutils.escape")
2212
 
            url = urlutils.relative_url(self.base, url)
2213
 
        self._set_parent_location(url)
2214
 
 
2215
2212
    def _set_parent_location(self, url):
2216
2213
        if url is None:
2217
2214
            self._transport.delete('parent')