Commit Graph

62 Commits

Author SHA1 Message Date
Sune Foldager
7045c35403 peer: introduce canpush and improve error message 2012-07-13 21:52:28 +02:00
Peter Arrenbrecht
ef7b77046e peer: introduce real peer classes
This change separates peer implementations from the repository implementation.
localpeer currently is a simple pass-through to localrepository, except for
legacy calls, which have already been removed from localpeer. This ensures that
the local client code only uses the most modern peer API when talking to local
repos.

Peers have a .local() method which returns either None or the underlying
localrepository (or descendant thereof). Repos have a .peer() method to return
a freshly constructed localpeer. The latter is used by hg.peer(), and also to
allow folks to pass either a peer or a repo to some generic helper methods.
We might want to get rid of .peer() eventually.

The only user of locallegacypeer is debugdiscovery, which uses it to pose as a
pre-setdiscovery client. But we decided to leave the old API defined in
locallegacypeer for clarity and maybe for other uses in the future.

It might be nice to actually define the peer API directly in peer.py as stub
methods. One problem there is, however, that localpeer implements
lock/addchangegroup, whereas the true remote peers implement unbundle.
It might be desireable to get rid of this distinction eventually.
2012-07-13 21:47:06 +02:00
FUJIWARA Katsunori
dad1f854dd localrepo: add "vfs" fields to "localrepository" for migration from "opener"
As a part of migration to vfs, this patch adds "vfs" fields to
"localrepository" class.

This allows new codes to access current "opener" objects related to
repositories via "vfs" fields, so patches referring to "vfs" will
replace referring to "opener" in time.

This patch also adds initializations for "vfs" fields to
"statichttprepository" class derived from it, because its constructor
doesn't invoke the constructor of "localrepository", so "vfs" fields
should be initialized explicitly as same as "opener" fields: it has no
working directory, so "wvfs" field is not added.
2012-07-06 18:45:26 +09:00
Alexander Boyd
dbb21eba13 statichttprepo: don't send Range header when requesting entire file
When requesting files using statichttprepo.httprangereader, a request for the
entire file is sent with a Range: bytes=0- header. This causes problems with
web servers such as Cherokee that return an HTTP 416 when an empty file is
requested in this way, which in turn cause some repository clone attempts to
fail. This patch omits the Range header when the entire file is being
requested, which fixes the problem.
2012-06-09 19:13:24 -06:00
Idan Kamara
f729c0ef8a scmutil: update cached copy when filecached attribute is assigned (issue3263)
When assigning a new object to filecached properties, the cached object that
was kept in the _filecache map was still holding the old object.

By implementing __set__, we track these changes too and update the cached
copy as well.
2012-02-15 20:02:35 +02:00
Pierre-Yves David
7448ca3281 phases: mechanism to allow extension to alter initial computation of phase
This commit add a whennodata list where extension can register a callback to be
called if no phase related data are found in the repository.

The goal is to ensure the existing extension that move phase data in 2.1 can
compute consistent phase boundary for existing repo.
2012-01-18 17:23:54 +01:00
Augie Fackler
b6e6839631 statichttprepo: replace hasattr with getattr 2011-07-25 15:47:43 -05:00
Idan Kamara
1c37933f72 localrepo: add a cache with stat info for files under .hg/ 2011-07-25 15:08:37 +03:00
Martin Geisler
94d9d879d7 statichttprepo: use in-place difference for shorter line 2011-06-03 20:08:26 +02:00
Adrian Buehlmann
924c56c606 introduce new function scmutil.readrequires
for reading and parsing the .hg/requires file
2011-05-31 19:16:18 +02:00
Dan Villiom Podlaski Christiansen
511c941422 prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.

This implies:
 - changing opener(...).read() calls to opener.read(...)
 - changing opener(...).write() calls to opener.write(...)
 - changing open(...).read(...) to util.readfile(...)
 - changing open(...).write(...) to util.writefile(...)
