mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
Convert revision range processing to pipeline model
This commit is contained in:
parent
b856d28904
commit
9b4b6627b6
1 changed files with 26 additions and 16 deletions
|
@ -3070,39 +3070,49 @@ var Tag = Ref.extend({
|
|||
|
||||
function RevisionRange(engine, specifiers) {
|
||||
this.engine = engine;
|
||||
this.included = {};
|
||||
this.excluded = {};
|
||||
this.tipsToInclude = [];
|
||||
this.tipsToExclude = [];
|
||||
this.includedRefs = {};
|
||||
this.excludedRefs = {};
|
||||
this.revisions = [];
|
||||
|
||||
this.processSpecifiers(specifiers);
|
||||
}
|
||||
|
||||
RevisionRange.prototype.isExclusion = function(specifier) {
|
||||
return specifier.startsWith('^');
|
||||
RevisionRange.prototype.processAsExclusion = function(specifier) {
|
||||
if(!specifier.startsWith('^')) {
|
||||
return false;
|
||||
}
|
||||
this.tipsToExclude.push(specifier.slice(1));
|
||||
return true;
|
||||
};
|
||||
|
||||
RevisionRange.prototype.processAsInclusion = function(specifier) {
|
||||
this.tipsToInclude.push(specifier);
|
||||
return true;
|
||||
};
|
||||
|
||||
RevisionRange.prototype.processSpecifiers = function(specifiers) {
|
||||
var self = this;
|
||||
var inclusions = [];
|
||||
var exclusions = [];
|
||||
var processors = [
|
||||
this.processAsExclusion
|
||||
];
|
||||
|
||||
specifiers.forEach(function(specifier) {
|
||||
if(self.isExclusion(specifier)) {
|
||||
exclusions.push(specifier.slice(1));
|
||||
} else {
|
||||
inclusions.push(specifier);
|
||||
if(!processors.some(function(processor) { return processor.bind(self)(specifier); })) {
|
||||
self.processAsInclusion(specifier);
|
||||
}
|
||||
});
|
||||
|
||||
exclusions.forEach(function(exclusion) {
|
||||
this.tipsToExclude.forEach(function(exclusion) {
|
||||
self.addExcluded(Graph.getUpstreamSet(self.engine, exclusion));
|
||||
});
|
||||
|
||||
inclusions.forEach(function(inclusion) {
|
||||
this.tipsToInclude.forEach(function(inclusion) {
|
||||
self.addIncluded(Graph.getUpstreamSet(self.engine, inclusion));
|
||||
});
|
||||
|
||||
var includedKeys = Array.from(Object.keys(self.included));
|
||||
var includedKeys = Array.from(Object.keys(self.includedRefs));
|
||||
|
||||
self.revisions = includedKeys.map(function(revision) {
|
||||
return self.engine.resolveStringRef(revision);
|
||||
|
@ -3112,14 +3122,14 @@ RevisionRange.prototype.processSpecifiers = function(specifiers) {
|
|||
};
|
||||
|
||||
RevisionRange.prototype.isExcluded = function(revision) {
|
||||
return this.excluded.hasOwnProperty(revision);
|
||||
return this.excludedRefs.hasOwnProperty(revision);
|
||||
};
|
||||
|
||||
RevisionRange.prototype.addExcluded = function(setToExclude) {
|
||||
var self = this;
|
||||
Object.keys(setToExclude).forEach(function(toExclude) {
|
||||
if(!self.isExcluded(toExclude)) {
|
||||
self.excluded[toExclude] = true;
|
||||
self.excludedRefs[toExclude] = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -3128,7 +3138,7 @@ RevisionRange.prototype.addIncluded = function(setToInclude) {
|
|||
var self = this;
|
||||
Object.keys(setToInclude).forEach(function(toInclude) {
|
||||
if(!self.isExcluded(toInclude)) {
|
||||
self.included[toInclude] = true;
|
||||
self.includedRefs[toInclude] = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue