# HG changeset patch # User Alexis S. L. Carvalho # Date 1173009801 10800 # Node ID 9dc64c8414caf4a91cb11a19c978b677d9ff7431 # Parent b9dcee25be8e5c1baed05cf74aa73a3670379cad# Parent a9ee6c53af8db43a746a91e9f015677598a5eb7e Merge with crew-stable diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1738,7 +1738,10 @@ def guard(ui, repo, *args, **opts): if patch is None: raise util.Abort(_('no patch to work with')) if args or opts['none']: - q.set_guards(q.find_series(patch), args) + idx = q.find_series(patch) + if idx is None: + raise util.Abort(_('no patch named %s') % patch) + q.set_guards(idx, args) q.save_dirty() else: status(q.series.index(q.lookup(patch))) diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c --- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -255,8 +255,8 @@ static struct hunklist diff(struct line if (pos && l.base && t) { /* generate the matching block list */ recurse(a, b, pos, 0, an, 0, bn, &l); - l.head->a1 = an; - l.head->b1 = bn; + l.head->a1 = l.head->a2 = an; + l.head->b1 = l.head->b2 = bn; l.head++; } diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py --- a/mercurial/hgweb/server.py +++ b/mercurial/hgweb/server.py @@ -197,6 +197,11 @@ def create_server(ui, repo): pass class MercurialHTTPServer(object, _mixin, BaseHTTPServer.HTTPServer): + + # SO_REUSEADDR has broken semantics on windows + if os.name == 'nt': + allow_reuse_address = 0 + def __init__(self, *args, **kargs): BaseHTTPServer.HTTPServer.__init__(self, *args, **kargs) self.accesslog = accesslog diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -126,6 +126,7 @@ class httprepository(remoterepository): def __init__(self, ui, path): self.path = path self.caps = None + self.handler = None scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) if query or frag: raise util.Abort(_('unsupported URL component: "%s"') % @@ -140,7 +141,8 @@ class httprepository(remoterepository): proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') # XXX proxyauthinfo = None - handlers = [httphandler()] + self.handler = httphandler() + handlers = [self.handler] if proxyurl: # proxy can be proper url or host[:port] @@ -198,6 +200,11 @@ class httprepository(remoterepository): # 1.0 here is the _protocol_ version opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] urllib2.install_opener(opener) + + def __del__(self): + if self.handler: + self.handler.close_all() + self.handler = None def url(self): return self.path diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1880,6 +1880,8 @@ class localrepository(repo.repository): ofp.write(chunk) ofp.close() elapsed = time.time() - start + if elapsed <= 0: + elapsed = 0.001 self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % (util.bytecount(total_bytes), elapsed, util.bytecount(total_bytes / elapsed))) diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -78,7 +78,7 @@ def stream_out(repo, fileobj): entries = [] total_bytes = 0 for name, size in walkrepo(repo.spath): - name = util.pconvert(repo.decodefn(name)) + name = repo.decodefn(util.pconvert(name)) entries.append((name, size)) total_bytes += size repolock.release() diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -790,6 +790,14 @@ if os.name == 'nt': if inst.errno != 0: raise self.close() raise IOError(errno.EPIPE, 'Broken pipe') + + def flush(self): + try: + return self.fp.flush() + except IOError, inst: + if inst.errno != errno.EINVAL: raise + self.close() + raise IOError(errno.EPIPE, 'Broken pipe') sys.stdout = winstdout(sys.stdout) diff --git a/tests/test-http b/tests/test-http --- a/tests/test-http +++ b/tests/test-http @@ -6,6 +6,8 @@ echo foo>foo hg commit -A -d '0 0' -m 1 hg --config server.uncompressed=True serve -p 20059 -d --pid-file=../hg1.pid hg serve -p 20060 -d --pid-file=../hg2.pid +# Test server address cannot be reused +hg serve -p 20060 2>&1 | sed -e 's/abort: cannot start server:.*/abort: cannot start server:/' cd .. cat hg1.pid hg2.pid >> $DAEMON_PIDS diff --git a/tests/test-http.out b/tests/test-http.out --- a/tests/test-http.out +++ b/tests/test-http.out @@ -1,4 +1,5 @@ adding foo +abort: cannot start server: % clone via stream streaming all changes XXX files to transfer, XXX bytes of data diff --git a/tests/test-mq-guards b/tests/test-mq-guards --- a/tests/test-mq-guards +++ b/tests/test-mq-guards @@ -27,6 +27,9 @@ hg qrefresh hg qpop -a echo % should fail +hg qguard does-not-exist.patch +bleh + +echo % should fail hg qguard +fail hg qpush diff --git a/tests/test-mq-guards.out b/tests/test-mq-guards.out --- a/tests/test-mq-guards.out +++ b/tests/test-mq-guards.out @@ -1,6 +1,8 @@ adding x Patch queue now empty % should fail +abort: no patch named does-not-exist.patch +% should fail abort: no patches applied applying a.patch Now at: a.patch