Patchwork [1,of,2] util: add functions to check symlink/exec bits

login
register
mail settings
Submitter Bryan O'Sullivan
Date April 3, 2013, 3:57 p.m.
Message ID <5cbbc8b9ab28356138ee.1365004623@australite.local>
Download mbox | patch
Permalink /patch/1254/
State Accepted
Commit cafa447a7d3b494d334776de28e02606f297bdbf
Headers show

Comments

Bryan O'Sullivan - April 3, 2013, 3:57 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1364947219 25200
#      Tue Apr 02 17:00:19 2013 -0700
# Node ID 5cbbc8b9ab28356138eead0c0539ba9e7afd1089
# Parent  65a67c7aefed9d86aa24758aaa7529445856db9f
util: add functions to check symlink/exec bits

These are not yet used.

Patch

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -557,3 +557,11 @@  class unixdomainserver(socket.socket):
         if self.realpath != self.path:
             okayifmissing(os.unlink, self.realpath)
             okayifmissing(os.rmdir, os.path.dirname(self.realpath))
+
+def statislink(st):
+    '''check whether a stat result is a symlink'''
+    return st and stat.S_ISLNK(st.st_mode)
+
+def statisexec(st):
+    '''check whether a stat result is an executable file'''
+    return st and (st.st_mode & 0100 != 0)
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -65,6 +65,8 @@  spawndetached = platform.spawndetached
 split = platform.split
 sshargs = platform.sshargs
 statfiles = getattr(osutil, 'statfiles', platform.statfiles)
+statisexec = platform.statisexec
+statislink = platform.statislink
 termwidth = platform.termwidth
 testpid = platform.testpid
 umask = platform.umask
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -337,3 +337,11 @@  def lookupreg(key, valname=None, scope=N
             pass
 
 expandglobs = True
+
+def statislink(st):
+    '''check whether a stat result is a symlink'''
+    return False
+
+def statisexec(st):
+    '''check whether a stat result is an executable file'''
+    return False