Add username/merge/editor to .hgrc
authorMatt Mackall <mpm@selenic.com>
Sun, 03 Jul 2005 21:51:09 -0800
changeset 608 d2994b5298fb
parent 607 94744f6fe0e7
child 609 2acf1f5df2e6
Add username/merge/editor to .hgrc -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Add username/merge/editor to .hgrc These take priority over the equivalent environment vars Deprecate HGMERGE, HGUSER, and HGEDITOR in docs Add ui section to docs Remove undocumented HG_OPTS Raise username code out of changelog class Make tests ignore ~/.hgrc manifest hash: d127ef02bc5266036b4c77a55319519e91bd475b -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCyM5NywK+sNU5EO8RAuU7AJ9zKk1TFrJXHM04jOOJJeBSp8jlTgCeP+tr qwGFd+WaNqTepZ0wun5g9Uc= =QEBu -----END PGP SIGNATURE-----
doc/hg.1.txt
mercurial/fancyopts.py
mercurial/hg.py
mercurial/ui.py
tests/run-tests
--- a/doc/hg.1.txt	Sun Jul 03 21:14:40 2005 -0800
+++ b/doc/hg.1.txt	Sun Jul 03 21:51:09 2005 -0800
@@ -415,7 +415,9 @@
 
 HGEDITOR::
     This is the name of the editor to use when committing. Defaults to the
-    value of EDITOR.
+    value of EDITOR. 
+
+    (deprecated, use .hgrc)
 
 HGMERGE::
     An executable to use for resolving merge conflicts. The program
@@ -425,9 +427,13 @@
     The default program is "hgmerge", which is a shell script provided
     by Mercurial with some sensible defaults.
 
+    (deprecated, use .hgrc)
+
 HGUSER::
     This is the string used for the author of a commit.
 
+    (deprecated, use .hgrc)
+
 EMAIL::
     If HGUSER is not set, this will be used as the author for a commit.
 
@@ -458,6 +464,21 @@
     This file contains defaults and configuration. Values in .hg/hgrc
     override those in .hgrc.
 
+
+UI OPTIONS
+----------
+
+Various configuration options can be set in .hgrc:
+
+-------------
+[ui]
+verbose = 0
+username = Matt Mackall <mpm@selenic.com>
+editor = hgeditor
+merge = hgmerge
+-------------
+
+
 NAMED REPOSITORIES
 ------------------
 
--- a/mercurial/fancyopts.py	Sun Jul 03 21:14:40 2005 -0800
+++ b/mercurial/fancyopts.py	Sun Jul 03 21:51:09 2005 -0800
@@ -14,9 +14,6 @@
         if s: short = short + s
         if l: long.append(l)
 
-    if os.environ.has_key("HG_OPTS"):
-        args = os.environ["HG_OPTS"].split() + args
-
     opts, args = getopt.getopt(args, short, long)
 
     for opt, arg in opts:
--- a/mercurial/hg.py	Sun Jul 03 21:14:40 2005 -0800
+++ b/mercurial/hg.py	Sun Jul 03 21:51:09 2005 -0800
@@ -161,12 +161,6 @@
 
     def add(self, manifest, list, desc, transaction, p1=None, p2=None,
                   user=None, date=None):
-        user = (user or
-                os.environ.get("HGUSER") or
-                os.environ.get("EMAIL") or
-                (os.environ.get("LOGNAME",
-                               os.environ.get("USERNAME", "unknown"))
-                 + '@' + socket.getfqdn()))
         date = date or "%d %d" % (time.time(), time.timezone)
         list.sort()
         l = [hex(manifest), user, date] + list + ["", desc]
@@ -592,6 +586,7 @@
                     pass
 
         mnode = self.manifest.add(mm, mfm, tr, linkrev, c1[0], c2[0])
+        user = user or self.ui.username()
         n = self.changelog.add(mnode, files, text, tr, p1, p2, user, date)
         tr.close()
         if update_dirstate:
@@ -675,6 +670,7 @@
                 return 1
             text = edittext
 
+        user = user or self.ui.username()
         n = self.changelog.add(mn, new, text, tr, p1, p2, user, date)
 
         if not self.hook("commit", node=hex(n)):
@@ -1303,7 +1299,8 @@
         self.ui.debug("file %s: other %s ancestor %s\n" %
                               (fn, short(other), short(base)))
 
-        cmd = os.environ.get("HGMERGE", "hgmerge")
+        cmd = self.ui.config("ui", "merge") or \
+              os.environ.get("HGMERGE", "hgmerge")
         r = os.system("%s %s %s %s" % (cmd, a, b, c))
         if r:
             self.ui.warn("merging %s failed!\n" % fn)
--- a/mercurial/ui.py	Sun Jul 03 21:14:40 2005 -0800
+++ b/mercurial/ui.py	Sun Jul 03 21:51:09 2005 -0800
@@ -41,6 +41,14 @@
             return self.cdata.items(section)
         return []
 
+    def username(self):
+        return (self.config("ui", "username") or
+                os.environ.get("HGUSER") or
+                os.environ.get("EMAIL") or
+                (os.environ.get("LOGNAME",
+                                os.environ.get("USERNAME", "unknown"))
+                 + '@' + socket.getfqdn()))
+
     def expandpath(self, loc):
         paths = {}
         for name, path in self.configitems("paths"):
@@ -83,7 +91,10 @@
         f.write(text)
         f.close()
 
-        editor = os.environ.get("HGEDITOR") or os.environ.get("EDITOR", "vi")
+        editor = (self.config("ui", "editor") or
+                  os.environ.get("HGEDITOR") or
+                  os.environ.get("EDITOR", "vi"))
+
         util.system("%s %s" % (editor, name), errprefix = "edit failed")
 
         t = open(name).read()
--- a/tests/run-tests	Sun Jul 03 21:14:40 2005 -0800
+++ b/tests/run-tests	Sun Jul 03 21:51:09 2005 -0800
@@ -51,6 +51,7 @@
 
     cd $D
     fail=0
+    export HOME=$D
 
     if ! $H/$1 > .out 2>&1 ; then
 	echo $1 failed with error code $?