Mercurial > libervia-backend
annotate sat/plugins/plugin_merge_req_mercurial.py @ 3082:9211c0d8b50c
plugin manhole: fixed default value
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Dec 2019 15:19:31 +0100 |
parents | fee60f17ebac |
children | 9d0df638c8b4 |
rev | line source |
---|---|
3028 | 1 #!/usr/bin/env python3 |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # SàT plugin for import external blogs |
2771 | 5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org) |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
2793
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
20 import re |
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
21 from twisted.python.procutils import which |
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
22 from sat.tools.common import async_process |
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
23 from sat.tools import utils |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from sat.core.i18n import _, D_ |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 from sat.core.constants import Const as C |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from sat.core import exceptions |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 from sat.core.log import getLogger |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 log = getLogger(__name__) |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 PLUGIN_INFO = { |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 C.PI_NAME: "Mercurial Merge Request handler", |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 C.PI_IMPORT_NAME: "MERGE_REQUEST_MERCURIAL", |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 C.PI_TYPE: C.PLUG_TYPE_MISC, |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 C.PI_DEPENDENCIES: ["MERGE_REQUESTS"], |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 C.PI_MAIN: "MercurialHandler", |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 C.PI_HANDLER: "no", |
3028 | 38 C.PI_DESCRIPTION: _("""Merge request handler for Mercurial""") |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 } |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 |
3028 | 41 SHORT_DESC = D_("handle Mercurial repository") |
42 CLEAN_RE = re.compile(r'[^\w -._]', flags=re.UNICODE) | |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 |
2793
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
45 class MercurialProtocol(async_process.CommandProtocol): |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 """handle hg commands""" |
3028 | 47 name = "Mercurial" |
2793
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
48 command = None |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 @classmethod |
2544
a64887289931
plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
51 def run(cls, path, command, *args, **kwargs): |
2620 | 52 """Create a new MercurialRegisterProtocol and execute the given mercurial command. |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 @param path(unicode): path to the repository |
2793
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
55 @param command(unicode): hg command to run |
3040 | 56 @return D(bytes): stdout of the command |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 """ |
3028 | 58 assert "path" not in kwargs |
2793
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
59 kwargs["path"] = path |
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
60 # FIXME: we have to use this workaround because Twisted's protocol.ProcessProtocol |
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
61 # is not using new style classes. This can be removed once moved to |
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
62 # Python 3 (super can be used normally then). |
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
63 d = async_process.CommandProtocol.run.__func__(cls, command, *args, **kwargs) |
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
64 d.addErrback(utils.logError) |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 return d |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 class MercurialHandler(object): |
3028 | 69 data_types = ('mercurial_changeset',) |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 def __init__(self, host): |
3028 | 72 log.info(_("Mercurial merge request handler initialization")) |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 try: |
2793
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
74 MercurialProtocol.command = which('hg')[0] |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 except IndexError: |
3028 | 76 raise exceptions.NotFound(_("Mercurial executable (hg) not found, " |
77 "can't use Mercurial handler")) | |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 self.host = host |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 self._m = host.plugins['MERGE_REQUESTS'] |
2544
a64887289931
plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
80 self._m.register('mercurial', self, self.data_types, SHORT_DESC) |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 |
2793
181735d1b062
plugin mr mercurial, tools(common/utils): moved command protocol to a new module
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
82 |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 def check(self, repository): |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 d = MercurialProtocol.run(repository, 'identify') |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2627
diff
changeset
|
85 d.addCallback(lambda __: True) |
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2627
diff
changeset
|
86 d.addErrback(lambda __: False) |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 return d |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 def export(self, repository): |
3040 | 90 d = MercurialProtocol.run(repository, 'export', '-g', '-r', 'outgoing()', |
91 '--encoding=utf-8') | |
92 d.addCallback(lambda data: data.decode('utf-8')) | |
93 return d | |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 |
2544
a64887289931
plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
95 def import_(self, repository, data, data_type, item_id, service, node, extra): |
a64887289931
plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
96 parsed_data = self.parse(data) |
a64887289931
plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
97 try: |
3028 | 98 parsed_name = parsed_data[0]['commit_msg'].split('\n')[0] |
99 parsed_name = CLEAN_RE.sub('', parsed_name)[:40] | |
2544
a64887289931
plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
100 except Exception: |
3028 | 101 parsed_name = '' |
102 name = 'mr_{item_id}_{parsed_name}'.format(item_id=CLEAN_RE.sub('', item_id), | |
3040 | 103 parsed_name=parsed_name) |
2620 | 104 return MercurialProtocol.run(repository, 'qimport', '-g', '--name', name, |
105 '--encoding=utf-8', '-', stdin=data) | |
2544
a64887289931
plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
106 |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 def parse(self, data, data_type=None): |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 lines = data.splitlines() |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 total_lines = len(lines) |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 patches = [] |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 while lines: |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 patch = {} |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 commit_msg = [] |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 diff = [] |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 state = 'init' |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 if lines[0] != '# HG changeset patch': |
3028 | 117 raise exceptions.DataError(_('invalid changeset signature')) |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 # line index of this patch in the whole data |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 patch_idx = total_lines - len(lines) |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 del lines[0] |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 for idx, line in enumerate(lines): |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 if state == 'init': |
3028 | 124 if line.startswith('# '): |
125 if line.startswith('# User '): | |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 elems = line[7:].split() |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 if not elems: |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 continue |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 last = elems[-1] |
3028 | 130 if (last.startswith('<') and last.endswith('>') |
131 and '@' in last): | |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 patch[self._m.META_EMAIL] = elems.pop()[1:-1] |
3028 | 133 patch[self._m.META_AUTHOR] = ' '.join(elems) |
134 elif line.startswith('# Date '): | |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 time_data = line[7:].split() |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 if len(time_data) != 2: |
3028 | 137 log.warning(_('unexpected time data: {data}') |
2620 | 138 .format(data=line[7:])) |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 continue |
2620 | 140 patch[self._m.META_TIMESTAMP] = (int(time_data[0]) |
141 + int(time_data[1])) | |
3028 | 142 elif line.startswith('# Node ID '): |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 patch[self._m.META_HASH] = line[10:] |
3028 | 144 elif line.startswith('# Parent '): |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 patch[self._m.META_PARENT_HASH] = line[10:] |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 else: |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 state = 'commit_msg' |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 if state == 'commit_msg': |
3028 | 149 if line.startswith('diff --git a/'): |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 state = 'diff' |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 patch[self._m.META_DIFF_IDX] = patch_idx + idx + 1 |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 else: |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 commit_msg.append(line) |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 if state == 'diff': |
3028 | 155 if line.startswith('# ') or idx == len(lines)-1: |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 # a new patch is starting or we have reached end of patches |
2627
163aab916bcf
plugin merge-request/mercurial: fixed missing last line in diff while parsing patch
Goffi <goffi@goffi.org>
parents:
2623
diff
changeset
|
157 if idx == len(lines)-1: |
163aab916bcf
plugin merge-request/mercurial: fixed missing last line in diff while parsing patch
Goffi <goffi@goffi.org>
parents:
2623
diff
changeset
|
158 # end of patches, we need to keep the line |
163aab916bcf
plugin merge-request/mercurial: fixed missing last line in diff while parsing patch
Goffi <goffi@goffi.org>
parents:
2623
diff
changeset
|
159 diff.append(line) |
3028 | 160 patch[self._m.META_COMMIT_MSG] = '\n'.join(commit_msg) |
161 patch[self._m.META_DIFF] = '\n'.join(diff) | |
2449
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 patches.append(patch) |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 if idx == len(lines)-1: |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 del lines[:] |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 else: |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 del lines[:idx] |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 break |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 else: |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 diff.append(line) |
67942ba2ee55
plugin merge requests Mercurial: first draft:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 return patches |