Commit Graph

71 Commits

Author SHA1 Message Date
Pierre-Yves David
bb4442ac82 statichttp: respect localrepo _restrictcapabilities
The static http repository was doing his own filtering of capability ignoring
the filtering done in the local repo main class. This led to static http using
the current draft of bundle2. We now apply both.
2014-04-07 11:45:50 -07:00
Siddharth Agarwal
a70310c09e statichttprepo.httprangeheader: implement readlines
bookmarks.readcurrent() requires readlines() on file objects returned from
repo.vfs. It isn't used right now but will be in upcoming patches.
2013-11-17 13:31:18 -08:00
Siddharth Agarwal
b1f5a2bec5 statichttprepo: pass in True to splitlines, not 1
splitlines actually takes a boolean.
2013-11-17 13:28:11 -08:00
FUJIWARA Katsunori
c1e7da5d4f localrepo: make supported features manageable in each repositories individually
Before this patch, all localrepositories support same features,
because supported features are managed by the class variable
"supported" of "localrepository".

For example, "largefiles" feature provided by largefiles extension is
recognized as supported, by adding the feature name to "supported" of
"localrepository".

So, commands handling multiple repositories at a time like below
misunderstand that such features are supported also in repositories
not enabling corresponded extensions:

  - clone/pull from or push to localhost
  - recursive execution in subrepo tree

"reposetup()" can't be used to fix this problem, because it is invoked
after checking whether supported features satisfy ones required in the
target repository.

So, this patch adds the set object named as "featuresetupfuncs" to
"localrepository" to manage hook functions to setup supported features
of each repositories.

If any functions are added to "featuresetupfuncs", they are invoked,
and information about supported features is managed in each
repositories individually.

This patch also adds checking below:

  - pull from localhost: whether features supported in the local(= dst)
    repository satisfies ones required in the remote(= src)

  - push to localhost: whether features supported in the remote(= dst)
    repository satisfies ones required in the local(= src)

Managing supported features by the class variable means that there is
no difference of supported features between each instances of
"localrepository" in the same Python process, so such checking is not
needed before this patch.

Even with this patch, if intermediate bundlefile is used as pulling
source, pulling indirectly from the remote repository, which requires
features more than ones supported in the local, can't be prevented,
because bundlefile has no information about "required features" in it.
2013-09-21 21:33:29 +09:00
Bryan O'Sullivan
e689a5b672 statichttprepo: add missing import of os
Found using Cython.
2013-04-12 17:17:05 -07:00
Pierre-Yves David
0cd9115520 branchmap: enable caching for filtered version too
The `_branchcache` attribute is turned into a dictionary. Key are filter name and
value is a `branchcache` object. Unfiltered version is cached as `None` filter.

The attribute is renamed to `_branchcaches` to avoid confusion with the previous
one. Both old and new contents are dictionary even if their contents are
different. I prefer possible extension code to crash right away instead of just
messing the wrong dictionary.

As all different caches work isolated to each other, this code keeps the
previous behavior of using the unfiltered cache  we nothing is filtered.  This
is a cheap way to have cache collaborate and nullify potential impact in the
default case.
2012-12-24 03:21:15 +01:00
Pierre-Yves David
72ccce9263 branchmap: add the tipnode (cache key) on the branchcache object
Gathering data and cache key paves the way to a lot of simplification.
2012-12-22 01:59:05 +01:00
FUJIWARA Katsunori
f503d56231 vfs: define "join()" in each classes derived from "abstractvfs"
This patch defines "join()" in each classes derived from "abstractvfs"
except "vfs", which already defines it.

This allows all vfs instances to be used for indirect file API
invocation.
2012-10-09 01:41:55 +09:00
FUJIWARA Katsunori
97278fdfa7 scmutil: rename classes from "opener" to "vfs"
For backwards compatibility, aliases for the old names are added,
except for "abstractopener", "statichttpopener" and "_fncacheopener",
because these are not used in Mercurial core implementation after this
patch.

"_fncacheopener" was only referred in "fncachestore" constructor, so
this patch also renames from "_fncacheopener" to "_fncachevfs" there.
2012-08-31 02:06:29 +09:00
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