##// END OF EJS Templates
patch: patchmeta gives (islink, isexec) tuple instead of int mode
Patrick Mezard -
r7149:01a056c5 default
parent child Browse files
Show More
@@ -148,8 +148,10 b' class patchmeta:'
148
148
149 'op' is the performed operation within ADD, DELETE, RENAME, MODIFY
149 'op' is the performed operation within ADD, DELETE, RENAME, MODIFY
150 or COPY. 'path' is patched file path. 'oldpath' is set to the
150 or COPY. 'path' is patched file path. 'oldpath' is set to the
151 origin file when 'op' is either COPY or RENAME, None
151 origin file when 'op' is either COPY or RENAME, None otherwise. If
152 otherwise. 'mode' is set to the new mode of patched file or None.
152 file mode is changed, 'mode' is a tuple (islink, isexec) where
153 'islink' is True if the file is a symlink and 'isexec' is True if
154 the file is executable. Otherwise, 'mode' is None.
153 """
155 """
154 def __init__(self, path):
156 def __init__(self, path):
155 self.path = path
157 self.path = path
@@ -159,6 +161,11 b' class patchmeta:'
159 self.lineno = 0
161 self.lineno = 0
160 self.binary = False
162 self.binary = False
161
163
164 def setmode(self, mode):
165 islink = mode & 020000
166 isexec = mode & 0100
167 self.mode = (islink, isexec)
168
162 def readgitpatch(fp, firstline=None):
169 def readgitpatch(fp, firstline=None):
163 """extract git-style metadata about patches from <patchname>"""
170 """extract git-style metadata about patches from <patchname>"""
164
171
@@ -208,9 +215,9 b' def readgitpatch(fp, firstline=None):'
208 gp.op = 'DELETE'
215 gp.op = 'DELETE'
209 elif line.startswith('new file mode '):
216 elif line.startswith('new file mode '):
210 gp.op = 'ADD'
217 gp.op = 'ADD'
211 gp.mode = int(line.rstrip()[-6:], 8)
218 gp.setmode(int(line.rstrip()[-6:], 8))
212 elif line.startswith('new mode '):
219 elif line.startswith('new mode '):
213 gp.mode = int(line.rstrip()[-6:], 8)
220 gp.setmode(int(line.rstrip()[-6:], 8))
214 elif line.startswith('GIT binary patch'):
221 elif line.startswith('GIT binary patch'):
215 dopatch |= GP_BINARY
222 dopatch |= GP_BINARY
216 gp.binary = True
223 gp.binary = True
@@ -1096,17 +1103,14 b' def updatedir(ui, repo, patches):'
1096 for f in patches:
1103 for f in patches:
1097 ctype, gp = patches[f]
1104 ctype, gp = patches[f]
1098 if gp and gp.mode:
1105 if gp and gp.mode:
1099 flags = ''
1106 islink, isexec = gp.mode
1100 if gp.mode & 0100:
1101 flags = 'x'
1102 elif gp.mode & 020000:
1103 flags = 'l'
1104 dst = os.path.join(repo.root, gp.path)
1107 dst = os.path.join(repo.root, gp.path)
1105 # patch won't create empty files
1108 # patch won't create empty files
1106 if ctype == 'ADD' and not os.path.exists(dst):
1109 if ctype == 'ADD' and not os.path.exists(dst):
1110 flags = (isexec and 'x' or '') + (islink and 'l' or '')
1107 repo.wwrite(gp.path, '', flags)
1111 repo.wwrite(gp.path, '', flags)
1108 else:
1112 else:
1109 util.set_flags(dst, 'l' in flags, 'x' in flags)
1113 util.set_flags(dst, islink, isexec)
1110 cmdutil.addremove(repo, cfiles)
1114 cmdutil.addremove(repo, cfiles)
1111 files = patches.keys()
1115 files = patches.keys()
1112 files.extend([r for r in removes if r not in files])
1116 files.extend([r for r in removes if r not in files])
General Comments 0
You need to be logged in to leave comments. Login now