public static ArrayMemory valueOf(ReflogEntry value) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("newId").assign(valueOf(value.getNewId())); memory.refOfIndex("oldId").assign(valueOf(value.getOldId())); memory.refOfIndex("who").assign(value.getWho() == null ? Memory.NULL : valueOf(value.getWho())); memory.refOfIndex("comment").assign(value.getComment()); return memory; }
@Nullable private String resolveReflogCheckout(int checkoutNo) throws IOException { ReflogReader reader = getReflogReader(Constants.HEAD); if (reader == null) { return null; } List<ReflogEntry> reflogEntries = reader.getReverseEntries(); for (ReflogEntry entry : reflogEntries) { CheckoutEntry checkout = entry.parseCheckout(); if (checkout != null) if (checkoutNo-- == 1) return checkout.getFromBranch(); } return null; }
/** * @param ref * the ref which log should be inspected * @param minTime only reflog entries not older then this time are processed * @return the {@link ObjectId}s contained in the reflog * @throws IOException */ private Set<ObjectId> listRefLogObjects(Ref ref, long minTime) throws IOException { ReflogReader reflogReader = repo.getReflogReader(ref.getName()); if (reflogReader == null) { return Collections.emptySet(); } List<ReflogEntry> rlEntries = reflogReader .getReverseEntries(); if (rlEntries == null || rlEntries.isEmpty()) return Collections.emptySet(); Set<ObjectId> ret = new HashSet<>(); for (ReflogEntry e : rlEntries) { if (e.getWho().getWhen().getTime() < minTime) break; ObjectId newId = e.getNewId(); if (newId != null && !ObjectId.zeroId().equals(newId)) ret.add(newId); ObjectId oldId = e.getOldId(); if (oldId != null && !ObjectId.zeroId().equals(oldId)) ret.add(oldId); } return ret; }
for (int i = entries.size() - 1; i >= 0; i--) { ReflogEntry entry = entries.get(i); writer.log(stashLockRef, entryId, entry.getNewId(), entry.getWho(), entry.getComment()); entryId = entry.getNewId();
CheckoutEntryImpl(ReflogEntry reflogEntry) { String comment = reflogEntry.getComment(); int p1 = CHECKOUT_MOVING_FROM.length(); int p2 = comment.indexOf(" to ", p1); //$NON-NLS-1$ int p3 = comment.length(); from = comment.substring(p1,p2); to = comment.substring(p2 + " to ".length(), p3); //$NON-NLS-1$ }
private String toString(ReflogEntry entry, int i) { final StringBuilder s = new StringBuilder(); s.append(entry.getNewId().abbreviate(7).name()); s.append(" "); //$NON-NLS-1$ s.append(ref == null ? Constants.HEAD : Repository.shortenRefName(ref)); s.append("@{" + i + "}:"); //$NON-NLS-1$ //$NON-NLS-2$ s.append(" "); //$NON-NLS-1$ s.append(entry.getComment()); return s.toString(); } }
private void handleOpen(ISelection selection, boolean activateOnOpen) { if (selection instanceof IStructuredSelection) if (selection.isEmpty()) return; Repository repo = getRepository(); if (repo == null) return; RevWalk walk = new RevWalk(repo); try { for (Object element : ((IStructuredSelection)selection).toArray()) { ReflogEntry entry = (ReflogEntry) element; ObjectId id = entry.getNewId(); if (id == null || id.equals(ObjectId.zeroId())) id = entry.getOldId(); if (id != null && !id.equals(ObjectId.zeroId())) CommitEditor.openQuiet(new RepositoryCommit(repo, walk.parseCommit(id)), activateOnOpen); } } catch (IOException e) { Activator.logError(UIText.ReflogView_ErrorOnOpenCommit, e); } finally { walk.release(); } } };
@Override public String getText(Object element) { final ReflogEntry entry = (ReflogEntry) element; final PersonIdent who = entry.getWho(); // TODO add option to use RelativeDateFormatter return absoluteFormatter.format(who.getWhen()); }
for (int i = entries.size() - 1; i >= 0; i--) { ReflogEntry entry = entries.get(i); writer.log(stashLockRef, entryId, entry.getNewId(), entry.getWho(), entry.getComment()); entryId = entry.getNewId();
/** * @param ref * the ref which log should be inspected * @param minTime only reflog entries not older then this time are processed * @return the {@link ObjectId}s contained in the reflog * @throws IOException */ private Set<ObjectId> listRefLogObjects(Ref ref, long minTime) throws IOException { ReflogReader reflogReader = repo.getReflogReader(ref.getName()); if (reflogReader == null) { return Collections.emptySet(); } List<ReflogEntry> rlEntries = reflogReader .getReverseEntries(); if (rlEntries == null || rlEntries.isEmpty()) return Collections.emptySet(); Set<ObjectId> ret = new HashSet<>(); for (ReflogEntry e : rlEntries) { if (e.getWho().getWhen().getTime() < minTime) break; ObjectId newId = e.getNewId(); if (newId != null && !ObjectId.zeroId().equals(newId)) ret.add(newId); ObjectId oldId = e.getOldId(); if (oldId != null && !ObjectId.zeroId().equals(oldId)) ret.add(oldId); } return ret; }
private RevCommit resolveReflog(RevWalk rw, Ref ref, String time) throws IOException { int number; try { number = Integer.parseInt(time); } catch (NumberFormatException nfe) { throw new RevisionSyntaxException(MessageFormat.format( JGitText.get().invalidReflogRevision, time)); } assert number >= 0; ReflogReader reader = getReflogReader(ref.getName()); if (reader == null) { throw new RevisionSyntaxException( MessageFormat.format(JGitText.get().reflogEntryNotFound, Integer.valueOf(number), ref.getName())); } ReflogEntry entry = reader.getReverseEntry(number); if (entry == null) throw new RevisionSyntaxException(MessageFormat.format( JGitText.get().reflogEntryNotFound, Integer.valueOf(number), ref.getName())); return rw.parseCommit(entry.getNewId()); }
@Override public String getText(Object element) { final ReflogEntry entry = (ReflogEntry) element; return entry.getComment(); }
public static ZonedDateTime getTime(ReflogEntry entry) { final PersonIdent who = entry.getWho(); return ZonedDateTime.ofInstant(who.getWhen().toInstant(), who.getTimeZone().toZoneId()); }
/** * Write the given entry to the ref's log. * * @param refName * a {@link java.lang.String} object. * @param entry * a {@link org.eclipse.jgit.lib.ReflogEntry} object. * @return this writer * @throws java.io.IOException */ public ReflogWriter log(String refName, ReflogEntry entry) throws IOException { return log(refName, entry.getOldId(), entry.getNewId(), entry.getWho(), entry.getComment()); }
for (int i = entries.size() - 1; i >= 0; i--) { ReflogEntry entry = entries.get(i); writer.log(stashLockRef, entryId, entry.getNewId(), entry.getWho(), entry.getComment()); entryId = entry.getNewId();
/** * @param ref * the ref which log should be inspected * @param minTime only reflog entries not older then this time are processed * @return the {@link ObjectId}s contained in the reflog * @throws IOException */ private Set<ObjectId> listRefLogObjects(Ref ref, long minTime) throws IOException { ReflogReader reflogReader = repo.getReflogReader(ref.getName()); if (reflogReader == null) { return Collections.emptySet(); } List<ReflogEntry> rlEntries = reflogReader .getReverseEntries(); if (rlEntries == null || rlEntries.isEmpty()) return Collections.<ObjectId> emptySet(); Set<ObjectId> ret = new HashSet<ObjectId>(); for (ReflogEntry e : rlEntries) { if (e.getWho().getWhen().getTime() < minTime) break; ObjectId newId = e.getNewId(); if (newId != null && !ObjectId.zeroId().equals(newId)) ret.add(newId); ObjectId oldId = e.getOldId(); if (oldId != null && !ObjectId.zeroId().equals(oldId)) ret.add(oldId); } return ret; }
@Override public String getToolTipText(Object element) { final ReflogEntry entry = (ReflogEntry) element; return entry.getNewId().name(); }
CheckoutEntryImpl(ReflogEntry reflogEntry) { String comment = reflogEntry.getComment(); int p1 = CHECKOUT_MOVING_FROM.length(); int p2 = comment.indexOf(" to ", p1); //$NON-NLS-1$ int p3 = comment.length(); from = comment.substring(p1,p2); to = comment.substring(p2 + " to ".length(), p3); //$NON-NLS-1$ }
@Nullable private String resolveReflogCheckout(int checkoutNo) throws IOException { ReflogReader reader = getReflogReader(Constants.HEAD); if (reader == null) { return null; } List<ReflogEntry> reflogEntries = reader.getReverseEntries(); for (ReflogEntry entry : reflogEntries) { CheckoutEntry checkout = entry.parseCheckout(); if (checkout != null) if (checkoutNo-- == 1) return checkout.getFromBranch(); } return null; }