##// END OF EJS Templates
patchbomb: add --body flag to send patches as inline message body text...
patchbomb: add --body flag to send patches as inline message body text There is currently no way to make patchbomb include patches both as attachments and as inline text. This would be quite convenient when sending patches to people who use web email clients (e.g. gmail) which often mangle the patches, making them hard to apply. The default behavior of the email command is unchanged. However it is now possible to use the --body flag _in addition_ to the -i or -a flags, in which case the patchbomb emails will contain the patch as inline body text and as an attachment. A new test has been added to test-patchbomb.t ("test attach for single patch"), based on the existing test called "test attach for single patch" test.

File last commit:

r16115:236bb604 stable
r16307:17a9a1f5 default
Show More
statichttprepo.py
139 lines | 4.6 KiB | text/x-python | PythonLexer
mpm@selenic.com
Separate out old-http support...
r1101 # statichttprepo.py - simple http repository class for mercurial
#
# This provides read-only repo access to repositories exported via static http
#
Thomas Arendsen Hein
Updated copyright notices and add "and others" to "hg version"
r4635 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
mpm@selenic.com
Separate out old-http support...
r1101 #
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
mpm@selenic.com
Separate out old-http support...
r1101
Matt Mackall
Simplify i18n imports
r3891 from i18n import _
Matt Mackall
error: move repo errors...
r7637 import changelog, byterange, url, error
Dan Villiom Podlaski Christiansen
statichttprepo: make the opener a subclass of abstractopener
r14091 import localrepo, manifest, util, scmutil, store
Dirkjan Ochtman
make static-http work with empty repos (issue965)
r6028 import urllib, urllib2, errno
Bryan O'Sullivan
Move urllib error handling from revlog into statichttprepo, where it belongs.
r1325
Benoit Boissinot
statichttprepo: cleanups, use url.py (proxy, password support)...
r7274 class httprangereader(object):
def __init__(self, url, opener):
# we assume opener has HTTPRangeHandler
self.url = url
self.pos = 0
self.opener = opener
Nicolas Dumazet
static-http: mimic more closely localrepo (issue2164: allow clone -r )...
r11066 self.name = url
Benoit Boissinot
statichttprepo: cleanups, use url.py (proxy, password support)...
r7274 def seek(self, pos):
self.pos = pos
def read(self, bytes=None):
req = urllib2.Request(self.url)
end = ''
if bytes:
end = self.pos + bytes - 1
req.add_header('Range', 'bytes=%d-%s' % (self.pos, end))
Bryan O'Sullivan
Move urllib error handling from revlog into statichttprepo, where it belongs.
r1325 try:
Benoit Boissinot
statichttprepo: cleanups, use url.py (proxy, password support)...
r7274 f = self.opener.open(req)
data = f.read()
Augie Fackler
statichttprepo: replace hasattr with getattr
r14962 # Python 2.6+ defines a getcode() function, and 2.4 and
# 2.5 appear to always have an undocumented code attribute
# set. If we can't read either of those, fall back to 206
# and hope for the best.
code = getattr(f, 'getcode', lambda : getattr(f, 'code', 206))()
Thomas Arendsen Hein
Catch urllib errors for old-http in a nicer way.
r1821 except urllib2.HTTPError, inst:
Dirkjan Ochtman
make static-http work with empty repos (issue965)
r6028 num = inst.code == 404 and errno.ENOENT or None
raise IOError(num, inst)
Bryan O'Sullivan
Move urllib error handling from revlog into statichttprepo, where it belongs.
r1325 except urllib2.URLError, inst:
Thomas Arendsen Hein
Catch urllib errors for old-http in a nicer way.
r1821 raise IOError(None, inst.reason[1])
mpm@selenic.com
Separate out old-http support...
r1101
Patrick Mezard
statichttprepo: handle remote not supporting Range headers...
r8612 if code == 200:
# HTTPRangeHandler does nothing if remote does not support
# Range headers and returns the full entity. Let's slice it.
if bytes:
data = data[self.pos:self.pos + bytes]
else:
data = data[self.pos:]
elif bytes:
Benoit Boissinot
statichttprepo: cleanups, use url.py (proxy, password support)...
r7274 data = data[:bytes]
Patrick Mezard
statichttprepo: handle remote not supporting Range headers...
r8612 self.pos += len(data)
Benoit Boissinot
statichttprepo: cleanups, use url.py (proxy, password support)...
r7274 return data
Nicolas Dumazet
static-http: mimic more closely localrepo (issue2164: allow clone -r )...
r11066 def __iter__(self):
return iter(self.read().splitlines(1))
def close(self):
pass
Benoit Boissinot
statichttprepo: cleanups, use url.py (proxy, password support)...
r7274
def build_opener(ui, authinfo):
# urllib cannot handle URLs with embedded user or passwd
urlopener = url.opener(ui, authinfo)
urlopener.add_handler(byterange.HTTPRangeHandler())
Dan Villiom Podlaski Christiansen
statichttprepo: make the opener a subclass of abstractopener
r14091 class statichttpopener(scmutil.abstractopener):
def __init__(self, base):
self.base = base
def __call__(self, path, mode="r", atomictemp=None):
Adrian Buehlmann
statichttprepo: abort if opener mode is 'r+' or 'rb+'...
r13533 if mode not in ('r', 'rb'):
Nicolas Dumazet
static-http: mimic more closely localrepo (issue2164: allow clone -r )...
r11066 raise IOError('Permission denied')
Dan Villiom Podlaski Christiansen
statichttprepo: make the opener a subclass of abstractopener
r14091 f = "/".join((self.base, urllib.quote(path)))
Benoit Boissinot
statichttprepo: cleanups, use url.py (proxy, password support)...
r7274 return httprangereader(f, urlopener)
Dan Villiom Podlaski Christiansen
statichttprepo: make the opener a subclass of abstractopener
r14091 return statichttpopener
mpm@selenic.com
Separate out old-http support...
r1101
class statichttprepository(localrepo.localrepository):
def __init__(self, ui, path):
Vadim Gelfer
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks...
r2673 self._url = path
mpm@selenic.com
Separate out old-http support...
r1101 self.ui = ui
Benoit Boissinot
switch to the .hg/store layout, fix the tests
r3853
Nicolas Dumazet
static-http: mimic more closely localrepo (issue2164: allow clone -r )...
r11066 self.root = path
Brodie Rao
url: move URL parsing functions into util to improve startup time...
r14076 u = util.url(path.rstrip('/') + "/.hg")
Brodie Rao
httprepo/sshrepo: use url.url...
r13819 self.path, authinfo = u.authinfo()
Benoit Boissinot
statichttprepo: cleanups, use url.py (proxy, password support)...
r7274
opener = build_opener(ui, authinfo)
mpm@selenic.com
Separate out old-http support...
r1101 self.opener = opener(self.path)
Pierre-Yves David
phases: mechanism to allow extension to alter initial computation of phase...
r15922 self._phasedefaults = []
Dirkjan Ochtman
make static-http work with empty repos (issue965)
r6028
Benoit Boissinot
add "requires" file to the repo, specifying the requirements
r3851 try:
Adrian Buehlmann
introduce new function scmutil.readrequires...
r14482 requirements = scmutil.readrequires(self.opener, self.supported)
Dirkjan Ochtman
make static-http work with empty repos (issue965)
r6028 except IOError, inst:
Thomas Arendsen Hein
Fix Debian bug #494889 (fetching from static-http://... broken)...
r7178 if inst.errno != errno.ENOENT:
raise
Adrian Buehlmann
introduce new function scmutil.readrequires...
r14482 requirements = set()
Thomas Arendsen Hein
Fix Debian bug #494889 (fetching from static-http://... broken)...
r7178 # check if it is a non-empty old-style repository
try:
Dan Villiom Podlaski Christiansen
explicitly close files...
r13400 fp = self.opener("00changelog.i")
fp.read(1)
fp.close()
Thomas Arendsen Hein
Fix Debian bug #494889 (fetching from static-http://... broken)...
r7178 except IOError, inst:
if inst.errno != errno.ENOENT:
raise
# we do not care about empty old-style repositories here
Dirkjan Ochtman
make static-http work with empty repos (issue965)
r6028 msg = _("'%s' does not appear to be an hg repository") % path
Matt Mackall
error: move repo errors...
r7637 raise error.RepoError(msg)
Benoit Boissinot
add "requires" file to the repo, specifying the requirements
r3851
# setup store
Adrian Buehlmann
store: remove pointless pathjoiner parameter...
r13426 self.store = store.store(requirements, self.path, opener)
Matt Mackall
statichttp: use store class...
r6897 self.spath = self.store.path
self.sopener = self.store.opener
self.sjoin = self.store.join
Idan Kamara
scmutil: update cached copy when filecached attribute is assigned (issue3263)...
r16115 self._filecache = {}
Benoit Boissinot
add "requires" file to the repo, specifying the requirements
r3851
Benoit Boissinot
introduce localrepo.spath for the store path, sopener fixes
r3791 self.manifest = manifest.manifest(self.sopener)
self.changelog = changelog.changelog(self.sopener)
Greg Ward
localrepo: rename in-memory tag cache instance attributes (issue548)....
r9146 self._tags = None
mpm@selenic.com
Separate out old-http support...
r1101 self.nodetagscache = None
Nicolas Dumazet
static-http: mimic more closely localrepo (issue2164: allow clone -r )...
r11066 self._branchcache = None
self._branchcachetip = None
Benoit Boissinot
cleanup of revlog.group when repository is local...
r1598 self.encodepats = None
self.decodepats = None
Martin Geisler
statichttprepo: use in-place difference for shorter line
r14519 self.capabilities.difference_update(["pushkey"])
mpm@selenic.com
Separate out old-http support...
r1101
Vadim Gelfer
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks...
r2673 def url(self):
Matt Mackall
Autodetect static-http
r7211 return self._url
Vadim Gelfer
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks...
r2673
mpm@selenic.com
Separate out old-http support...
r1101 def local(self):
return False
Vadim Gelfer
clean up hg.py: move repo constructor code into each repo module
r2740
Martin Geisler
do not pretend to lock static-http repositories (issue994)
r7005 def lock(self, wait=True):
raise util.Abort(_('cannot lock static-http repository'))
Vadim Gelfer
clean up hg.py: move repo constructor code into each repo module
r2740 def instance(ui, path, create):
if create:
raise util.Abort(_('cannot create new static-http repository'))
Thomas Arendsen Hein
Removed deprecated hg:// and old-http:// protocols (issue406)
r4853 return statichttprepository(ui, path[7:])