# HG changeset patch # User Matt Mackall # Date 2012-05-12 10:23:49 # Node ID ea7bf1d49bce6bb28c26a36c4c1538a857e744aa # Parent de4b42daf396b000e73c0cc0217a5fde0a88ac8f # Parent 2fdd1902ed2d0862afd51f956379b0effac4e884 merge with stable diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py --- a/hgext/bugzilla.py +++ b/hgext/bugzilla.py @@ -585,11 +585,13 @@ class cookietransportrequest(object): # 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. diff --git a/hgext/pager.py b/hgext/pager.py --- a/hgext/pager.py +++ b/hgext/pager.py @@ -85,10 +85,8 @@ def uisetup(ui): (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) diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c --- a/mercurial/diffhelpers.c +++ b/mercurial/diffhelpers.c @@ -135,7 +135,7 @@ testhunk(PyObject *self, PyObject *args) 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++) { diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1014,9 +1014,9 @@ class hunk(object): 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 diff --git a/tests/test-import.t b/tests/test-import.t --- a/tests/test-import.t +++ b/tests/test-import.t @@ -997,6 +997,26 @@ import a unified diff with no lines of c 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