private void addUpdatedFiles( VirtualFile repo, UpdatedFiles updatedFiles, HgRevisionNumber parentBeforeUpdate, HgRevisionNumber parentAfterUpdate) { if (parentAfterUpdate == null || parentBeforeUpdate == null) { return; } if (parentAfterUpdate.equals( parentBeforeUpdate)) { // nothing to update => returning not to capture local uncommitted // changes return; } HgStatusCommand statusCommand = new HgStatusCommand.Builder(true) .ignored(false) .unknown(false) .baseRevision(parentBeforeUpdate) .targetRevision(parentAfterUpdate) .build(project); Set<HgChange> changes = statusCommand.execute(repo); for (HgChange change : changes) { HgFileStatusEnum status = change.getStatus(); switch (status) { case ADDED: addToGroup(updatedFiles, change, FileGroup.CREATED_ID); break; case MODIFIED: addToGroup(updatedFiles, change, FileGroup.UPDATED_ID); break; case DELETED: addToGroup(updatedFiles, change, FileGroup.REMOVED_FROM_REPOSITORY_ID); break; case COPY: addToGroup(updatedFiles, change, FileGroup.CHANGED_ON_SERVER_ID); break; default: // do nothing break; } } }
private static void addToGroup(UpdatedFiles updatedFiles, HgChange change, String id) { updatedFiles .getGroupById(id) .add(change.afterFile().getFile().getAbsolutePath(), HgVcs.VCS_NAME, null); }