2011-05-02 10:11:18 +02:00
Dan Villiom Podlaski Christiansen
6fdf8d9352 statichttprepo: make the opener a subclass of abstractopener 2011-04-30 19:41:25 +02:00
Brodie Rao
b7f0d2a103 url: move URL parsing functions into util to improve startup time
The introduction of the new URL parsing code has created a startup
time regression. This is mainly due to the use of url.hasscheme() in
the ui class. It ends up importing many libraries that the url module
requires.

This fix helps marginally, but if we can get rid of the urllib import
in the URL parser all together, startup time will go back to normal.

perfstartup time before the URL refactoring (707e4b1e8064):

! wall 0.050692 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)

current startup time (9ad1dce9e7f4):

! wall 0.070685 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)

after this change:

! wall 0.064667 comb 0.000000 user 0.000000 sys 0.000000 (best of 100)
2011-04-30 09:43:20 -07:00
Brodie Rao
de32ed5320 httprepo/sshrepo: use url.url
Like the previous patch to getauthinfo(), this also makes
username/password parsing more forgiving for SSH URLs.

This also opens up the possibility of allowing non-numeric ports,
since the URL parser has no problem handling them.

Related issues:

- issue851: @ in password in http url
- issue2055: nonnumeric port bug with https protocol
2011-03-30 20:01:35 -07:00
Adrian Buehlmann
8f9b06619f statichttprepo: abort if opener mode is 'r+' or 'rb+'
The old version of the check failed to catch
modifying modes 'r+' and 'rb+'.
2011-02-18 01:19:01 +01:00
Adrian Buehlmann
a8a418601f introduce new RequirementError (issue2649)
This improves the misleading error message

  $ hg identify
  abort: there is no Mercurial repository here (.hg not found)!

to the more explicit

  $ hg identify
  abort: requirement 'fake' not supported!

for all commands in commands.optionalrepo, which includes the identify
and serve commands in particular.

This is for the case when a new entry in .hg/requires will be defined
in a future Mercurial release.
2011-02-18 20:25:25 +01:00
Mads Kiilerich
b6559c7bf6 statichttprepo: don't modify localrepo class variables
This happened to crash in subrepo setups when the base class variable was
modified twice.

Now we don't modify the class variable but an instance copy.
2011-02-18 23:41:13 +01:00
Adrian Buehlmann
82c4b3eebe store: remove pointless pathjoiner parameter
We can stop pretending that we have to support anything else
than '/' for concatenating path elements anywhere.

Windows deals just fine with '/' in file paths and we already
have plenty of places which produce paths containing '/'
anyway when running on Windows.
2011-02-16 15:02:30 +01:00
Dan Villiom Podlaski Christiansen
ec590d5cd4 explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
2010-12-24 15:23:01 +01:00
Matt Mackall
efaaee2894 revlog: remove lazy index 2011-01-04 14:12:52 -06:00
Matt Mackall
c5711377a4 statichttprepo: disable pushkey 2010-08-24 13:13:35 -05:00
Matt Mackall
94c9deabbe static-http: disable lazy parsing
This only hits if you're crazy enough to use static-http on a
repository with revlogs larger than 1M. Don't do it.
2010-05-11 16:28:09 -05:00
Nicolas Dumazet
09283d5a0c static-http: mimic more closely localrepo (issue2164: allow clone -r )
* httprangereader: name, __iter__ and close are needed to mimic file object
* static-http opener:
    - disallow write/append modes
    - add (unused) atomictemp parameter
* static-http repo:
    - root attribute is needed for localrepo.dirstate()
    - _branch* attributes are required for commitctx and branchmap calls
* tags: force repo.opener.__iter__ call earlier to force httprangereader
  to try to read the cache early, to avoid raising IOError later.
2010-04-26 20:13:14 +09:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Greg Ward
37b1525e95 localrepo: rename in-memory tag cache instance attributes (issue548).
- self.tagscache to self._tags
- self._tagstypecache to self._tagtypes
- this is for consistency, readability, privacy, and to subtly hint
  that "caching" is something else
