/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2005-12-31 00:51:34 UTC
  • mto: (1587.1.6 bound-branches)
  • mto: This revision was merged to the branch mainline in revision 1590.
  • Revision ID: john@arbash-meinel.com-20051231005134-dd54e393c7d3b612
Updated pull. Now all paths which call set_revision_history maintain the branch invariant. All tests pass.

Show diffs side-by-side

added added

removed removed

Lines of Context:
866
866
        # TODO: jam 20051230 This is actually just an integrity check
867
867
        #       This shouldn't be necessary, as other code should
868
868
        #       handle making sure this is correct
869
 
        master_branch = self.get_bound_branch()
 
869
        master_branch = self.get_master_branch()
870
870
        if master_branch:
871
871
            master_history = master_branch.revision_history()
872
872
            if rev_history != master_history[:len(rev_history)]:
1045
1045
    @needs_write_lock
1046
1046
    def pull(self, source, overwrite=False):
1047
1047
        """See Branch.pull."""
 
1048
        master_branch = self.get_master_branch()
 
1049
        if master_branch:
 
1050
            # TODO: jam 20051230 It would certainly be possible
 
1051
            #       to overwrite the master branch, I just feel
 
1052
            #       a little funny about doing it. This should be
 
1053
            #       discussed.
 
1054
            if overwrite:
 
1055
                raise errors.OverwriteBoundBranch(branch)
 
1056
            master_branch.pull(source)
 
1057
            source = master_branch
 
1058
 
1048
1059
        source.lock_read()
1049
1060
        try:
1050
1061
            old_count = len(self.revision_history())
1119
1130
            return f.read().strip()
1120
1131
 
1121
1132
    @needs_read_lock
1122
 
    def get_bound_branch(self):
 
1133
    def get_master_branch(self):
1123
1134
        """Return the branch we are bound to.
1124
1135
        
1125
1136
        :return: Either a Branch, or None
1131
1142
 
1132
1143
    @needs_write_lock
1133
1144
    def set_bound_location(self, location):
1134
 
        self.put_controlfile('bound', location+'\n')
 
1145
        if location:
 
1146
            self.put_controlfile('bound', location+'\n')
 
1147
        else:
 
1148
            bound_path = self._rel_controlfilename('bound')
 
1149
            try:
 
1150
                self._transport.delete(bound_path)
 
1151
            except NoSuchFile:
 
1152
                return False
 
1153
            return True
1135
1154
 
1136
1155
    @needs_write_lock
1137
1156
    def bind(self, other):
1201
1220
    @needs_write_lock
1202
1221
    def unbind(self):
1203
1222
        """If bound, unbind"""
1204
 
        bound_path = self._rel_controlfilename('bound')
1205
 
        try:
1206
 
            self._transport.delete(bound_path)
1207
 
        except NoSuchFile:
1208
 
            return False
1209
 
        return True
 
1223
        return self.set_bound_location(None)
1210
1224
 
1211
1225
 
1212
1226
class ScratchBranch(BzrBranch):