@teambit/merging 0.0.196 → 0.0.198
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/merge-cmd.js +4 -50
- package/dist/merge-cmd.js.map +1 -1
- package/dist/merging.aspect.js +0 -5
- package/dist/merging.aspect.js.map +1 -1
- package/dist/merging.main.runtime.js +28 -199
- package/dist/merging.main.runtime.js.map +1 -1
- package/package-tar/teambit-merging-0.0.198.tgz +0 -0
- package/package.json +6 -6
- /package/{preview-1666409808293.js → preview-1666582798766.js} +0 -0
- package/package-tar/teambit-merging-0.0.196.tgz +0 -0
|
@@ -1,304 +1,213 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.MergingMain = void 0;
|
|
13
|
-
|
|
14
10
|
function _defineProperty2() {
|
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
|
|
17
12
|
_defineProperty2 = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function _cli() {
|
|
25
18
|
const data = require("@teambit/cli");
|
|
26
|
-
|
|
27
19
|
_cli = function () {
|
|
28
20
|
return data;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return data;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function _workspace() {
|
|
35
25
|
const data = _interopRequireDefault(require("@teambit/workspace"));
|
|
36
|
-
|
|
37
26
|
_workspace = function () {
|
|
38
27
|
return data;
|
|
39
28
|
};
|
|
40
|
-
|
|
41
29
|
return data;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
function _ramda() {
|
|
45
32
|
const data = _interopRequireDefault(require("ramda"));
|
|
46
|
-
|
|
47
33
|
_ramda = function () {
|
|
48
34
|
return data;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
return data;
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
function _componentsList() {
|
|
55
39
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component/components-list"));
|
|
56
|
-
|
|
57
40
|
_componentsList = function () {
|
|
58
41
|
return data;
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
return data;
|
|
62
44
|
}
|
|
63
|
-
|
|
64
45
|
function _mergeVersion() {
|
|
65
46
|
const data = require("@teambit/legacy/dist/consumer/versions-ops/merge-version");
|
|
66
|
-
|
|
67
47
|
_mergeVersion = function () {
|
|
68
48
|
return data;
|
|
69
49
|
};
|
|
70
|
-
|
|
71
50
|
return data;
|
|
72
51
|
}
|
|
73
|
-
|
|
74
52
|
function _exceptions() {
|
|
75
53
|
const data = require("@teambit/legacy/dist/consumer/exceptions");
|
|
76
|
-
|
|
77
54
|
_exceptions = function () {
|
|
78
55
|
return data;
|
|
79
56
|
};
|
|
80
|
-
|
|
81
57
|
return data;
|
|
82
58
|
}
|
|
83
|
-
|
|
84
59
|
function _snapping() {
|
|
85
60
|
const data = _interopRequireDefault(require("@teambit/snapping"));
|
|
86
|
-
|
|
87
61
|
_snapping = function () {
|
|
88
62
|
return data;
|
|
89
63
|
};
|
|
90
|
-
|
|
91
64
|
return data;
|
|
92
65
|
}
|
|
93
|
-
|
|
94
66
|
function _hasWildcard() {
|
|
95
67
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/utils/string/has-wildcard"));
|
|
96
|
-
|
|
97
68
|
_hasWildcard = function () {
|
|
98
69
|
return data;
|
|
99
70
|
};
|
|
100
|
-
|
|
101
71
|
return data;
|
|
102
72
|
}
|
|
103
|
-
|
|
104
73
|
function _pMapSeries() {
|
|
105
74
|
const data = _interopRequireDefault(require("p-map-series"));
|
|
106
|
-
|
|
107
75
|
_pMapSeries = function () {
|
|
108
76
|
return data;
|
|
109
77
|
};
|
|
110
|
-
|
|
111
78
|
return data;
|
|
112
79
|
}
|
|
113
|
-
|
|
114
80
|
function _bitId() {
|
|
115
81
|
const data = require("@teambit/legacy/dist/bit-id");
|
|
116
|
-
|
|
117
82
|
_bitId = function () {
|
|
118
83
|
return data;
|
|
119
84
|
};
|
|
120
|
-
|
|
121
85
|
return data;
|
|
122
86
|
}
|
|
123
|
-
|
|
124
87
|
function _bitError() {
|
|
125
88
|
const data = require("@teambit/bit-error");
|
|
126
|
-
|
|
127
89
|
_bitError = function () {
|
|
128
90
|
return data;
|
|
129
91
|
};
|
|
130
|
-
|
|
131
92
|
return data;
|
|
132
93
|
}
|
|
133
|
-
|
|
134
94
|
function _generalError() {
|
|
135
95
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/error/general-error"));
|
|
136
|
-
|
|
137
96
|
_generalError = function () {
|
|
138
97
|
return data;
|
|
139
98
|
};
|
|
140
|
-
|
|
141
99
|
return data;
|
|
142
100
|
}
|
|
143
|
-
|
|
144
101
|
function _laneId() {
|
|
145
102
|
const data = require("@teambit/lane-id");
|
|
146
|
-
|
|
147
103
|
_laneId = function () {
|
|
148
104
|
return data;
|
|
149
105
|
};
|
|
150
|
-
|
|
151
106
|
return data;
|
|
152
107
|
}
|
|
153
|
-
|
|
154
108
|
function _getDivergeData() {
|
|
155
109
|
const data = require("@teambit/legacy/dist/scope/component-ops/get-diverge-data");
|
|
156
|
-
|
|
157
110
|
_getDivergeData = function () {
|
|
158
111
|
return data;
|
|
159
112
|
};
|
|
160
|
-
|
|
161
113
|
return data;
|
|
162
114
|
}
|
|
163
|
-
|
|
164
115
|
function _chalk() {
|
|
165
116
|
const data = _interopRequireDefault(require("chalk"));
|
|
166
|
-
|
|
167
117
|
_chalk = function () {
|
|
168
118
|
return data;
|
|
169
119
|
};
|
|
170
|
-
|
|
171
120
|
return data;
|
|
172
121
|
}
|
|
173
|
-
|
|
174
122
|
function _repositories() {
|
|
175
123
|
const data = require("@teambit/legacy/dist/scope/repositories");
|
|
176
|
-
|
|
177
124
|
_repositories = function () {
|
|
178
125
|
return data;
|
|
179
126
|
};
|
|
180
|
-
|
|
181
127
|
return data;
|
|
182
128
|
}
|
|
183
|
-
|
|
184
129
|
function _utils() {
|
|
185
130
|
const data = require("@teambit/legacy/dist/utils");
|
|
186
|
-
|
|
187
131
|
_utils = function () {
|
|
188
132
|
return data;
|
|
189
133
|
};
|
|
190
|
-
|
|
191
134
|
return data;
|
|
192
135
|
}
|
|
193
|
-
|
|
194
136
|
function _manyComponentsWriter() {
|
|
195
137
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component-ops/many-components-writer"));
|
|
196
|
-
|
|
197
138
|
_manyComponentsWriter = function () {
|
|
198
139
|
return data;
|
|
199
140
|
};
|
|
200
|
-
|
|
201
141
|
return data;
|
|
202
142
|
}
|
|
203
|
-
|
|
204
143
|
function _logger() {
|
|
205
144
|
const data = require("@teambit/logger");
|
|
206
|
-
|
|
207
145
|
_logger = function () {
|
|
208
146
|
return data;
|
|
209
147
|
};
|
|
210
|
-
|
|
211
148
|
return data;
|
|
212
149
|
}
|
|
213
|
-
|
|
214
150
|
function _checkoutVersion() {
|
|
215
151
|
const data = require("@teambit/legacy/dist/consumer/versions-ops/checkout-version");
|
|
216
|
-
|
|
217
152
|
_checkoutVersion = function () {
|
|
218
153
|
return data;
|
|
219
154
|
};
|
|
220
|
-
|
|
221
155
|
return data;
|
|
222
156
|
}
|
|
223
|
-
|
|
224
157
|
function _threeWayMerge() {
|
|
225
158
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge"));
|
|
226
|
-
|
|
227
159
|
_threeWayMerge = function () {
|
|
228
160
|
return data;
|
|
229
161
|
};
|
|
230
|
-
|
|
231
162
|
return data;
|
|
232
163
|
}
|
|
233
|
-
|
|
234
164
|
function _noCommonSnap() {
|
|
235
165
|
const data = require("@teambit/legacy/dist/scope/exceptions/no-common-snap");
|
|
236
|
-
|
|
237
166
|
_noCommonSnap = function () {
|
|
238
167
|
return data;
|
|
239
168
|
};
|
|
240
|
-
|
|
241
169
|
return data;
|
|
242
170
|
}
|
|
243
|
-
|
|
244
171
|
function _checkout() {
|
|
245
172
|
const data = require("@teambit/checkout");
|
|
246
|
-
|
|
247
173
|
_checkout = function () {
|
|
248
174
|
return data;
|
|
249
175
|
};
|
|
250
|
-
|
|
251
176
|
return data;
|
|
252
177
|
}
|
|
253
|
-
|
|
254
178
|
function _componentId() {
|
|
255
179
|
const data = require("@teambit/component-id");
|
|
256
|
-
|
|
257
180
|
_componentId = function () {
|
|
258
181
|
return data;
|
|
259
182
|
};
|
|
260
|
-
|
|
261
183
|
return data;
|
|
262
184
|
}
|
|
263
|
-
|
|
264
185
|
function _install() {
|
|
265
186
|
const data = require("@teambit/install");
|
|
266
|
-
|
|
267
187
|
_install = function () {
|
|
268
188
|
return data;
|
|
269
189
|
};
|
|
270
|
-
|
|
271
190
|
return data;
|
|
272
191
|
}
|
|
273
|
-
|
|
274
192
|
function _mergeCmd() {
|
|
275
193
|
const data = require("./merge-cmd");
|
|
276
|
-
|
|
277
194
|
_mergeCmd = function () {
|
|
278
195
|
return data;
|
|
279
196
|
};
|
|
280
|
-
|
|
281
197
|
return data;
|
|
282
198
|
}
|
|
283
|
-
|
|
284
199
|
function _merging() {
|
|
285
200
|
const data = require("./merging.aspect");
|
|
286
|
-
|
|
287
201
|
_merging = function () {
|
|
288
202
|
return data;
|
|
289
203
|
};
|
|
290
|
-
|
|
291
204
|
return data;
|
|
292
205
|
}
|
|
293
|
-
|
|
294
206
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
295
|
-
|
|
296
207
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
297
|
-
|
|
298
208
|
class MergingMain {
|
|
299
209
|
constructor(workspace, install, snapping, checkout, logger) {
|
|
300
210
|
var _this$workspace;
|
|
301
|
-
|
|
302
211
|
this.workspace = workspace;
|
|
303
212
|
this.install = install;
|
|
304
213
|
this.snapping = snapping;
|
|
@@ -307,57 +216,48 @@ class MergingMain {
|
|
|
307
216
|
(0, _defineProperty2().default)(this, "consumer", void 0);
|
|
308
217
|
this.consumer = (_this$workspace = this.workspace) === null || _this$workspace === void 0 ? void 0 : _this$workspace.consumer;
|
|
309
218
|
}
|
|
219
|
+
|
|
310
220
|
/**
|
|
311
221
|
* merge components according to the "values" param.
|
|
312
222
|
* if the first param is a version, then merge the component ids to that version.
|
|
313
223
|
* otherwise, merge from the remote head to the local.
|
|
314
224
|
*/
|
|
315
|
-
|
|
316
|
-
|
|
317
225
|
async merge(values, mergeStrategy, abort, resolve, noSnap, message, build, skipDependencyInstallation) {
|
|
318
226
|
if (!this.workspace) throw new (_exceptions().ConsumerNotFound)();
|
|
319
227
|
const consumer = this.workspace.consumer;
|
|
320
228
|
let mergeResults;
|
|
321
|
-
|
|
322
229
|
const firstValue = _ramda().default.head(values);
|
|
323
|
-
|
|
324
230
|
if (resolve) {
|
|
325
231
|
mergeResults = await this.resolveMerge(values, message, build);
|
|
326
232
|
} else if (abort) {
|
|
327
233
|
mergeResults = await this.abortMerge(values);
|
|
328
234
|
} else if (!_bitId().BitId.isValidVersion(firstValue)) {
|
|
329
|
-
const bitIds = this.getComponentsToMerge(consumer, values);
|
|
330
|
-
|
|
235
|
+
const bitIds = this.getComponentsToMerge(consumer, values);
|
|
236
|
+
// @todo: version could be the lane only or remote/lane
|
|
331
237
|
mergeResults = await this.mergeComponentsFromRemote(consumer, bitIds, mergeStrategy, noSnap, message, build, skipDependencyInstallation);
|
|
332
238
|
} else {
|
|
333
239
|
const version = firstValue;
|
|
334
|
-
|
|
335
240
|
const ids = _ramda().default.tail(values);
|
|
336
|
-
|
|
337
241
|
const bitIds = this.getComponentsToMerge(consumer, ids);
|
|
338
242
|
mergeResults = await (0, _mergeVersion().mergeVersion)(consumer, version, bitIds, mergeStrategy);
|
|
339
243
|
}
|
|
340
|
-
|
|
341
244
|
await consumer.onDestroy();
|
|
342
245
|
return mergeResults;
|
|
343
246
|
}
|
|
247
|
+
|
|
344
248
|
/**
|
|
345
249
|
* when user is on main, it merges the remote main components into local.
|
|
346
250
|
* when user is on a lane, it merges the remote lane components into the local lane.
|
|
347
251
|
*/
|
|
348
|
-
|
|
349
|
-
|
|
350
252
|
async mergeComponentsFromRemote(consumer, bitIds, mergeStrategy, noSnap, snapMessage, build, skipDependencyInstallation) {
|
|
351
253
|
const currentLaneId = consumer.getCurrentLaneId();
|
|
352
254
|
const currentLaneObject = await consumer.getCurrentLaneObject();
|
|
353
255
|
const allComponentsStatus = await this.getAllComponentsStatus(bitIds, currentLaneId, currentLaneObject);
|
|
354
256
|
const failedComponents = allComponentsStatus.filter(c => c.unmergedMessage && !c.unmergedLegitimately);
|
|
355
|
-
|
|
356
257
|
if (failedComponents.length) {
|
|
357
258
|
const failureMsgs = failedComponents.map(failedComponent => `${_chalk().default.bold(failedComponent.id.toString())} - ${_chalk().default.red(failedComponent.unmergedMessage)}`).join('\n');
|
|
358
259
|
throw new (_bitError().BitError)(`unable to merge due to the following failures:\n${failureMsgs}`);
|
|
359
260
|
}
|
|
360
|
-
|
|
361
261
|
return this.mergeSnaps({
|
|
362
262
|
mergeStrategy,
|
|
363
263
|
allComponentsStatus,
|
|
@@ -369,11 +269,10 @@ class MergingMain {
|
|
|
369
269
|
skipDependencyInstallation
|
|
370
270
|
});
|
|
371
271
|
}
|
|
272
|
+
|
|
372
273
|
/**
|
|
373
274
|
* merge multiple components according to the "allComponentsStatus".
|
|
374
275
|
*/
|
|
375
|
-
|
|
376
|
-
|
|
377
276
|
async mergeSnaps({
|
|
378
277
|
mergeStrategy,
|
|
379
278
|
allComponentsStatus,
|
|
@@ -387,19 +286,17 @@ class MergingMain {
|
|
|
387
286
|
}) {
|
|
388
287
|
const consumer = this.workspace.consumer;
|
|
389
288
|
const componentWithConflict = allComponentsStatus.find(component => component.mergeResults && component.mergeResults.hasConflicts);
|
|
390
|
-
|
|
391
289
|
if (componentWithConflict && !mergeStrategy) {
|
|
392
290
|
mergeStrategy = await (0, _mergeVersion().getMergeStrategyInteractive)();
|
|
393
291
|
}
|
|
394
|
-
|
|
395
292
|
const failedComponents = allComponentsStatus.filter(componentStatus => componentStatus.unmergedMessage).map(componentStatus => ({
|
|
396
293
|
id: componentStatus.id,
|
|
397
294
|
failureMessage: componentStatus.unmergedMessage,
|
|
398
295
|
unchangedLegitimately: componentStatus.unmergedLegitimately
|
|
399
296
|
}));
|
|
400
|
-
const succeededComponents = allComponentsStatus.filter(componentStatus => !componentStatus.unmergedMessage);
|
|
297
|
+
const succeededComponents = allComponentsStatus.filter(componentStatus => !componentStatus.unmergedMessage);
|
|
298
|
+
// do not use Promise.all for applyVersion. otherwise, it'll write all components in parallel,
|
|
401
299
|
// which can be an issue when some components are also dependencies of others
|
|
402
|
-
|
|
403
300
|
const componentsResults = await (0, _pMapSeries().default)(succeededComponents, async ({
|
|
404
301
|
currentComponent,
|
|
405
302
|
id,
|
|
@@ -425,7 +322,6 @@ class MergingMain {
|
|
|
425
322
|
await consumer.scope.objects.unmergedComponents.write();
|
|
426
323
|
await consumer.writeBitMap();
|
|
427
324
|
const leftUnresolvedConflicts = componentWithConflict && mergeStrategy === 'manual';
|
|
428
|
-
|
|
429
325
|
if (!skipDependencyInstallation && !leftUnresolvedConflicts) {
|
|
430
326
|
try {
|
|
431
327
|
await this.install.install(undefined, {
|
|
@@ -438,14 +334,12 @@ class MergingMain {
|
|
|
438
334
|
this.logger.consoleError(`failed installing packages, see the log for full stacktrace. error: ${err.message}`);
|
|
439
335
|
}
|
|
440
336
|
}
|
|
441
|
-
|
|
442
337
|
const getSnapOrTagResults = async () => {
|
|
443
338
|
// if one of the component has conflict, don't snap-merge. otherwise, some of the components would be snap-merged
|
|
444
339
|
// and some not. besides the fact that it could by mistake tag dependent, it's a confusing state. better not snap.
|
|
445
340
|
if (noSnap || leftUnresolvedConflicts) {
|
|
446
341
|
return null;
|
|
447
342
|
}
|
|
448
|
-
|
|
449
343
|
if (tag) {
|
|
450
344
|
const idsToTag = allComponentsStatus.map(c => c.id);
|
|
451
345
|
const results = await this.tagAllLaneComponent(idsToTag, snapMessage, build);
|
|
@@ -459,19 +353,15 @@ class MergingMain {
|
|
|
459
353
|
autoSnappedResults: autoTaggedResults
|
|
460
354
|
};
|
|
461
355
|
}
|
|
462
|
-
|
|
463
356
|
return this.snapResolvedComponents(consumer, snapMessage, build);
|
|
464
357
|
};
|
|
465
|
-
|
|
466
358
|
let mergeSnapResults = null;
|
|
467
359
|
let mergeSnapError;
|
|
468
|
-
|
|
469
360
|
try {
|
|
470
361
|
mergeSnapResults = await getSnapOrTagResults();
|
|
471
362
|
} catch (err) {
|
|
472
363
|
mergeSnapError = err;
|
|
473
364
|
}
|
|
474
|
-
|
|
475
365
|
return {
|
|
476
366
|
components: componentsResults,
|
|
477
367
|
failedComponents,
|
|
@@ -480,6 +370,7 @@ class MergingMain {
|
|
|
480
370
|
leftUnresolvedConflicts
|
|
481
371
|
};
|
|
482
372
|
}
|
|
373
|
+
|
|
483
374
|
/**
|
|
484
375
|
* this function gets called from two different commands:
|
|
485
376
|
* 1. "bit merge <ids...>", when merging a component from a remote to the local.
|
|
@@ -491,35 +382,30 @@ class MergingMain {
|
|
|
491
382
|
* @param existingOnWorkspaceOnly
|
|
492
383
|
* @returns
|
|
493
384
|
*/
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
otherLaneName,
|
|
385
|
+
async getComponentMergeStatus(id,
|
|
386
|
+
// the id.version is the version we want to merge to the current component
|
|
387
|
+
localLane,
|
|
388
|
+
// currently checked out lane. if on main, then it's null.
|
|
389
|
+
otherLaneName,
|
|
390
|
+
// the lane name we want to merged to our lane. (can be also "main").
|
|
499
391
|
options) {
|
|
500
392
|
const consumer = this.workspace.consumer;
|
|
501
393
|
const componentStatus = {
|
|
502
394
|
id
|
|
503
395
|
};
|
|
504
|
-
|
|
505
396
|
const returnUnmerged = (msg, unmergedLegitimately = false) => {
|
|
506
397
|
componentStatus.unmergedMessage = msg;
|
|
507
398
|
componentStatus.unmergedLegitimately = unmergedLegitimately;
|
|
508
399
|
return componentStatus;
|
|
509
400
|
};
|
|
510
|
-
|
|
511
401
|
const modelComponent = await consumer.scope.getModelComponentIfExist(id);
|
|
512
|
-
|
|
513
402
|
if (!modelComponent) {
|
|
514
403
|
return returnUnmerged(`component ${id.toString()} is on the lane/main but its objects were not found, please re-import the lane`);
|
|
515
404
|
}
|
|
516
|
-
|
|
517
405
|
const unmerged = consumer.scope.objects.unmergedComponents.getEntry(id.name);
|
|
518
|
-
|
|
519
406
|
if (unmerged) {
|
|
520
407
|
return returnUnmerged(`component ${id.toStringWithoutVersion()} is in during-merge state a previous merge, please snap/tag it first (or use bit merge --resolve/--abort)`);
|
|
521
408
|
}
|
|
522
|
-
|
|
523
409
|
const repo = consumer.scope.objects;
|
|
524
410
|
const version = id.version;
|
|
525
411
|
const otherLaneHead = modelComponent.getRef(version);
|
|
@@ -527,32 +413,24 @@ class MergingMain {
|
|
|
527
413
|
ignoreVersion: true
|
|
528
414
|
});
|
|
529
415
|
const componentOnLane = await modelComponent.loadVersion(version, consumer.scope.objects);
|
|
530
|
-
|
|
531
416
|
if (componentOnLane.isRemoved()) {
|
|
532
417
|
return returnUnmerged(`component has been removed`, true);
|
|
533
418
|
}
|
|
534
|
-
|
|
535
419
|
const getCurrentId = () => {
|
|
536
420
|
if (existingBitMapId) return existingBitMapId;
|
|
537
|
-
|
|
538
421
|
if (localLane) {
|
|
539
422
|
const idOnLane = localLane.getComponent(id);
|
|
540
423
|
if (!idOnLane) return null;
|
|
541
424
|
return idOnLane.id.changeVersion(idOnLane.head.toString());
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
|
|
425
|
+
}
|
|
426
|
+
// it's on main
|
|
545
427
|
const head = modelComponent.getHeadAsTagIfExist();
|
|
546
|
-
|
|
547
428
|
if (head) {
|
|
548
429
|
return id.changeVersion(head);
|
|
549
430
|
}
|
|
550
|
-
|
|
551
431
|
return null;
|
|
552
432
|
};
|
|
553
|
-
|
|
554
433
|
const currentId = getCurrentId();
|
|
555
|
-
|
|
556
434
|
if (!currentId) {
|
|
557
435
|
const divergeData = await (0, _getDivergeData().getDivergeData)({
|
|
558
436
|
repo,
|
|
@@ -568,14 +446,11 @@ class MergingMain {
|
|
|
568
446
|
divergeData
|
|
569
447
|
};
|
|
570
448
|
}
|
|
571
|
-
|
|
572
449
|
const getCurrentComponent = () => {
|
|
573
450
|
if (existingBitMapId) return consumer.loadComponent(existingBitMapId);
|
|
574
451
|
return consumer.scope.getConsumerComponent(currentId);
|
|
575
452
|
};
|
|
576
|
-
|
|
577
453
|
const currentComponent = await getCurrentComponent();
|
|
578
|
-
|
|
579
454
|
const isModified = async () => {
|
|
580
455
|
const componentModificationStatus = await consumer.getComponentStatusById(currentComponent.id);
|
|
581
456
|
if (!componentModificationStatus.modified) return false;
|
|
@@ -583,21 +458,18 @@ class MergingMain {
|
|
|
583
458
|
const baseComponent = await modelComponent.loadVersion(existingBitMapId.version, consumer.scope.objects);
|
|
584
459
|
return options !== null && options !== void 0 && options.ignoreConfigChanges ? consumer.isComponentSourceCodeModified(baseComponent, currentComponent) : true;
|
|
585
460
|
};
|
|
586
|
-
|
|
587
461
|
const isComponentModified = await isModified();
|
|
588
|
-
|
|
589
462
|
if (isComponentModified) {
|
|
590
463
|
return returnUnmerged(`component is modified, please snap/tag it first`);
|
|
591
|
-
}
|
|
464
|
+
}
|
|
465
|
+
// @todo: is it needed?
|
|
592
466
|
// const laneHeadIsDifferentThanCheckedOut =
|
|
593
467
|
// localLane && existingBitMapId?.version && modelComponent.laneHeadLocal?.toString() !== existingBitMapId?.version;
|
|
594
468
|
// const localHead = laneHeadIsDifferentThanCheckedOut ? Ref.from(existingBitMapId.version) : null;
|
|
595
469
|
|
|
596
|
-
|
|
597
470
|
if (!otherLaneHead) {
|
|
598
471
|
throw new Error(`merging: unable finding a hash for the version ${version} of ${id.toString()}`);
|
|
599
472
|
}
|
|
600
|
-
|
|
601
473
|
const divergeData = await (0, _getDivergeData().getDivergeData)({
|
|
602
474
|
repo,
|
|
603
475
|
modelComponent,
|
|
@@ -605,10 +477,8 @@ class MergingMain {
|
|
|
605
477
|
// checkedOutLocalHead: localHead,
|
|
606
478
|
throws: false
|
|
607
479
|
});
|
|
608
|
-
|
|
609
480
|
if (divergeData.err) {
|
|
610
481
|
const mainHead = modelComponent.head;
|
|
611
|
-
|
|
612
482
|
if (divergeData.err instanceof _noCommonSnap().NoCommonSnap && options !== null && options !== void 0 && options.resolveUnrelated && mainHead) {
|
|
613
483
|
const hasResolvedFromMain = async hashToCompare => {
|
|
614
484
|
const divergeDataFromMain = await (0, _getDivergeData().getDivergeData)({
|
|
@@ -621,18 +491,14 @@ class MergingMain {
|
|
|
621
491
|
if (!divergeDataFromMain.err) return true;
|
|
622
492
|
return !(divergeDataFromMain.err instanceof _noCommonSnap().NoCommonSnap);
|
|
623
493
|
};
|
|
624
|
-
|
|
625
494
|
const hasResolvedLocally = await hasResolvedFromMain(modelComponent.getHeadRegardlessOfLane());
|
|
626
495
|
const hasResolvedRemotely = await hasResolvedFromMain(otherLaneHead);
|
|
627
|
-
|
|
628
496
|
if (!hasResolvedLocally && !hasResolvedRemotely) {
|
|
629
497
|
return returnUnmerged(`unable to traverse ${currentComponent.id.toString()} history. the main-head ${mainHead.toString()} doesn't appear in both lanes, it was probably created in each lane separately`);
|
|
630
498
|
}
|
|
631
|
-
|
|
632
499
|
const versionToSaveInLane = hasResolvedLocally ? currentComponent.id.version : id.version;
|
|
633
500
|
const resolvedRef = modelComponent.getRef(versionToSaveInLane);
|
|
634
501
|
if (!resolvedRef) throw new Error(`unable to get ref of "${versionToSaveInLane}" for "${id.toString()}"`);
|
|
635
|
-
|
|
636
502
|
if ((options === null || options === void 0 ? void 0 : options.resolveUnrelated) === 'theirs') {
|
|
637
503
|
// just override with the model data
|
|
638
504
|
return {
|
|
@@ -647,7 +513,6 @@ class MergingMain {
|
|
|
647
513
|
}
|
|
648
514
|
};
|
|
649
515
|
}
|
|
650
|
-
|
|
651
516
|
if ((options === null || options === void 0 ? void 0 : options.resolveUnrelated) === 'ours') {
|
|
652
517
|
return {
|
|
653
518
|
currentComponent,
|
|
@@ -660,19 +525,15 @@ class MergingMain {
|
|
|
660
525
|
}
|
|
661
526
|
};
|
|
662
527
|
}
|
|
663
|
-
|
|
664
528
|
throw new Error(`unsupported strategy "${options === null || options === void 0 ? void 0 : options.resolveUnrelated}" of resolve-unrelated. supported strategies are: [ours, theirs]`);
|
|
665
529
|
}
|
|
666
|
-
|
|
667
530
|
return returnUnmerged(`unable to traverse ${currentComponent.id.toString()} history. error: ${divergeData.err.message}`);
|
|
668
531
|
}
|
|
669
|
-
|
|
670
532
|
if (!divergeData.isDiverged()) {
|
|
671
533
|
if (divergeData.isLocalAhead()) {
|
|
672
534
|
// do nothing!
|
|
673
535
|
return returnUnmerged(`component ${currentComponent.id.toString()} is ahead, nothing to merge`, true);
|
|
674
536
|
}
|
|
675
|
-
|
|
676
537
|
if (divergeData.isRemoteAhead()) {
|
|
677
538
|
// just override with the model data
|
|
678
539
|
return {
|
|
@@ -682,14 +543,11 @@ class MergingMain {
|
|
|
682
543
|
mergeResults: null,
|
|
683
544
|
divergeData
|
|
684
545
|
};
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
|
|
546
|
+
}
|
|
547
|
+
// we know that localHead and remoteHead are set, so if none of them is ahead they must be equal
|
|
688
548
|
return returnUnmerged(`component ${currentComponent.id.toString()} is already merged`, true);
|
|
689
549
|
}
|
|
690
|
-
|
|
691
550
|
const baseSnap = divergeData.commonSnapBeforeDiverge; // must be set when isTrueMerge
|
|
692
|
-
|
|
693
551
|
const baseComponent = await modelComponent.loadVersion(baseSnap.toString(), repo);
|
|
694
552
|
const otherComponent = await modelComponent.loadVersion(otherLaneHead.toString(), repo);
|
|
695
553
|
const currentLaneName = (localLane === null || localLane === void 0 ? void 0 : localLane.toLaneId().toString()) || 'main';
|
|
@@ -708,7 +566,6 @@ class MergingMain {
|
|
|
708
566
|
divergeData
|
|
709
567
|
};
|
|
710
568
|
}
|
|
711
|
-
|
|
712
569
|
async applyVersion({
|
|
713
570
|
currentComponent,
|
|
714
571
|
id,
|
|
@@ -736,7 +593,6 @@ class MergingMain {
|
|
|
736
593
|
};
|
|
737
594
|
id = currentComponent ? currentComponent.id : id;
|
|
738
595
|
const modelComponent = await consumer.scope.getModelComponent(id);
|
|
739
|
-
|
|
740
596
|
const handleResolveUnrelated = () => {
|
|
741
597
|
if (!currentComponent) throw new Error('currentComponent must be defined when resolvedUnrelated');
|
|
742
598
|
if (!localLane) throw new Error('localLane must be defined when resolvedUnrelated');
|
|
@@ -756,14 +612,12 @@ class MergingMain {
|
|
|
756
612
|
filesStatus
|
|
757
613
|
};
|
|
758
614
|
};
|
|
759
|
-
|
|
760
615
|
const markAllFilesAsUnchanged = () => {
|
|
761
616
|
if (!currentComponent) throw new Error(`applyVersion expect to get currentComponent for ${id.toString()}`);
|
|
762
617
|
currentComponent.files.forEach(file => {
|
|
763
618
|
filesStatus[(0, _utils().pathNormalizeToLinux)(file.relative)] = _mergeVersion().FileStatus.unchanged;
|
|
764
619
|
});
|
|
765
620
|
};
|
|
766
|
-
|
|
767
621
|
if (mergeResults && mergeResults.hasConflicts && mergeStrategy === _mergeVersion().MergeOptions.ours) {
|
|
768
622
|
markAllFilesAsUnchanged();
|
|
769
623
|
consumer.scope.objects.unmergedComponents.addEntry(unmergedComponent);
|
|
@@ -772,12 +626,10 @@ class MergingMain {
|
|
|
772
626
|
filesStatus
|
|
773
627
|
};
|
|
774
628
|
}
|
|
775
|
-
|
|
776
629
|
if ((resolvedUnrelated === null || resolvedUnrelated === void 0 ? void 0 : resolvedUnrelated.strategy) === 'ours') {
|
|
777
630
|
markAllFilesAsUnchanged();
|
|
778
631
|
return handleResolveUnrelated();
|
|
779
632
|
}
|
|
780
|
-
|
|
781
633
|
const remoteId = id.changeVersion(remoteHead.toString());
|
|
782
634
|
const idToLoad = !mergeResults || mergeStrategy === _mergeVersion().MergeOptions.theirs ? remoteId : id;
|
|
783
635
|
const componentWithDependencies = await consumer.loadComponentWithDependenciesFromModel(idToLoad);
|
|
@@ -786,7 +638,6 @@ class MergingMain {
|
|
|
786
638
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
787
639
|
filesStatus[(0, _utils().pathNormalizeToLinux)(file.relative)] = _mergeVersion().FileStatus.updated;
|
|
788
640
|
});
|
|
789
|
-
|
|
790
641
|
if (mergeResults) {
|
|
791
642
|
// update files according to the merge results
|
|
792
643
|
const {
|
|
@@ -796,7 +647,6 @@ class MergingMain {
|
|
|
796
647
|
componentWithDependencies.component.files = modifiedFiles;
|
|
797
648
|
filesStatus = _objectSpread(_objectSpread({}, filesStatus), modifiedStatus);
|
|
798
649
|
}
|
|
799
|
-
|
|
800
650
|
const manyComponentsWriter = new (_manyComponentsWriter().default)({
|
|
801
651
|
consumer,
|
|
802
652
|
componentsWithDependencies: [componentWithDependencies],
|
|
@@ -805,41 +655,38 @@ class MergingMain {
|
|
|
805
655
|
writeConfig: false,
|
|
806
656
|
// @todo: should write if config exists before, needs to figure out how to do it.
|
|
807
657
|
verbose: false // @todo: do we need a flag here?
|
|
808
|
-
|
|
809
658
|
});
|
|
810
|
-
await manyComponentsWriter.writeAll(); // if mergeResults, the head snap is going to be updated on a later phase when snapping with two parents
|
|
811
|
-
// otherwise, update the head of the current lane or main
|
|
812
659
|
|
|
660
|
+
await manyComponentsWriter.writeAll();
|
|
661
|
+
|
|
662
|
+
// if mergeResults, the head snap is going to be updated on a later phase when snapping with two parents
|
|
663
|
+
// otherwise, update the head of the current lane or main
|
|
813
664
|
if (mergeResults) {
|
|
814
665
|
if (mergeResults.hasConflicts && mergeStrategy === _mergeVersion().MergeOptions.manual) {
|
|
815
666
|
unmergedComponent.unmergedPaths = mergeResults.modifiedFiles.filter(f => f.conflict).map(f => f.filePath);
|
|
816
667
|
}
|
|
817
|
-
|
|
818
668
|
consumer.scope.objects.unmergedComponents.addEntry(unmergedComponent);
|
|
819
669
|
} else if (localLane) {
|
|
820
670
|
if (resolvedUnrelated) {
|
|
821
671
|
// must be "theirs"
|
|
822
672
|
return handleResolveUnrelated();
|
|
823
673
|
}
|
|
824
|
-
|
|
825
674
|
localLane.addComponent({
|
|
826
675
|
id,
|
|
827
676
|
head: remoteHead
|
|
828
677
|
});
|
|
829
678
|
} else {
|
|
830
679
|
// this is main
|
|
831
|
-
modelComponent.setHead(remoteHead);
|
|
832
|
-
|
|
680
|
+
modelComponent.setHead(remoteHead);
|
|
681
|
+
// mark it as local, otherwise, when importing this component from a remote, it'll override it.
|
|
833
682
|
modelComponent.markVersionAsLocal(remoteHead.toString());
|
|
834
683
|
consumer.scope.objects.add(modelComponent);
|
|
835
684
|
}
|
|
836
|
-
|
|
837
685
|
return {
|
|
838
686
|
id,
|
|
839
687
|
filesStatus
|
|
840
688
|
};
|
|
841
689
|
}
|
|
842
|
-
|
|
843
690
|
async abortMerge(values) {
|
|
844
691
|
const consumer = this.workspace.consumer;
|
|
845
692
|
const ids = await this.getIdsForUnmerged(values);
|
|
@@ -853,10 +700,9 @@ class MergingMain {
|
|
|
853
700
|
abortedComponents: results.components
|
|
854
701
|
};
|
|
855
702
|
}
|
|
856
|
-
|
|
857
703
|
async resolveMerge(values, snapMessage, build) {
|
|
858
|
-
const ids = await this.getIdsForUnmerged(values);
|
|
859
|
-
|
|
704
|
+
const ids = await this.getIdsForUnmerged(values);
|
|
705
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
860
706
|
const {
|
|
861
707
|
snappedComponents
|
|
862
708
|
} = await this.snapping.snap({
|
|
@@ -868,16 +714,12 @@ class MergingMain {
|
|
|
868
714
|
resolvedComponents: snappedComponents
|
|
869
715
|
};
|
|
870
716
|
}
|
|
871
|
-
|
|
872
717
|
async getAllComponentsStatus(bitIds, laneId, localLaneObject) {
|
|
873
718
|
const tmp = new (_repositories().Tmp)(this.consumer.scope);
|
|
874
|
-
|
|
875
719
|
try {
|
|
876
720
|
const componentsStatus = await Promise.all(bitIds.map(async bitId => {
|
|
877
721
|
const remoteScopeName = laneId.isDefault() ? bitId.scope : laneId.scope;
|
|
878
|
-
|
|
879
722
|
const remoteLaneId = _laneId().LaneId.from(laneId.name, remoteScopeName);
|
|
880
|
-
|
|
881
723
|
const remoteHead = await this.consumer.scope.objects.remoteLanes.getRef(remoteLaneId, bitId);
|
|
882
724
|
const laneIdStr = remoteLaneId.toString();
|
|
883
725
|
if (!remoteHead) throw new (_bitError().BitError)(`unable to find a remote head of "${bitId.toStringWithoutVersion()}" in "${laneIdStr}"`);
|
|
@@ -890,21 +732,17 @@ class MergingMain {
|
|
|
890
732
|
throw err;
|
|
891
733
|
}
|
|
892
734
|
}
|
|
893
|
-
|
|
894
735
|
async snapResolvedComponents(consumer, snapMessage, build) {
|
|
895
736
|
const unmergedComponents = consumer.scope.objects.unmergedComponents.getComponents();
|
|
896
737
|
this.logger.debug(`merge-snaps, snapResolvedComponents, total ${unmergedComponents.length.toString()} components`);
|
|
897
738
|
if (!unmergedComponents.length) return null;
|
|
898
|
-
|
|
899
739
|
const ids = _bitId().BitIds.fromArray(unmergedComponents.map(r => new (_bitId().BitId)(r.id)));
|
|
900
|
-
|
|
901
740
|
return this.snapping.snap({
|
|
902
741
|
legacyBitIds: ids,
|
|
903
742
|
build,
|
|
904
743
|
message: snapMessage
|
|
905
744
|
});
|
|
906
745
|
}
|
|
907
|
-
|
|
908
746
|
async tagAllLaneComponent(idsToTag, tagMessage, build) {
|
|
909
747
|
const ids = idsToTag.map(id => {
|
|
910
748
|
return id.toStringWithoutVersion();
|
|
@@ -917,48 +755,39 @@ class MergingMain {
|
|
|
917
755
|
unmodified: true
|
|
918
756
|
});
|
|
919
757
|
}
|
|
920
|
-
|
|
921
758
|
async getIdsForUnmerged(idsStr) {
|
|
922
759
|
if (idsStr && idsStr.length) {
|
|
923
760
|
const componentIds = await this.workspace.resolveMultipleComponentIds(idsStr);
|
|
924
761
|
componentIds.forEach(id => {
|
|
925
762
|
const entry = this.workspace.consumer.scope.objects.unmergedComponents.getEntry(id.fullName);
|
|
926
|
-
|
|
927
763
|
if (!entry) {
|
|
928
764
|
throw new (_generalError().default)(`unable to merge-resolve ${id.toString()}, it is not marked as unresolved`);
|
|
929
765
|
}
|
|
930
766
|
});
|
|
931
767
|
return componentIds;
|
|
932
768
|
}
|
|
933
|
-
|
|
934
769
|
const unresolvedComponents = this.workspace.consumer.scope.objects.unmergedComponents.getComponents();
|
|
935
770
|
if (!unresolvedComponents.length) throw new (_generalError().default)(`all components are resolved already, nothing to do`);
|
|
936
771
|
return unresolvedComponents.map(u => _componentId().ComponentID.fromLegacy(new (_bitId().BitId)(u.id)));
|
|
937
772
|
}
|
|
938
|
-
|
|
939
773
|
getComponentsToMerge(consumer, ids) {
|
|
940
774
|
if ((0, _hasWildcard().default)(ids)) {
|
|
941
775
|
const componentsList = new (_componentsList().default)(consumer);
|
|
942
776
|
return componentsList.listComponentsByIdsWithWildcard(ids);
|
|
943
777
|
}
|
|
944
|
-
|
|
945
778
|
return ids.map(id => consumer.getParsedId(id));
|
|
946
779
|
}
|
|
947
|
-
|
|
948
780
|
static async provider([cli, workspace, snapping, checkout, install, loggerMain]) {
|
|
949
781
|
const logger = loggerMain.createLogger(_merging().MergingAspect.id);
|
|
950
782
|
const merging = new MergingMain(workspace, install, snapping, checkout, logger);
|
|
951
783
|
cli.register(new (_mergeCmd().MergeCmd)(merging));
|
|
952
784
|
return merging;
|
|
953
785
|
}
|
|
954
|
-
|
|
955
786
|
}
|
|
956
|
-
|
|
957
787
|
exports.MergingMain = MergingMain;
|
|
958
788
|
(0, _defineProperty2().default)(MergingMain, "slots", []);
|
|
959
789
|
(0, _defineProperty2().default)(MergingMain, "dependencies", [_cli().CLIAspect, _workspace().default, _snapping().default, _checkout().CheckoutAspect, _install().InstallAspect, _logger().LoggerAspect]);
|
|
960
790
|
(0, _defineProperty2().default)(MergingMain, "runtime", _cli().MainRuntime);
|
|
961
|
-
|
|
962
791
|
_merging().MergingAspect.addRuntime(MergingMain);
|
|
963
792
|
|
|
964
793
|
//# sourceMappingURL=merging.main.runtime.js.map
|