Mercurial > jhg
diff src/org/tmatesoft/hg/repo/HgInternals.java @ 128:44b97930570c
Introduced ChangelogHelper to look up changesets files were modified in
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 16 Feb 2011 20:13:41 +0100 |
parents | 46291ec605a0 |
children | 37a34044e6bd |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgInternals.java Wed Feb 16 18:42:10 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgInternals.java Wed Feb 16 20:13:41 2011 +0100 @@ -17,6 +17,8 @@ package org.tmatesoft.hg.repo; import java.io.File; +import java.net.InetAddress; +import java.net.UnknownHostException; import org.tmatesoft.hg.internal.ConfigFile; @@ -58,4 +60,27 @@ public ConfigFile getRepoConfig() { return repo.getConfigFile(); } + + // in fact, need a setter for this anyway, shall move to internal.Internals perhaps? + public String getNextCommitUsername() { + String hgUser = System.getenv("HGUSER"); + if (hgUser != null && hgUser.trim().length() > 0) { + return hgUser.trim(); + } + String configValue = getRepoConfig().getString("ui", "username", null); + if (configValue != null) { + return configValue; + } + String email = System.getenv("EMAIL"); + if (email != null && email.trim().length() > 0) { + return email; + } + String username = System.getProperty("user.name"); + try { + String hostname = InetAddress.getLocalHost().getHostName(); + return username + '@' + hostname; + } catch (UnknownHostException ex) { + return username; + } + } }