1 | "use strict";
|
2 | var DagGraph_1 = require("../DagGraph");
|
3 | var nextId_1 = require("../nextId");
|
4 | var log = require('debug')('redux-dag-history:DagHistory');
|
5 | function createBranch(branchName, history) {
|
6 | log('creating branch %s', branchName);
|
7 | var graph = history.graph, current = history.current;
|
8 | var reader = new DagGraph_1.default(graph);
|
9 | return {
|
10 | current: current,
|
11 | graph: graph.withMutations(function (g) {
|
12 | var reader = new DagGraph_1.default(graph);
|
13 | var lastBranchId = reader.lastBranchId;
|
14 | var newBranchId = nextId_1.default(lastBranchId);
|
15 | return reader
|
16 | .setCurrentBranch(newBranchId)
|
17 | .setLastBranchId(newBranchId)
|
18 | .setBranchName(newBranchId, branchName)
|
19 | .setCommitted(newBranchId, reader.currentStateId)
|
20 | .setFirst(newBranchId, reader.currentStateId)
|
21 | .setLatest(newBranchId, reader.currentStateId);
|
22 | }),
|
23 | };
|
24 | }
|
25 | Object.defineProperty(exports, "__esModule", { value: true });
|
26 | exports.default = createBranch;
|