merge with stable
authorMatt Mackall <mpm@selenic.com>
Sat, 12 May 2012 12:23:49 +0200
changeset 16662 ea7bf1d49bce
parent 16661 de4b42daf396 (current diff)
parent 16652 2fdd1902ed2d (diff)
child 16663 a955e05dd7a0
merge with stable
mercurial/patch.py
--- a/hgext/bugzilla.py	Sat May 12 10:20:57 2012 +0200
+++ b/hgext/bugzilla.py	Sat May 12 12:23:49 2012 +0200
@@ -585,11 +585,13 @@
 # inheritance with a new-style class.
 class cookietransport(cookietransportrequest, xmlrpclib.Transport):
     def __init__(self, use_datetime=0):
-        xmlrpclib.Transport.__init__(self, use_datetime)
+        if util.safehasattr(xmlrpclib.Transport, "__init__"):
+            xmlrpclib.Transport.__init__(self, use_datetime)
 
 class cookiesafetransport(cookietransportrequest, xmlrpclib.SafeTransport):
     def __init__(self, use_datetime=0):
-        xmlrpclib.SafeTransport.__init__(self, use_datetime)
+        if util.safehasattr(xmlrpclib.Transport, "__init__"):
+            xmlrpclib.SafeTransport.__init__(self, use_datetime)
 
 class bzxmlrpc(bzaccess):
     """Support for access to Bugzilla via the Bugzilla XMLRPC API.
--- a/hgext/pager.py	Sat May 12 10:20:57 2012 +0200
+++ b/hgext/pager.py	Sat May 12 12:23:49 2012 +0200
@@ -85,10 +85,8 @@
                  (cmd not in ui.configlist('pager', 'ignore') and not attend))):
                 ui.setconfig('ui', 'formatted', ui.formatted())
                 ui.setconfig('ui', 'interactive', False)
-                try:
+                if util.safehasattr(signal, "SIGPIPE"):
                     signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-                except ValueError:
-                    pass
                 _runpager(p)
         return orig(ui, options, cmd, cmdfunc)
 
--- a/mercurial/diffhelpers.c	Sat May 12 10:20:57 2012 +0200
+++ b/mercurial/diffhelpers.c	Sat May 12 12:23:49 2012 +0200
@@ -135,7 +135,7 @@
 		return NULL;
 	alen = PyList_Size(a);
 	blen = PyList_Size(b);
-	if (alen > blen - bstart) {
+	if (alen > blen - bstart || bstart < 0) {
 		return Py_BuildValue("l", -1);
 	}
 	for (i = 0; i < alen; i++) {
--- a/mercurial/patch.py	Sat May 12 10:20:57 2012 +0200
+++ b/mercurial/patch.py	Sat May 12 12:23:49 2012 +0200
@@ -1014,9 +1014,9 @@
         oldstart = self.starta + top
         newstart = self.startb + top
         # zero length hunk ranges already have their start decremented
-        if self.lena:
+        if self.lena and oldstart > 0:
             oldstart -= 1
-        if self.lenb:
+        if self.lenb and newstart > 0:
             newstart -= 1
         return old, oldstart, new, newstart
 
--- a/tests/test-import.t	Sat May 12 10:20:57 2012 +0200
+++ b/tests/test-import.t	Sat May 12 12:23:49 2012 +0200
@@ -997,6 +997,26 @@
   c3
   c4
 
+no segfault while importing a unified diff which start line is zero but chunk
+size is non-zero
+
+  $ hg init startlinezero
+  $ cd startlinezero
+  $ echo foo > foo
+  $ hg commit -Amfoo
+  adding foo
+
+  $ hg import --no-commit - << EOF
+  > diff a/foo b/foo
+  > --- a/foo
+  > +++ b/foo
+  > @@ -0,1 +0,1 @@
+  >  foo
+  > EOF
+  applying patch from stdin
+
+  $ cd ..
+
 Test corner case involving fuzz and skew
 
   $ hg init morecornercases