~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge_directive.py

  • Committer: Sabin Iacob
  • Date: 2009-03-23 14:59:43 UTC
  • mto: (4189.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4193.
  • Revision ID: iacobs@m0n5t3r.info-20090323145943-3s3p1px5q1rkh2e5
update FSF mailing address

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
from StringIO import StringIO
136
136
        return klass(revision_id, t.as_sha1(), time, timezone, target_branch,
137
137
            patch, patch_type, public_branch, message)
138
138
 
 
139
    def get_disk_name(self, branch):
 
140
        """Generate a suitable basename for storing this directive on disk
 
141
 
 
142
        :param branch: The Branch this merge directive was generated fro
 
143
        :return: A string
 
144
        """
 
145
        revno, revision_id = branch.last_revision_info()
 
146
        if self.revision_id == revision_id:
 
147
            revno = [revno]
 
148
        else:
 
149
            revno = branch.get_revision_id_to_revno_map().get(self.revision_id,
 
150
                ['merge'])
 
151
        nick = re.sub('(\W+)', '-', branch.nick).strip('-')
 
152
        return '%s-%s' % (nick, '.'.join(str(n) for n in revno))
 
153
 
139
154
    @staticmethod
140
155
    def _generate_diff(repository, revision_id, ancestor_id):
141
156
        tree_1 = repository.revision_tree(ancestor_id)
195
210
                except errors.RevisionNotPresent:
196
211
                    # At least one dependency isn't present.  Try installing
197
212
                    # missing revisions from the submit branch
198
 
                    submit_branch = _mod_branch.Branch.open(self.target_branch)
 
213
                    try:
 
214
                        submit_branch = \
 
215
                            _mod_branch.Branch.open(self.target_branch)
 
216
                    except errors.NotBranchError:
 
217
                        raise errors.TargetNotBranch(self.target_branch)
199
218
                    missing_revisions = []
200
219
                    bundle_revisions = set(r.revision_id for r in
201
220
                                           info.real_revisions)
259
278
        """
260
279
        _BaseMergeDirective.__init__(self, revision_id, testament_sha1, time,
261
280
            timezone, target_branch, patch, source_branch, message)
262
 
        assert patch_type in (None, 'diff', 'bundle'), patch_type
 
281
        if patch_type not in (None, 'diff', 'bundle'):
 
282
            raise ValueError(patch_type)
263
283
        if patch_type != 'bundle' and source_branch is None:
264
284
            raise errors.NoMergeSource()
265
285
        if patch_type is not None and patch is None: