public static RefDiff added(Ref ref) { checkNotNull(ref); return new RefDiff(null, ref); }
public static RefDiff removed(Ref ref) { checkNotNull(ref); return new RefDiff(ref, null); }
public static RefDiff removed(Ref ref) { checkNotNull(ref); return new RefDiff(ref, null); }
public static RefDiff added(Ref ref) { checkNotNull(ref); return new RefDiff(null, ref); }
public static RefDiff updated(Ref oldRef, Ref newRef) { checkNotNull(oldRef); checkNotNull(newRef); return new RefDiff(oldRef, newRef); }
public static RefDiff updated(Ref oldRef, Ref newRef) { checkNotNull(oldRef); checkNotNull(newRef); return new RefDiff(oldRef, newRef); }
if (local.isPresent()) { if (!local.get().getObjectId().equals(remoteRef.getObjectId())) { RefDiff changedRef = new RefDiff(local.get(), remoteRef); changedRefs.add(changedRef); } else if (depth.isPresent()) { int commitDepth = graphDatabase().getDepth(local.get().getObjectId()); if (depth.get() > commitDepth) { RefDiff RefDiff = new RefDiff(local.get(), remoteRef); changedRefs.add(RefDiff); RefDiff RefDiff = new RefDiff(null, remoteRef); changedRefs.add(RefDiff);
private void prune(final ImmutableSet<Ref> remoteRemoteRefs, final ImmutableSet<Ref> localRemoteRefs, List<RefDiff> needUpdate) { // Delete local refs that aren't in the remote List<Ref> locals = new ArrayList<Ref>(); // only branches, not tags, appear in the remoteRemoteRefs list so we will not catch // any tags in this check. However, we do not track which remote originally // provided a tag so it makes sense not to prune them anyway. for (Ref remoteRef : remoteRemoteRefs) { Optional<Ref> localRef = findLocal(remoteRef, localRemoteRefs); if (localRef.isPresent()) { locals.add(localRef.get()); } } for (Ref localRef : localRemoteRefs) { if (!(localRef instanceof SymRef) && !locals.contains(localRef)) { // Delete the ref RefDiff RefDiff = new RefDiff(localRef, null); needUpdate.add(RefDiff); command(UpdateRef.class).setDelete(true).setName(localRef.getName()).call(); } } }
private void prune(final ImmutableSet<Ref> remoteRemoteRefs, final ImmutableSet<Ref> localRemoteRefs, List<RefDiff> needUpdate) { // Delete local refs that aren't in the remote List<Ref> locals = new ArrayList<Ref>(); // only branches, not tags, appear in the remoteRemoteRefs list so we will not catch // any tags in this check. However, we do not track which remote originally // provided a tag so it makes sense not to prune them anyway. for (Ref remoteRef : remoteRemoteRefs) { Optional<Ref> localRef = findLocal(remoteRef, localRemoteRefs); if (localRef.isPresent()) { locals.add(localRef.get()); } } for (Ref localRef : localRemoteRefs) { if (!(localRef instanceof SymRef) && !locals.contains(localRef)) { // Delete the ref RefDiff RefDiff = new RefDiff(localRef, null); needUpdate.add(RefDiff); command(UpdateRef.class).setDelete(true).setName(localRef.getName()).call(); } } }
if (local.isPresent()) { if (!local.get().getObjectId().equals(remoteRef.getObjectId())) { RefDiff changedRef = new RefDiff(local.get(), remoteRef); changedRefs.add(changedRef); } else if (depth.isPresent()) { int commitDepth = graphDatabase().getDepth(local.get().getObjectId()); if (depth.get() > commitDepth) { RefDiff RefDiff = new RefDiff(local.get(), remoteRef); changedRefs.add(RefDiff); RefDiff RefDiff = new RefDiff(null, remoteRef); changedRefs.add(RefDiff);
private RefDiff convertToRemote(RefDiff cr) { Ref oldRef = convertToRemote(cr.getOldRef()); Ref newRef = convertToRemote(cr.getNewRef()); return new RefDiff(oldRef, newRef); }
private RefDiff convertToRemote(RefDiff cr) { Ref oldRef = convertToRemote(cr.getOldRef()); Ref newRef = convertToRemote(cr.getNewRef()); return new RefDiff(oldRef, newRef); }
private TransferSummary callInternal(IRemoteRepo remoteRepo) { final Remote remote = this.remote; @Nullable String localRefSpec; @Nullable String remoteRefSpec; boolean force; TransferSummary result = new TransferSummary(); for (TransferableRef ref : this.refsToPush) { localRefSpec = ref.getLocalRef(); remoteRefSpec = ref.getRemoteRef(); force = ref.isForceUpdate(); if (ref.isDelete()) { Optional<Ref> deleted = remoteRepo.deleteRef(remoteRefSpec); if (deleted.isPresent()) { RefDiff deleteResult = RefDiff.added(deleted.get()); result.add(remote.getPushURL(), deleteResult); } } else { Optional<Ref> localRef = refParse(localRefSpec); checkState(localRef.isPresent(), "RefSpec %s does not exist", localRefSpec); Optional<Ref> newRef = push(remoteRepo, remote, localRef.get(), remoteRefSpec); if (newRef.isPresent()) { RefDiff deleteResult = new RefDiff(localRef.get(), newRef.get()); result.add(remote.getPushURL(), deleteResult); } } } return result; }
private TransferSummary callInternal(IRemoteRepo remoteRepo) { final Remote remote = this.remote; @Nullable String localRefSpec; @Nullable String remoteRefSpec; boolean force; TransferSummary sendPackResult = new TransferSummary(); for (TransferableRef ref : this.refsToPush) { localRefSpec = ref.getLocalRef(); remoteRefSpec = ref.getRemoteRef(); force = ref.isForceUpdate(); if (ref.isDelete()) { Optional<Ref> deleted = remoteRepo.deleteRef(remoteRefSpec); if (deleted.isPresent()) { RefDiff deleteResult = RefDiff.added(deleted.get()); sendPackResult.add(remote.getPushURL(), deleteResult); } } else { Optional<Ref> localRef = refParse(localRefSpec); checkState(localRef.isPresent(), "RefSpec %s does not exist", localRefSpec); Optional<Ref> newRef = push(remoteRepo, remote, localRef.get(), remoteRefSpec); if (newRef.isPresent()) { RefDiff deleteResult = new RefDiff(localRef.get(), newRef.get()); sendPackResult.add(remote.getPushURL(), deleteResult); } } } return sendPackResult; }
RefDiff changedRef = new RefDiff(oldRef, newRef);
Ref oldRef = req.have.isPresent() ? new Ref(req.name, req.have.get()) : null; Ref newRef = new Ref(req.name, req.want); RefDiff changedRef = new RefDiff(oldRef, newRef); refs.add(changedRef);
RefDiff changedRef = new RefDiff(oldRef, newRef);
RefDiff updateRemoteRef = new RefDiff(oldRef, remoteRef.get()); results.add(updateRemoteRef);
RefDiff result = new RefDiff(oldRef, remoteRef.get()); results.add(result);
private Iterable<RefDiff> updateLocalRemoteRefs(Remote remote, List<LocalRemoteRef> fetchSpecs, final boolean prune) { List<RefDiff> updatedLocalRemoteRefs = new ArrayList<>(); for (LocalRemoteRef expected : fetchSpecs) { final boolean isNew = expected.isNew; final boolean remoteDeleted = expected.remoteDeleted; final String localName = expected.localRemoteRef.getName(); if (remoteDeleted) { if (prune) { updatedLocalRemoteRefs.add(RefDiff.removed(expected.localRemoteRef)); command(UpdateRef.class).setName(localName) .setOldValue(expected.localRemoteRef.getObjectId()).setDelete(true) .call(); } continue; } RefDiff localRefDiff; Ref oldRef = isNew ? null : expected.localRemoteRef; Ref newRef = new Ref(localName, expected.remoteRef.getObjectId()); command(UpdateRef.class).setName(localName).setNewValue(newRef.getObjectId()).call(); localRefDiff = new RefDiff(oldRef, newRef); updatedLocalRemoteRefs.add(localRefDiff); } return updatedLocalRemoteRefs; }