##// END OF EJS Templates
Merge with crew-stable
Patrick Mezard -
r9598:a981ddb1 merge default
parent child Browse files
Show More
@@ -115,7 +115,11 b' class logstream(object):'
115
115
116 def __iter__(self):
116 def __iter__(self):
117 while True:
117 while True:
118 entry = pickle.load(self._stdout)
118 try:
119 entry = pickle.load(self._stdout)
120 except EOFError:
121 raise util.Abort(_('Mercurial failed to run itself, check'
122 ' hg executable is in PATH'))
119 try:
123 try:
120 orig_paths, revnum, author, date, message = entry
124 orig_paths, revnum, author, date, message = entry
121 except:
125 except:
@@ -292,14 +292,23 b' class patchfile(object):'
292 self.hunks = 0
292 self.hunks = 0
293
293
294 def readlines(self, fname):
294 def readlines(self, fname):
295 if os.path.islink(fname):
296 return [os.readlink(fname)]
295 fp = self.opener(fname, 'r')
297 fp = self.opener(fname, 'r')
296 try:
298 try:
297 return list(linereader(fp, self.eol is not None))
299 return list(linereader(fp, self.eol is not None))
298 finally:
300 finally:
299 fp.close()
301 fp.close()
300
302
301 def writelines(self, fname, lines):
303 def writelines(self, fname, lines):
302 fp = self.opener(fname, 'w')
304 # Ensure supplied data ends in fname, being a regular file or
305 # a symlink. updatedir() will -too magically- take care of
306 # setting it to the proper type afterwards.
307 islink = os.path.islink(fname)
308 if islink:
309 fp = cStringIO.StringIO()
310 else:
311 fp = self.opener(fname, 'w')
303 try:
312 try:
304 if self.eol and self.eol != '\n':
313 if self.eol and self.eol != '\n':
305 for l in lines:
314 for l in lines:
@@ -308,6 +317,8 b' class patchfile(object):'
308 fp.write(l)
317 fp.write(l)
309 else:
318 else:
310 fp.writelines(lines)
319 fp.writelines(lines)
320 if islink:
321 self.opener.symlink(fp.getvalue(), fname)
311 finally:
322 finally:
312 fp.close()
323 fp.close()
313
324
@@ -399,7 +410,7 b' class patchfile(object):'
399 self.rej.append(h)
410 self.rej.append(h)
400 return -1
411 return -1
401
412
402 if isinstance(h, githunk):
413 if isinstance(h, binhunk):
403 if h.rmfile():
414 if h.rmfile():
404 self.unlink(self.fname)
415 self.unlink(self.fname)
405 else:
416 else:
@@ -665,12 +676,12 b' class hunk(object):'
665 def new(self, fuzz=0, toponly=False):
676 def new(self, fuzz=0, toponly=False):
666 return self.fuzzit(self.b, fuzz, toponly)
677 return self.fuzzit(self.b, fuzz, toponly)
667
678
668 class githunk(object):
679 class binhunk:
669 """A git hunk"""
680 'A binary patch file. Only understands literals so far.'
670 def __init__(self, gitpatch):
681 def __init__(self, gitpatch):
671 self.gitpatch = gitpatch
682 self.gitpatch = gitpatch
672 self.text = None
683 self.text = None
673 self.hunk = []
684 self.hunk = ['GIT binary patch\n']
674
685
675 def createfile(self):
686 def createfile(self):
676 return self.gitpatch.op in ('ADD', 'RENAME', 'COPY')
687 return self.gitpatch.op in ('ADD', 'RENAME', 'COPY')
@@ -684,12 +695,6 b' class githunk(object):'
684 def new(self):
695 def new(self):
685 return [self.text]
696 return [self.text]
686
697
687 class binhunk(githunk):
688 'A binary patch file. Only understands literals so far.'
689 def __init__(self, gitpatch):
690 super(binhunk, self).__init__(gitpatch)
691 self.hunk = ['GIT binary patch\n']
692
693 def extract(self, lr):
698 def extract(self, lr):
694 line = lr.readline()
699 line = lr.readline()
695 self.hunk.append(line)
700 self.hunk.append(line)
@@ -717,18 +722,6 b' class binhunk(githunk):'
717 len(text), size)
722 len(text), size)
718 self.text = text
723 self.text = text
719
724
720 class symlinkhunk(githunk):
721 """A git symlink hunk"""
722 def __init__(self, gitpatch, hunk):
723 super(symlinkhunk, self).__init__(gitpatch)
724 self.hunk = hunk
725
726 def complete(self):
727 return True
728
729 def fix_newline(self):
730 return
731
732 def parsefilename(str):
725 def parsefilename(str):
733 # --- filename \t|space stuff
726 # --- filename \t|space stuff
734 s = str[4:].rstrip('\r\n')
727 s = str[4:].rstrip('\r\n')
@@ -875,10 +868,6 b' def iterhunks(ui, fp, sourcefile=None, t'
875 create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD'
868 create = afile == '/dev/null' or gpatch and gpatch.op == 'ADD'
876 remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE'
869 remove = bfile == '/dev/null' or gpatch and gpatch.op == 'DELETE'
877 current_hunk = hunk(x, hunknum + 1, lr, context, create, remove)
870 current_hunk = hunk(x, hunknum + 1, lr, context, create, remove)
878 if remove:
879 gpatch = changed.get(afile[2:])
880 if gpatch and gpatch.mode[0]:
881 current_hunk = symlinkhunk(gpatch, current_hunk)
882 except PatchError, err:
871 except PatchError, err:
883 ui.debug(err)
872 ui.debug(err)
884 current_hunk = None
873 current_hunk = None
@@ -28,3 +28,7 b" hg glog --template 'branch={branches} {r"
28 hg branches | sed 's/:.*/:/'
28 hg branches | sed 's/:.*/:/'
29 hg tags -q
29 hg tags -q
30 cd ..
30 cd ..
31
32 echo '% test hg failing to call itself'
33 HG=foobar hg convert svn-repo B-hg 2>&1 | grep -v foobar
34
@@ -48,3 +48,6 b' default 10:'
48 old 9:
48 old 9:
49 old2 8:
49 old2 8:
50 tip
50 tip
51 % test hg failing to call itself
52 initializing destination B-hg repository
53 abort: Mercurial failed to run itself, check hg executable is in PATH
@@ -1,12 +1,31 b''
1 a -> a not a symlink
1 a -> a not a symlink
2 % test replacing a file with a symlink
2 a -> b
3 a -> b
3 popping symlink.patch
4 popping symlink.patch
4 now at: base.patch
5 now at: base.patch
5 applying symlink.patch
6 applying symlink.patch
6 now at: symlink.patch
7 now at: symlink.patch
7 a -> b
8 a -> b
9 % test updating a symlink
10 a -> c
11 popping updatelink
12 now at: symlink.patch
13 applying updatelink
14 patching file a
15 a
16 now at: updatelink
17 a -> c
18 % test replacing a symlink with a file
19 popping replacelinkwithfile
20 now at: addlink
21 applying replacelinkwithfile
22 now at: replacelinkwithfile
23 sss
24 % test symlink removal
8 popping removesl.patch
25 popping removesl.patch
9 now at: symlink.patch
26 now at: replacelinkwithfile
10 applying removesl.patch
27 applying removesl.patch
11 now at: removesl.patch
28 now at: removesl.patch
12 C b
29 C b
30 C c
31 C s
General Comments 0
You need to be logged in to leave comments. Login now