本文介绍了如何确定工作项变更集文件项是新添加还是修改的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些变更集对象,我需要确定变更集中的文件是否是新添加或修改的.以下是我用来获取更改集的代码:

I have some change set objects and I need to find out if the file in the change set is newly added or modified. below is the code I am using to fetch the change set:

    IChangeSetHandle changeSets = convertToChangeSetHandles(extracted);

                        changeSet = (IChangeSet) repoApac.itemManager().fetchCompleteItem(changeSets,
                                    IItemManager.DEFAULT, monitor);

public static List<IFileItem> changeSetFileName(IChangeSet changeSet) throws TeamRepositoryException{
        IVersionableManager vm = SCMPlatform.getWorkspaceManager(repoApac).versionableManager(); 
        List changes = changeSet.changes(); 
        List<IFileItem> changeSetFileNames = new ArrayList<>();
        for(int i=0;i<changes.size();i++) { 
            Change change = (Change) changes.get(i); 
            IVersionableHandle after = change.afterState();
            if( after != null && after instanceof IFileItemHandle) { 
                IFileItem fileItem = (IFileItem) vm.fetchCompleteState(after, null); 
                changeSetFileNames.add(fileItem);
            } 
        } 
        return changeSetFileNames;
    }

        if(changeSet.isNewItem()){
                return "ADDED"; 
            }else{
                return "MODIFIED";
            }

推荐答案

这是工作代码:

for (IChange change : (List<IChange>) changeSet.changes()) {
                if (change.kind() == IChange.MODIFY) {
                    return "MODIFIED";
                }
                if (change.kind() == IChange.ADD) {
                    return "ADDED";
                }
            }

这篇关于如何确定工作项变更集文件项是新添加还是修改的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 11:08