[PATCH 06 of 19] windows: use umask 022 in debugstate output

Mads Kiilerich mads at kiilerich.com
Sun Nov 6 20:40:56 CST 2011


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1320632094 -3600
# Node ID 761672b9095d0ae87230c315189167b8e0f9c4cd
# Parent  c8ed4f9ca20ade50ce0e69ed492ba6eb282cac0b
windows: use umask 022 in debugstate output

debugstate would always report files as mode 666 or 777 on Windows.

umask is not used on Windows, but faking and using a defalt value of 022
matches what the test suite uses on Unix.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2189,7 +2189,7 @@
         if ent[1] & 020000:
             mode = 'lnk'
         else:
-            mode = '%3o' % (ent[1] & 0777)
+            mode = '%3o' % (ent[1] & 0777 & ~util.umask)
         ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
     for f in repo.dirstate.copies():
         ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -26,7 +26,7 @@
 unlink = win32.unlink
 
 nulldev = 'NUL:'
-umask = 002
+umask = 0022
 
 # wrap osutil.posixfile to provide friendlier exceptions
 def posixfile(name, mode='r', buffering=-1):
diff --git a/tests/test-rebuildstate.t b/tests/test-rebuildstate.t
--- a/tests/test-rebuildstate.t
+++ b/tests/test-rebuildstate.t
@@ -17,8 +17,8 @@
 state dump after
 
   $ hg debugstate --nodates | sort
-  n 666         -1 bar
-  n 666         -1 foo
+  n 644         -1 bar
+  n 644         -1 foo
 
 status
 


More information about the Mercurial-devel mailing list