code: private HistoryEntry processIndex(List<HistoryEntry> history) {
      log.debug("I received entry: "+index);
      HistoryEntry selectedEntry = null;
      if(index != null && index > 0) {
        for(HistoryEntry entry : history) {
          if(entry.getIndex() == index) {
            if(!entry.isRevertible()) {
              System.err.println("Selected index ["+index+"] is not revertible.");
              index = null;
            } else {
              selectedEntry = entry;
            }
            break;
          }
        }
        if(index == null) {
          selectedEntry = null;
        } else if(selectedEntry == null) {
          System.err.println("Invalid entry!");
          index = null;
        }
      } else if(index != null && index < 0) {
        for(HistoryEntry entry : history) {
          if(entry.isRevertible()) {
            if(index++ == 0) {
              selectedEntry = entry;
              index = entry.getIndex();
              break;
            }
          }
        }
        if(selectedEntry == null) {
          System.err.println("Invalid entry!");
          index = null;
        }
      } else {
        index = null;
        System.err.println("Invalid entry!");
      }
      return selectedEntry;
    }
docs: Prompts for and returns a selected history entry or if the <code>-n</code> option is passed that history entry is returned.
  
  @param history
  @return