[PATCH] record: checks for valid username before starting the recording process

Sumeet sumeet at fb.com
Mon Aug 27 17:04:53 CDT 2012


# HG changeset patch
# User Sumeet <sumeet at fb.com>
# Date 1346096470 25200
# Node ID 8d5630194133943d546ee71b2d8486d37a697719
# Parent  c6f88e7f95b764e23b7e0b4353c5a6458bbc3cc4
record: checks for valid username before starting the recording process

It is quite a bad UX when you spend some time selecting changes for
recording and at the end everything is lost,
because username is not configured for this clone.
'hg record' used to record all the changes and then check for username
before commiting the changes.
Bug in upstream mercurial: http://bz.selenic.com/show_bug.cgi?id=3456

This patch now will help check record for valid username before recording
changes.
I added a test case in test-record.t which unsets username and tries to
record changes to a file which terminates with error code 255.

diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -496,6 +496,10 @@
         raise util.Abort(_('running non-interactively, use %s instead') %
                          cmdsuggest)
 
+    # Bug 3456
+    if not ui.username():
+        raise util.Abort(_('no username supplied'))
+
     def recordfunc(ui, repo, message, match, opts):
         """This is generic record driver.
 
diff --git a/tests/test-record.t b/tests/test-record.t
--- a/tests/test-record.t
+++ b/tests/test-record.t
@@ -246,10 +246,24 @@
   +9
   +10
   
+Modify end of plain file with username unset
+
+  $ unset HGUSER
+  $ unset EMAIL
+  $ unset LOGNAME
+  $ echo 11 >> plain
+  $ hg record -d '8 0' -m end plain <<EOF
+  > y
+  > y
+  > EOF
+  abort: no username supplied (see "hg help config")
+  [255]
+
 
 Modify end of plain file
 
-  $ echo 11 >> plain
+  $ HGUSER="test"
+  $ export HGUSER
   $ hg record -d '8 0' -m end plain <<EOF
   > y
   > y


More information about the Mercurial-devel mailing list