# HG changeset patch # User Brendan Cully # Date 1224373201 25200 # Node ID d1d011accf94fec65766802413ce1f838989fb0f # Parent fd3cba5e73ae17d39f9eb1a2e295ff8b4c0267ab mq: let qimport read patches from URLs diff -r fd3cba5e73ae -r d1d011accf94 hgext/mq.py --- a/hgext/mq.py Sat Oct 18 16:33:10 2008 -0700 +++ b/hgext/mq.py Sat Oct 18 16:40:01 2008 -0700 @@ -34,7 +34,7 @@ from mercurial.repo import RepoError from mercurial import commands, cmdutil, hg, patch, revlog, util from mercurial import repair -import os, sys, re, errno +import os, sys, re, errno, urllib commands.norepo += " qclone" @@ -1499,7 +1499,10 @@ raise util.Abort(_('need --name to import a patch from -')) text = sys.stdin.read() else: - text = file(filename, 'rb').read() + if os.path.exists(filename): + text = file(filename, 'rb').read() + else: + text = urllib.urlopen(filename).read() except IOError: raise util.Abort(_("unable to read %s") % filename) if not patchname: diff -r fd3cba5e73ae -r d1d011accf94 tests/test-mq-qimport --- a/tests/test-mq-qimport Sat Oct 18 16:33:10 2008 -0700 +++ b/tests/test-mq-qimport Sat Oct 18 16:40:01 2008 -0700 @@ -27,6 +27,15 @@ echo % qimport non-existing-file hg qimport non-existing-file +echo % import URL +echo foo >> foo +hg add foo +hg diff > $HGTMP/url.diff +hg revert --no-backup foo +rm foo +hg qimport file://$HGTMP/url.diff +hg qun + echo % build diff with CRLF python ../writelines.py b 5 'a\n' 5 'a\r\n' hg ci -Am addb diff -r fd3cba5e73ae -r d1d011accf94 tests/test-mq-qimport.out --- a/tests/test-mq-qimport.out Sat Oct 18 16:33:10 2008 -0700 +++ b/tests/test-mq-qimport.out Sat Oct 18 16:40:01 2008 -0700 @@ -1,5 +1,8 @@ % qimport non-existing-file abort: unable to read non-existing-file +% import URL +adding url.diff to series file +url.diff % build diff with CRLF adding b 1 files updated, 0 files merged, 0 files removed, 0 files unresolved