patch: use util.set_flags
authorMatt Mackall <mpm@selenic.com>
Thu, 27 Dec 2007 22:29:21 -0600
changeset 5706 89fe5b36c21e
parent 5705 4e400863c5ac
child 5707 76dd039c2bad
patch: use util.set_flags
mercurial/patch.py
--- a/mercurial/patch.py	Thu Dec 27 22:29:17 2007 -0600
+++ b/mercurial/patch.py	Thu Dec 27 22:29:21 2007 -0600
@@ -1082,16 +1082,17 @@
     for f in patches:
         ctype, gp = patches[f]
         if gp and gp.mode:
-            x = gp.mode & 0100 != 0
-            l = gp.mode & 020000 != 0
+            flags = ''
+            if gp.mode & 0100:
+                flags = 'x'
+            elif gp.mode & 020000:
+                flags = 'l'
             dst = os.path.join(repo.root, gp.path)
             # patch won't create empty files
             if ctype == 'ADD' and not os.path.exists(dst):
-                repo.wwrite(gp.path, '', x and 'x' or '')
+                repo.wwrite(gp.path, '', flags)
             else:
-                util.set_link(dst, l)
-                if not l:
-                    util.set_exec(dst, x)
+                util.set_flags(dst, flags)
     cmdutil.addremove(repo, cfiles)
     files = patches.keys()
     files.extend([r for r in removes if r not in files])