Mercurial > hg > mercurial
diff mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java @ 838:7e461ea697f1
Faster working dir revision calculation
We used to use 'hg identity' to get a working dir revision. It
shows the revision but also adds a '+' sign if some files were
changed. For repository with a size of R# it takes around 5
minutes to understand that all files are unmodified and '+' sign
is not needed. To update sources we don't use this information at
all. Switch to 'hg parents' which takes around a second because it
doesn't check if files were modified.
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Mon, 02 Jun 2014 16:20:41 +0200 |
parents | 80ae3dc66685 |
children | 3a418ac5ada1 |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java Mon Jun 02 14:23:40 2014 +0200 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java Mon Jun 02 16:20:41 2014 +0200 @@ -24,7 +24,10 @@ import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static java.util.Arrays.asList; import static java.util.Collections.emptyList; @@ -188,8 +191,13 @@ return files; } + @NotNull public String getWorkingDirRevision() throws VcsException { - return id().inLocalRepository().call(); + List<String> workingDirParents = parents().call(); + if (workingDirParents.isEmpty()) + return LogCommand.ZERO_PARENT_SHORT_ID;//'hg id' shows zeroid when a working dir has no parents + //if a working dir is in an uncommitted merge state, choose the first parent + return workingDirParents.get(0); } public boolean containsRevision(@NotNull String revision) {