2009-07-16 10:39:41 -04:00
Patrick Mezard
945857d352 statichttprepo: handle remote not supporting Range headers
- If remote does not support Range header, 200 is answered instead of 206. The
  HTTPRangeHandler left these responses unchanged, so the data has to be sliced
  by the receiver.
- httprangereader file pointer was not updated.
2009-05-24 18:31:01 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Peter Arrenbrecht
bc21361ed2 cleanup: drop unused imports 2009-03-23 13:12:07 +01:00
Matt Mackall
e0735a1762 error: move repo errors
rename NoCapability to CapabilityError
2009-01-12 10:42:31 -06:00
Benoit Boissinot
15ec41ce13 statichttprepo: cleanups, use url.py (proxy, password support)
- unify httprangereader.py and statichttprepo.py:rangegreader()
- build the opener from url.py, that allows use to puse username and password
  in the url, to follow the proxy settings from hgrc, etc.
2008-10-28 08:26:18 +01:00
Matt Mackall
e617903e64 Autodetect static-http 2008-10-22 15:41:32 -05:00
Thomas Arendsen Hein
28f8d4bb8e merge with crew-stable 2008-10-19 22:07:43 +02:00
Thomas Arendsen Hein
94f908042c Fix Debian bug #494889 (fetching from static-http://... broken)
Changeset 055df4ac4b13 which fixed issue965 (hg clone static-http
does not work for empty repos) broke cloning of repos with old layout
(without store) via static-http.

This fix makes cloning from old-style repositories possible again,
but will not allow cloning of empty old-style repositories as this
can not be detected reliably.
2008-10-19 19:49:56 +02:00
Martin Geisler
ca8bba4890 do not pretend to lock static-http repositories (issue994) 2008-09-08 11:32:53 +02:00
Adrian Buehlmann
d71509e706 Fix for Issue1260 2008-08-31 00:22:20 +02:00
Matt Mackall
eac969c591 statichttp: use store class
This lets us nix store.encodefn.
2008-08-13 20:18:43 -05:00
Adrian Buehlmann
904617b7d8 introduce store classes
move store walking from streamclone.py into store.py
2008-07-24 16:32:52 +02:00
Adrian Buehlmann
34afc460b4 move filename encoding functions from util.py to new store.py 2008-07-24 16:32:51 +02:00
Matt Mackall
cfa4e83bd1 repo classes: remove unused dev() method 2008-03-20 11:12:35 -05:00
Joel Rosdahl
4f8012378a Remove unused imports 2008-03-06 22:23:41 +01:00
Dirkjan Ochtman
3539f58d90 make static-http work with empty repos (issue965) 2008-02-08 11:50:37 +01:00
Patrick Mezard
f770ac70cd Merge with crew-stable 2007-09-22 18:56:36 +02:00
Paul Bx
ab0ccce138 statichttprepo: fix calls on '/' URI (issue 747) 2007-09-22 18:37:35 +02:00
Thomas Arendsen Hein
d486a44410 Removed deprecated hg:// and old-http:// protocols (issue406) 2007-07-08 09:54:42 +02:00
Thomas Arendsen Hein
4d29c6dc8e Updated copyright notices and add "and others" to "hg version" 2007-06-19 08:51:34 +02:00
Matt Mackall
04561e556e revlog: simplify revlog version handling
- pass the default version as an attribute on the opener
- eliminate config option mess
2007-03-22 19:52:38 -05:00
Matt Mackall
296d6a7cb8 Simplify i18n imports 2006-12-14 20:25:19 -06:00
Matt Mackall
f17a4e1934 Replace demandload with new demandimport 2006-12-13 13:27:09 -06:00
Benoit Boissinot
e5024feef0 fix errors spotted by pychecker 2006-12-10 19:41:57 +01:00
Benoit Boissinot
e005ffc8c4 switch to the .hg/store layout, fix the tests 2006-12-01 13:34:09 +01:00