/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 gitlabs.py

Add get_source_branch_url/get_target_branch_url methods.

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
    def set_description(self, description):
143
143
        self._mr.description = description
144
144
 
 
145
    def _branch_url_from_project(self, project_id, branch_name):
 
146
        project = self._mr.manager.gitlab.projects.get(project_id)
 
147
        return gitlab_url_to_bzr_url(project.http_url_to_repo, branch_name)
 
148
 
 
149
    def get_source_branch_url(self):
 
150
        return self._branch_url_from_project(
 
151
            self._mr.source_project_id, self._mr.source_branch)
 
152
 
 
153
    def get_target_branch_url(self):
 
154
        return self._branch_url_from_project(
 
155
            self._mr.target_project_id, self._mr.target_branch)
 
156
 
145
157
    def is_merged(self):
146
 
        return (self._mr.attributes['state'] == 'merged')
 
158
        return (self._mr.state == 'merged')
147
159
 
148
160
 
149
161
def gitlab_url_to_bzr_url(url, name):
168
180
        (host, project_name, branch_name) = parse_gitlab_url(branch)
169
181
        project = self.gl.projects.get(project_name)
170
182
        return gitlab_url_to_bzr_url(
171
 
            project.attributes['ssh_url_to_repo'], branch_name)
 
183
            project.ssh_url_to_repo, branch_name)
172
184
 
173
185
    def publish_derived(self, local_branch, base_branch, name, project=None,
174
186
                        owner=None, revision_id=None, overwrite=False,
194
206
                target_project = base_project.forks.create({})
195
207
            else:
196
208
                raise
197
 
        remote_repo_url = git_url_to_bzr_url(target_project.attributes['ssh_url_to_repo'])
 
209
        remote_repo_url = git_url_to_bzr_url(target_project.ssh_url_to_repo)
198
210
        remote_dir = controldir.ControlDir.open(remote_repo_url)
199
211
        try:
200
212
            push_result = remote_dir.push_branch(local_branch, revision_id=revision_id,
205
217
            push_result = remote_dir.push_branch(local_branch, revision_id=revision_id,
206
218
                overwrite=overwrite, name=name, lossy=True)
207
219
        public_url = gitlab_url_to_bzr_url(
208
 
            target_project.attributes['http_url_to_repo'], name)
 
220
            target_project.http_url_to_repo, name)
209
221
        return push_result.target_branch, public_url
210
222
 
211
223
    def get_derived_branch(self, base_branch, name, project=None, owner=None):
230
242
                raise errors.NotBranchError('%s/%s/%s' % (self.gl.url, owner, project))
231
243
            raise
232
244
        return _mod_branch.Branch.open(gitlab_url_to_bzr_url(
233
 
                target_project.attributes['ssh_url_to_repo'], name))
 
245
                target_project.ssh_url_to_repo, name))
234
246
 
235
247
    def get_proposer(self, source_branch, target_branch):
236
248
        return GitlabMergeProposalBuilder(self.gl, source_branch, target_branch)
248
260
        target_project = self.gl.projects.get(target_project_name)
249
261
        try:
250
262
            for mr in target_project.mergerequests.list(state='all'):
251
 
                if (mr.attributes['source_project_id'] != source_project.id or
252
 
                    mr.attributes['source_branch'] != source_branch_name or
253
 
                    mr.attributes['target_project_id'] != target_project.id or
254
 
                    mr.attributes['target_branch'] != target_branch_name):
 
263
                if (mr.source_project_id != source_project.id or
 
264
                    mr.source_branch != source_branch_name or
 
265
                    mr.target_project_id != target_project.id or
 
266
                    mr.target_branch != target_branch_name):
255
267
                    continue
256
268
                return GitLabMergeProposal(mr)
257
269
        except gitlab.GitlabListError as e: