public class VcsFileUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
FILE_PATH_LIMIT
If multiple paths are specified on the command line, this limit is used to split paths into chunks.
|
Constructor and Description |
---|
VcsFileUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addFilesToVcsWithConfirmation(Project project,
java.util.Collection<? extends VirtualFile> virtualFiles)
Finds all VCSs related to the passed files, suggests user to add files to the respected VCSs honoring addition and silence settings
and adds them if user or settings confirmed addition.
|
static void |
addFilesToVcsWithConfirmation(Project project,
VirtualFile... virtualFiles) |
static java.util.List<java.util.List<java.lang.String>> |
chunkArguments(java.util.List<java.lang.String> arguments)
Chunk arguments on the command line
|
static java.util.List<java.util.List<java.lang.String>> |
chunkArguments(java.util.List<java.lang.String> arguments,
int groupSize)
Chunk arguments on the command line
|
static java.util.List<java.util.List<java.lang.String>> |
chunkFiles(VirtualFile root,
java.util.Collection<? extends VirtualFile> files)
The chunk paths
|
static java.util.List<java.util.List<java.lang.String>> |
chunkPaths(VirtualFile root,
java.util.Collection<? extends FilePath> files)
The chunk paths
|
static void |
foreachChunk(java.util.List<java.lang.String> arguments,
int groupSize,
ThrowableConsumer<? super java.util.List<java.lang.String>,? extends VcsException> consumer)
Execute function for each chunk of arguments.
|
static <T> java.util.List<T> |
foreachChunk(java.util.List<java.lang.String> arguments,
int groupSize,
ThrowableNotNullFunction<? super java.util.List<java.lang.String>,? extends java.util.List<? extends T>,? extends VcsException> processor)
Execute function for each chunk of arguments and collect the result.
|
static java.lang.String |
getRelativeFilePath(java.lang.String file,
VirtualFile baseDir) |
static java.lang.String |
getRelativeFilePath(VirtualFile file,
VirtualFile baseDir) |
static boolean |
isAncestor(FilePath ancestor,
FilePath path,
boolean strict) |
static boolean |
isAncestor(@SystemIndependent java.lang.String ancestor,
@SystemIndependent java.lang.String path,
boolean strict) |
static boolean |
isAncestor(VirtualFile root,
FilePath path) |
static boolean |
isOctal(char ch)
Check if character is octal digit
|
static void |
markFilesDirty(Project project,
java.util.Collection<? extends VirtualFile> affectedFiles) |
static void |
markFilesDirty(Project project,
java.util.List<? extends FilePath> affectedFiles) |
static java.lang.String |
relativeOrFullPath(VirtualFile root,
VirtualFile file)
Get relative path
|
static java.lang.String |
relativePath(java.io.File root,
java.io.File path)
Get relative path
|
static java.lang.String |
relativePath(java.io.File root,
FilePath path)
Get relative path
|
static java.lang.String |
relativePath(FilePath root,
FilePath file)
Get relative path
|
static java.lang.String |
relativePath(java.io.File root,
VirtualFile file)
Get relative path
|
static java.lang.String |
relativePath(VirtualFile root,
FilePath path)
Get relative path
|
static java.lang.String |
relativePath(VirtualFile root,
VirtualFile file)
Get relative path
|
static java.util.List<java.lang.String> |
toRelativeFiles(VirtualFile root,
java.util.Collection<? extends VirtualFile> files)
Covert list of files to relative paths
|
static java.util.List<java.lang.String> |
toRelativePaths(VirtualFile root,
java.util.Collection<? extends FilePath> filePaths)
Covert list of files to relative paths
|
static java.lang.String |
unescapeGitPath(java.lang.String path) |
static java.lang.String |
unescapeGitPath(java.lang.String path,
java.lang.String encoding)
Unescape path returned by Git.
|
public static final int FILE_PATH_LIMIT
public static <T> java.util.List<T> foreachChunk(java.util.List<java.lang.String> arguments, int groupSize, ThrowableNotNullFunction<? super java.util.List<java.lang.String>,? extends java.util.List<? extends T>,? extends VcsException> processor) throws VcsException
T
- type of result valuearguments
- the arguments to chunkgroupSize
- size of argument groups that should be put in the same chunk (like a name and a value)processor
- function to execute on each chunkVcsException
public static void foreachChunk(java.util.List<java.lang.String> arguments, int groupSize, ThrowableConsumer<? super java.util.List<java.lang.String>,? extends VcsException> consumer) throws VcsException
arguments
- the arguments to chunkgroupSize
- size of argument groups that should be put in the same chunk (like a name and a value)consumer
- consumer to feed each chunkVcsException
public static java.util.List<java.util.List<java.lang.String>> chunkArguments(java.util.List<java.lang.String> arguments)
arguments
- the arguments to chunkpublic static java.util.List<java.util.List<java.lang.String>> chunkArguments(java.util.List<java.lang.String> arguments, int groupSize)
arguments
- the arguments to chunk, number of arguments should be divisible by groupSizegroupSize
- size of argument groups that should be put in the same chunkpublic static java.util.List<java.util.List<java.lang.String>> chunkPaths(VirtualFile root, java.util.Collection<? extends FilePath> files)
root
- the vcs rootfiles
- the file listpublic static java.util.List<java.util.List<java.lang.String>> chunkFiles(VirtualFile root, java.util.Collection<? extends VirtualFile> files)
root
- the vcs rootfiles
- the file listpublic static java.lang.String getRelativeFilePath(VirtualFile file, VirtualFile baseDir)
public static java.lang.String getRelativeFilePath(java.lang.String file, VirtualFile baseDir)
public static boolean isOctal(char ch)
ch
- a character to testpublic static java.lang.String relativePath(VirtualFile root, FilePath path)
root
- a root pathpath
- a path to file (possibly deleted file)java.lang.IllegalArgumentException
- if path is not under root.public static java.lang.String relativePath(java.io.File root, FilePath path)
root
- a root pathpath
- a path to file (possibly deleted file)java.lang.IllegalArgumentException
- if path is not under root.public static java.lang.String relativePath(java.io.File root, VirtualFile file)
root
- a root pathfile
- a virtual filejava.lang.IllegalArgumentException
- if path is not under root.public static java.lang.String relativePath(VirtualFile root, VirtualFile file)
root
- a root filefile
- a virtual filejava.lang.IllegalArgumentException
- if path is not under root.public static java.lang.String relativeOrFullPath(VirtualFile root, VirtualFile file)
root
- a root filefile
- a virtual filejava.lang.IllegalArgumentException
- if path is not under root.public static java.lang.String relativePath(FilePath root, FilePath file)
root
- a root pathfile
- a target pathjava.lang.IllegalArgumentException
- if path is not under root.public static java.lang.String relativePath(java.io.File root, java.io.File path)
root
- a root pathpath
- a path to file (possibly deleted file)java.lang.IllegalArgumentException
- if path is not under root.public static java.util.List<java.lang.String> toRelativePaths(VirtualFile root, java.util.Collection<? extends FilePath> filePaths)
root
- a vcs rootfilePaths
- a parameters to convertjava.lang.IllegalArgumentException
- if some path is not under root.public static java.util.List<java.lang.String> toRelativeFiles(VirtualFile root, java.util.Collection<? extends VirtualFile> files)
root
- a vcs rootfiles
- a parameters to convertjava.lang.IllegalArgumentException
- if some path is not under root.public static void markFilesDirty(Project project, java.util.Collection<? extends VirtualFile> affectedFiles)
public static void markFilesDirty(Project project, java.util.List<? extends FilePath> affectedFiles)
public static void addFilesToVcsWithConfirmation(Project project, VirtualFile... virtualFiles)
public static void addFilesToVcsWithConfirmation(Project project, java.util.Collection<? extends VirtualFile> virtualFiles)
project
- project we work invirtualFiles
- collection of virtual files to add; directories being added recursivelypublic static boolean isAncestor(@SystemIndependent java.lang.String ancestor, @SystemIndependent java.lang.String path, boolean strict)
public static boolean isAncestor(VirtualFile root, FilePath path)
public static java.lang.String unescapeGitPath(java.lang.String path, java.lang.String encoding) throws java.lang.IllegalArgumentException
Unescape path returned by Git.
If there are quotes in the file name, Git not only escapes them, but also encloses the file name into quotes:
"\"quote"
If there are spaces in the file name, Git displays the name as is, without escaping spaces and without enclosing name in quotes.
path
- a path to unescapeencoding
- to use while converting char octetsjava.lang.IllegalArgumentException
- if the path is invalidpublic static java.lang.String unescapeGitPath(java.lang.String path)