private void MarkReachable(IEnumerable <ObjectId> have, int maxTime) { foreach (Ref r in local.getAllRefs().Values) { try { RevCommit o = _walk.parseCommit(r.ObjectId); o.add(REACHABLE); _reachableCommits.add(o); } catch (IOException) { // If we cannot read the value of the ref skip it. } } foreach (ObjectId id in have) { try { RevCommit o = _walk.parseCommit(id); o.add(REACHABLE); _reachableCommits.add(o); } catch (IOException) { // If we cannot read the value of the ref skip it. } } if (maxTime > 0) { // Mark reachable commits until we reach maxTime. These may // wind up later matching up against things we want and we // can avoid asking for something we already happen to have. // DateTime maxWhen = (maxTime * 1000L).MillisToUtcDateTime(); _walk.sort(RevSort.COMMIT_TIME_DESC); _walk.markStart(_reachableCommits); _walk.setRevFilter(CommitTimeRevFilter.After(maxWhen)); for (; ;) { RevCommit c = _walk.next(); if (c == null) { break; } if (c.has(ADVERTISED) && !c.has(COMMON)) { c.add(COMMON); c.carry(COMMON); _reachableCommits.add(c); } } } }
private void MarkReachable(IEnumerable <ObjectId> have, int maxTime) { foreach (Ref r in local.getAllRefs().Values) { try { RevCommit o = _walk.parseCommit(r.ObjectId); o.add(REACHABLE); _reachableCommits.add(o); } catch (IOException) { } } foreach (ObjectId id in have) { try { RevCommit o = _walk.parseCommit(id); o.add(REACHABLE); _reachableCommits.add(o); } catch (IOException) { } } if (maxTime > 0) { DateTime maxWhen = new DateTime(1970, 1, 1) + TimeSpan.FromSeconds(maxTime); _walk.sort(RevSort.COMMIT_TIME_DESC); _walk.markStart(_reachableCommits); _walk.setRevFilter(CommitTimeRevFilter.After(maxWhen)); for (; ;) { RevCommit c = _walk.next(); if (c == null) { break; } if (c.has(ADVERTISED) && !c.has(COMMON)) { c.add(COMMON); c.carry(COMMON); _reachableCommits.add(c); } } } }
/// <summary> /// Merge together two or more tree-ish objects. /// <para /> /// Any tree-ish may be supplied as inputs. Commits and/or tags pointing at /// trees or commits may be passed as input objects. /// </summary> /// <param name="tips"> /// source trees to be combined together. The merge base is not /// included in this set. </param> /// <returns> /// True if the merge was completed without conflicts; false if the /// merge strategy cannot handle this merge or there were conflicts /// preventing it from automatically resolving all paths. /// </returns> /// <exception cref="IncorrectObjectTypeException"> /// one of the input objects is not a commit, but the strategy /// requires it to be a commit. /// </exception> /// <exception cref="IOException"> /// one or more sources could not be read, or outputs could not /// be written to the Repository. /// </exception> public virtual bool Merge(AnyObjectId[] tips) { _sourceObjects = new RevObject[tips.Length]; for (int i = 0; i < tips.Length; i++) { _sourceObjects[i] = _walk.parseAny(tips[i]); } _sourceCommits = new RevCommit[_sourceObjects.Length]; for (int i = 0; i < _sourceObjects.Length; i++) { try { _sourceCommits[i] = _walk.parseCommit(_sourceObjects[i]); } catch (IncorrectObjectTypeException) { _sourceCommits[i] = null; } } SourceTrees = new RevTree[_sourceObjects.Length]; for (int i = 0; i < _sourceObjects.Length; i++) { SourceTrees[i] = _walk.parseTree(_sourceObjects[i]); } return(MergeImpl()); }
private void verifyPrerequisites() { if (prereqs.isEmpty()) return; using(RevWalk.RevWalk rw = new RevWalk.RevWalk(transport.Local)) { RevFlag PREREQ = rw.newFlag("PREREQ"); RevFlag SEEN = rw.newFlag("SEEN"); List<ObjectId> missing = new List<ObjectId>(); List<RevObject> commits = new List<RevObject>(); foreach (ObjectId p in prereqs) { try { RevCommit c = rw.parseCommit(p); if (!c.has(PREREQ)) { c.add(PREREQ); commits.Add(c); } } catch (MissingObjectException) { missing.Add(p); } catch (IOException err) { throw new TransportException(transport.Uri, "Cannot Read commit " + p.Name, err); } } if (!missing.isEmpty()) throw new MissingBundlePrerequisiteException(transport.Uri, missing); foreach (Ref r in transport.Local.getAllRefs().Values) { try { rw.markStart(rw.parseCommit(r.ObjectId)); } catch (IOException) { } } int remaining = commits.Count; try { RevCommit c; while ((c = rw.next()) != null) { if (c.has(PREREQ)) { c.add(SEEN); if (--remaining == 0) break; } } } catch (IOException err) { throw new TransportException(transport.Uri, "Cannot Read object", err); } if (remaining > 0) { foreach (RevObject o in commits) { if (!o.has(SEEN)) missing.Add(o); } throw new MissingBundlePrerequisiteException(transport.Uri, missing); } } }
private void verifyPrerequisites() { if (_prereqs.isEmpty()) return; using (var rw = new RevWalk.RevWalk(_transport.Local)) { RevFlag PREREQ = rw.newFlag("PREREQ"); RevFlag SEEN = rw.newFlag("SEEN"); IDictionary<ObjectId, string> missing = new Dictionary<ObjectId, string>(); var commits = new List<RevObject>(); foreach (KeyValuePair<ObjectId, string> e in _prereqs) { ObjectId p = e.Key; try { RevCommit c = rw.parseCommit(p); if (!c.has(PREREQ)) { c.add(PREREQ); commits.Add(c); } } catch (MissingObjectException) { missing.put(p, e.Value); } catch (IOException err) { throw new TransportException(_transport.Uri, "Cannot Read commit " + p.Name, err); } } if (!missing.isEmpty()) throw new MissingBundlePrerequisiteException(_transport.Uri, missing); foreach (Ref r in _transport.Local.getAllRefs().Values) { try { rw.markStart(rw.parseCommit(r.ObjectId)); } catch (IOException) { // If we cannot read the value of the ref skip it. } } int remaining = commits.Count; try { RevCommit c; while ((c = rw.next()) != null) { if (c.has(PREREQ)) { c.add(SEEN); if (--remaining == 0) break; } } } catch (IOException err) { throw new TransportException(_transport.Uri, "Cannot Read object", err); } if (remaining > 0) { foreach (RevObject o in commits) { if (!o.has(SEEN)) missing.put(o, _prereqs.get(o)); } throw new MissingBundlePrerequisiteException(_transport.Uri, missing); } } }
private void verifyPrerequisites() { if (_prereqs.isEmpty()) { return; } using (var rw = new RevWalk.RevWalk(_transport.Local)) { RevFlag PREREQ = rw.newFlag("PREREQ"); RevFlag SEEN = rw.newFlag("SEEN"); IDictionary <ObjectId, string> missing = new Dictionary <ObjectId, string>(); var commits = new List <RevObject>(); foreach (KeyValuePair <ObjectId, string> e in _prereqs) { ObjectId p = e.Key; try { RevCommit c = rw.parseCommit(p); if (!c.has(PREREQ)) { c.add(PREREQ); commits.Add(c); } } catch (MissingObjectException) { missing.put(p, e.Value); } catch (IOException err) { throw new TransportException(_transport.Uri, "Cannot Read commit " + p.Name, err); } } if (!missing.isEmpty()) { throw new MissingBundlePrerequisiteException(_transport.Uri, missing); } foreach (Ref r in _transport.Local.getAllRefs().Values) { try { rw.markStart(rw.parseCommit(r.ObjectId)); } catch (IOException) { // If we cannot read the value of the ref skip it. } } int remaining = commits.Count; try { RevCommit c; while ((c = rw.next()) != null) { if (c.has(PREREQ)) { c.add(SEEN); if (--remaining == 0) { break; } } } } catch (IOException err) { throw new TransportException(_transport.Uri, "Cannot Read object", err); } if (remaining > 0) { foreach (RevObject o in commits) { if (!o.has(SEEN)) { missing.put(o, _prereqs.get(o)); } } throw new MissingBundlePrerequisiteException(_transport.Uri, missing); } } }
private void verifyPrerequisites() { if (prereqs.isEmpty()) { return; } using (RevWalk.RevWalk rw = new RevWalk.RevWalk(transport.Local)) { RevFlag PREREQ = rw.newFlag("PREREQ"); RevFlag SEEN = rw.newFlag("SEEN"); List <ObjectId> missing = new List <ObjectId>(); List <RevObject> commits = new List <RevObject>(); foreach (ObjectId p in prereqs) { try { RevCommit c = rw.parseCommit(p); if (!c.has(PREREQ)) { c.add(PREREQ); commits.Add(c); } } catch (MissingObjectException) { missing.Add(p); } catch (IOException err) { throw new TransportException(transport.Uri, "Cannot Read commit " + p.Name, err); } } if (!missing.isEmpty()) { throw new MissingBundlePrerequisiteException(transport.Uri, missing); } foreach (Ref r in transport.Local.getAllRefs().Values) { try { rw.markStart(rw.parseCommit(r.ObjectId)); } catch (IOException) { } } int remaining = commits.Count; try { RevCommit c; while ((c = rw.next()) != null) { if (c.has(PREREQ)) { c.add(SEEN); if (--remaining == 0) { break; } } } } catch (IOException err) { throw new TransportException(transport.Uri, "Cannot Read object", err); } if (remaining > 0) { foreach (RevObject o in commits) { if (!o.has(SEEN)) { missing.Add(o); } } throw new MissingBundlePrerequisiteException(transport.Uri, missing); } } }