Skip to content

Commit

Permalink
hg: suppress add output
Browse files Browse the repository at this point in the history
This approach asks mercurial about files before adding.
i.e. ask permission.
  • Loading branch information
jsoref committed Jan 20, 2017
1 parent ab6d33e commit 514e6a6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/scala/Vcs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ object Mercurial extends VcsCompanion {
class Mercurial(val baseDir: File) extends Vcs with GitLike {
val commandName = "hg"

override def add(files: String*) = {
val filesToAdd = files.filterNot(isFileUnderVersionControl)
if(!filesToAdd.isEmpty) cmd(("add" +: filesToAdd): _*) else noop
}

private def andSign(sign: Boolean, proc: ProcessBuilder) =
if (sign)
proc #&& cmd("sign")
Expand Down Expand Up @@ -112,6 +117,11 @@ class Mercurial(val baseDir: File) extends Vcs with GitLike {
def hasUntrackedFiles = cmd("status", "-un").!!.trim.nonEmpty

def hasModifiedFiles = cmd("status", "-mn").!!.trim.nonEmpty

private def isFileUnderVersionControl(file: String): Boolean = Try(cmd("status", "-nmardc", file).!!).nonEmpty

private def noop:ProcessBuilder = status

}

object Git extends VcsCompanion {
Expand Down

0 comments on commit 514e6a6

Please sign in to comment.