##// END OF EJS Templates
Make 'hg import' platform independent....
Volker Kleinfeld -
r1285:1546c2aa default
parent child Browse files
Show More
@@ -1173,18 +1173,7 b' def import_(ui, repo, patch1, *patches, '
1173 message = "%s\n" % '\n'.join(message)
1173 message = "%s\n" % '\n'.join(message)
1174 ui.debug('message:\n%s\n' % message)
1174 ui.debug('message:\n%s\n' % message)
1175
1175
1176 f = os.popen("patch -p%d < '%s'" % (strip, pf))
1176 files = util.patch(strip, pf, ui)
1177 files = []
1178 for l in f.read().splitlines():
1179 l.rstrip('\r\n');
1180 ui.status("%s\n" % l)
1181 if l.startswith('patching file '):
1182 pf = l[14:]
1183 if pf not in files:
1184 files.append(pf)
1185 patcherr = f.close()
1186 if patcherr:
1187 raise util.Abort("patch failed")
1188
1177
1189 if len(files) > 0:
1178 if len(files) > 0:
1190 addremove(ui, repo, *files)
1179 addremove(ui, repo, *files)
@@ -30,6 +30,22 b' def filter(s, cmd):'
30 w.join()
30 w.join()
31 return f
31 return f
32
32
33 def patch(strip, patchname, ui):
34 """apply the patch <patchname> to the working directory.
35 a list of patched files is returned"""
36 fp = os.popen('patch -p%d < "%s"' % (strip, patchname))
37 files = {}
38 for line in fp:
39 line = line.rstrip()
40 ui.status("%s\n" % line)
41 if line.startswith('patching file '):
42 pf = parse_patch_output(line)
43 files.setdefault(pf, 1)
44 code = fp.close()
45 if code:
46 raise Abort("patch command failed: exit status %s " % code)
47 return files.keys()
48
33 def binary(s):
49 def binary(s):
34 """return true if a string is binary data using diff's heuristic"""
50 """return true if a string is binary data using diff's heuristic"""
35 if s and '\0' in s[:4096]:
51 if s and '\0' in s[:4096]:
@@ -315,6 +331,13 b' else:'
315 if os.name == 'nt':
331 if os.name == 'nt':
316 nulldev = 'NUL:'
332 nulldev = 'NUL:'
317
333
334 def parse_patch_output(output_line):
335 """parses the output produced by patch and returns the file name"""
336 pf = output_line[14:]
337 if pf[0] == '`':
338 pf = pf[1:-1] # Remove the quotes
339 return pf
340
318 try: # ActivePython can create hard links using win32file module
341 try: # ActivePython can create hard links using win32file module
319 import win32file
342 import win32file
320
343
@@ -360,6 +383,10 b" if os.name == 'nt':"
360 else:
383 else:
361 nulldev = '/dev/null'
384 nulldev = '/dev/null'
362
385
386 def parse_patch_output(output_line):
387 """parses the output produced by patch and returns the file name"""
388 return output_line[14:]
389
363 def is_exec(f, last):
390 def is_exec(f, last):
364 """check whether a file is executable"""
391 """check whether a file is executable"""
365 return (os.stat(f).st_mode & 0100 != 0)
392 return (os.stat(f).st_mode & 0100 != 0)
General Comments 0
You need to be logged in to leave comments. Login now