annotate frontends/src/jp/cmd_merge_request.py @ 2561:bd30dc3ffe5a

plugin merge-request mercurial: keeps more chars for import name
author Goffi <goffi@goffi.org>
date Mon, 02 Apr 2018 08:56:24 +0200
parents 501b0f827f63
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # jp: a SàT command line tool
2483
0046283a285d dates update
Goffi <goffi@goffi.org>
parents: 2450
diff changeset
5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org)
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 import base
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from sat.core.i18n import _
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from sat_frontends.jp.constants import Const as C
2542
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
24 from sat_frontends.jp import xmlui_manager
2551
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
25 from sat_frontends.jp import common
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from functools import partial
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 import os.path
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 __commands__ = ["MergeRequest"]
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 class Set(base.CommandBase):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 def __init__(self, host):
2551
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
35 base.CommandBase.__init__(self, host, 'set', use_pubsub=True,
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
36 pubsub_defaults = {u'service': _(u'auto'), u'node': _(u'auto')},
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
37 help=_(u'publish or update a merge request'))
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 self.need_loop=True
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 def add_parser_options(self):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 self.parser.add_argument("-i", "--item", type=base.unicode_decoder, default=u'', help=_(u"id or URL of the request to update, or nothing for a new one"))
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 self.parser.add_argument("-r", "--repository", metavar="PATH", type=base.unicode_decoder, default=u'.', help=_(u"path of the repository (DEFAULT: current directory)"))
2551
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
43 self.parser.add_argument("-f", "--force", action="store_true", help=_(u"publish merge request without confirmation"))
2554
0062d3e79d12 plugin uri finder, jp (merge-request): labels handling:
Goffi <goffi@goffi.org>
parents: 2553
diff changeset
44 self.parser.add_argument("-l", "--label", dest="labels", type=base.unicode_decoder, action='append', help=_(u"labels to categorize your request"))
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
45
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 def mergeRequestSetCb(self, published_id):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 if published_id:
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.disp(u"Merge request published at {pub_id}".format(pub_id=published_id))
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 else:
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 self.disp(u"Merge request published")
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 self.host.quit(C.EXIT_OK)
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
52
2551
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
53 def sendRequest(self):
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 extra = {'update': 'true'} if self.args.item else {}
2554
0062d3e79d12 plugin uri finder, jp (merge-request): labels handling:
Goffi <goffi@goffi.org>
parents: 2553
diff changeset
55 values = {}
0062d3e79d12 plugin uri finder, jp (merge-request): labels handling:
Goffi <goffi@goffi.org>
parents: 2553
diff changeset
56 if self.args.labels is not None:
0062d3e79d12 plugin uri finder, jp (merge-request): labels handling:
Goffi <goffi@goffi.org>
parents: 2553
diff changeset
57 values[u'labels'] = self.args.labels
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 self.host.bridge.mergeRequestSet(
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 self.args.service,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 self.args.node,
2551
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
61 self.repository,
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 u'auto',
2554
0062d3e79d12 plugin uri finder, jp (merge-request): labels handling:
Goffi <goffi@goffi.org>
parents: 2553
diff changeset
63 values,
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 u'',
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 self.args.item,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 extra,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 self.profile,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 callback=self.mergeRequestSetCb,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 errback=partial(self.errback,
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 msg=_(u"can't create merge request: {}"),
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 exit_code=C.EXIT_BRIDGE_ERRBACK))
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
72
2551
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
73 def askConfirmation(self):
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
74 if not self.args.force:
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
75 message = _(u"You are going to publish your changes to service [{service}], are you sure ?").format(
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
76 service=self.args.service)
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
77 self.host.confirmOrQuit(message, _(u"merge request publication cancelled"))
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
78 self.sendRequest()
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
79
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
80 def start(self):
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
81 self.repository = os.path.expanduser(os.path.abspath(self.args.repository))
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
82 common.URIFinder(self, self.repository, 'merge requests', self.askConfirmation)
b27165bf160c jp (merge-request/set): if service and node are not specified, URIFinder is now used + ask confirmation before publishing
Goffi <goffi@goffi.org>
parents: 2545
diff changeset
83
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
84
2542
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
85 class Get(base.CommandBase):
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
86
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
87 def __init__(self, host):
2553
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
88 base.CommandBase.__init__(self, host, 'get', use_verbose=True,
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
89 use_pubsub=True, pubsub_flags={C.MULTI_ITEMS},
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
90 pubsub_defaults = {u'service': _(u'auto'), u'node': _(u'auto')},
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
91 help=_(u'get a merge request'))
2542
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
92 self.need_loop=True
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
93
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
94 def add_parser_options(self):
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
95 pass
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
96
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
97 def mergeRequestGetCb(self, requests_data):
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
98 if self.verbosity >= 1:
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
99 whitelist = None
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
100 else:
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
101 whitelist = {'id', 'title', 'body'}
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
102 for request_xmlui in requests_data[0]:
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
103 xmlui = xmlui_manager.create(self.host, request_xmlui, whitelist=whitelist)
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
104 xmlui.show(values_only=True)
2553
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
105 self.disp(u'')
2542
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
106 self.host.quit(C.EXIT_OK)
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
107
2553
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
108 def getRequests(self):
2542
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
109 extra = {}
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
110 self.host.bridge.mergeRequestsGet(
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
111 self.args.service,
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
112 self.args.node,
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
113 self.args.max,
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
114 self.args.items,
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
115 u'',
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
116 extra,
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
117 self.profile,
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
118 callback=self.mergeRequestGetCb,
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
119 errback=partial(self.errback,
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
120 msg=_(u"can't get merge request: {}"),
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
121 exit_code=C.EXIT_BRIDGE_ERRBACK))
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
122
2553
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
123 def start(self):
2558
501b0f827f63 jp (merge-request,common): fixed URIFinder when metadata are not needed:
Goffi <goffi@goffi.org>
parents: 2554
diff changeset
124 common.URIFinder(self, os.getcwd(), 'merge requests', self.getRequests, meta_map={})
2542
100563768196 jp (merge/get): "get" command first draft:
Goffi <goffi@goffi.org>
parents: 2532
diff changeset
125
2545
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
126
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
127 class Import(base.CommandBase):
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
128
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
129 def __init__(self, host):
2553
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
130 base.CommandBase.__init__(self, host, 'import',
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
131 use_pubsub=True, pubsub_flags={C.SINGLE_ITEM, C.ITEM},
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
132 pubsub_defaults = {u'service': _(u'auto'), u'node': _(u'auto')},
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
133 help=_(u'import a merge request'))
2545
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
134 self.need_loop=True
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
135
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
136 def add_parser_options(self):
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
137 self.parser.add_argument("-r", "--repository", metavar="PATH", type=base.unicode_decoder, default=u'.', help=_(u"path of the repository (DEFAULT: current directory)"))
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
138
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
139 def mergeRequestImportCb(self):
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
140 self.host.quit(C.EXIT_OK)
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
141
2553
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
142 def importRequest(self):
2545
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
143 extra = {}
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
144 self.host.bridge.mergeRequestsImport(
2553
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
145 self.repository,
2545
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
146 self.args.item,
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
147 self.args.service,
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
148 self.args.node,
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
149 extra,
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
150 self.profile,
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
151 callback=self.mergeRequestImportCb,
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
152 errback=partial(self.errback,
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
153 msg=_(u"can't import merge request: {}"),
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
154 exit_code=C.EXIT_BRIDGE_ERRBACK))
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
155
2553
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
156 def start(self):
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
157 self.repository = os.path.expanduser(os.path.abspath(self.args.repository))
2558
501b0f827f63 jp (merge-request,common): fixed URIFinder when metadata are not needed:
Goffi <goffi@goffi.org>
parents: 2554
diff changeset
158 common.URIFinder(self, self.repository, 'merge requests', self.importRequest, meta_map={})
2553
39b10475f56b jp (merge-request): find URIs when --service and --node are not specified for get and import:
Goffi <goffi@goffi.org>
parents: 2551
diff changeset
159
2545
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
160
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 class MergeRequest(base.CommandBase):
2545
2df1ca79cb30 jp (merge-request/import): added import command
Goffi <goffi@goffi.org>
parents: 2542
diff changeset
162 subcommands = (Set, Get, Import)
2450
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
163
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 def __init__(self, host):
124f5db998f2 jp (merge-request): first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 super(MergeRequest, self).__init__(host, 'merge-request', use_profile=False, help=_('merge-request management'))