~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2005-12-31 00:23:03 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-20051231002303-fbc5cf80469ef0cf
Updated commit to handle bound branches. Included test to handle commit after merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
862
862
        """See Branch.set_revision_history."""
863
863
        old_revision = self.last_revision()
864
864
        new_revision = rev_history[-1]
 
865
        
 
866
        # TODO: jam 20051230 This is actually just an integrity check
 
867
        #       This shouldn't be necessary, as other code should
 
868
        #       handle making sure this is correct
 
869
        master_branch = self.get_bound_branch()
 
870
        if master_branch:
 
871
            master_history = master_branch.revision_history()
 
872
            if rev_history != master_history[:len(rev_history)]:
 
873
                mutter('Invalid revision history, bound branches should always be a subset of their master history')
 
874
                mutter('Local: %s', rev_history)
 
875
                mutter('Master: %s', master_history)
 
876
                assert False, 'Invalid revision history'
 
877
 
865
878
        self.put_controlfile('revision-history', '\n'.join(rev_history))
866
879
        try:
867
880
            self.working_tree().set_last_revision(new_revision, old_revision)
1105
1118
        else:
1106
1119
            return f.read().strip()
1107
1120
 
 
1121
    @needs_read_lock
 
1122
    def get_bound_branch(self):
 
1123
        """Return the branch we are bound to.
 
1124
        
 
1125
        :return: Either a Branch, or None
 
1126
        """
 
1127
        bound_loc = self.get_bound_location()
 
1128
        if not bound_loc:
 
1129
            return None
 
1130
        return Branch.open(bound_loc)
 
1131
 
1108
1132
    @needs_write_lock
1109
1133
    def set_bound_location(self, location):
1110
1134
        self.put_controlfile('bound', location+'\n')
1133
1157
        #       that was worse than having Branch.bind() try to
1134
1158
        #       update its working tree.
1135
1159
 
1136
 
        # It is debatable whether you should be able to bind to
1137
 
        # a branch which is itself bound.
1138
 
        # Committing is obviously forbidden,
1139
 
        # but binding itself may not be.
 
1160
        # TODO: jam 20051230 Consider checking if the target is bound
 
1161
        #       It is debatable whether you should be able to bind to
 
1162
        #       a branch which is itself bound.
 
1163
        #       Committing is obviously forbidden,
 
1164
        #       but binding itself may not be.
 
1165
        #       Since we *have* to check at commit time, we don't
 
1166
        #       *need* to check here
1140
1167
        try:
1141
1168
            self.working_tree().pull(other)
1142
1169
        except NoWorkingTree:
1151
1178
        # TODO: capture an exception which indicates the remote branch
1152
1179
        #       is not writeable. 
1153
1180
        #       If it is up-to-date, this probably should not be a failure
 
1181
 
 
1182
        # TODO: jam 20051230 Consider not updating the remote working tree.
 
1183
        #       Right now, it seems undesirable, since it is actually
 
1184
        #       its own branch, and we don't really want to generate
 
1185
        #       conflicts in the other working tree.
 
1186
        #       However, it means if there are uncommitted changes in
 
1187
        #       the remote tree, it is very difficult to update to
 
1188
        #       the latest version without losing
1154
1189
        try:
1155
1190
            other.working_tree().pull(self)
1156
1191
        except NoWorkingTree: