Commit Graph

493 Commits

Author SHA1 Message Date
Augie Fackler
5200764eb8 clone: don't fail with --update for non-local clones (issue3578)
This was broken by e01343f7da6f due to lack of test coverage. This
adds a test and fixes the defect.
2012-08-08 10:04:02 -05:00
Patrick Mezard
7221d12e58 discovery: add extinct changesets to outgoing.excluded
Before this change, push would incorrectly fast-path the bundle
generation when extinct changesets are involved, because they are not
added to outgoing.excluded. The reason to do so are related to
outgoing.excluded being assumed to contain only secret changesets by
scmutil.nochangesfound(), when displaying warnings like:

 changes found (ignored 9 secret changesets)

Still, outgoing.excluded seems like a good API to report the extinct
changesets instead of dedicated code and nothing in the docstring
indicates it to be bound to secret changesets. This patch adds extinct
changesets to outgoing.excluded and fixes scmutil.nochangesfound() to
filter the excluded node list.

Original version and test by Pierre-Yves.David@ens-lyon.org
2012-07-25 19:34:31 +02:00
Matt Harbison
0afe294dbc outgoing: accept revset argument for --rev
There may be a more generic way that would add revset support to more commands
by adding revset support to addbranchrevs(), but given the proximity of the next
code freeze, a minimal change seems like the better choice.
2012-07-15 12:43:10 -04:00
Sune Foldager
e82027e6f3 peer: remove cancopy from peer api; use directly on repo instead 2012-07-13 21:52:37 +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
Sune Foldager
ffe56435bf peer: introduce peer methods to prepare for peer classes
This introduces a peer method into all repository classes, which currently
simply returns self. It also changes hg.repository so it now raises an
exception if the supplied paths does not resolve to a localrepo or descendant.

Finally, all call sites are changed to use the peer and local methods as
appropriate, where peer is used whenever the code is dealing with a remote
repository (even if it's on local disk).
2012-07-13 21:46:53 +02:00
FUJIWARA Katsunori
204c7d4046 localrepo: use the path relative to "self.vfs" instead of "path" argument
As a part of migration to vfs, this patch uses "self.root", which can
be recognized as the path relative to "self.vfs", instead of "path"
argument.

This fix allows to make invocations of "util.makedirs()" and
"os.path.exists()" while ensuring repository directory in
"localrepository.__init__()" ones indirectly via vfs.

But this fix also raises issue 2528: "hg clone" with empty destination.

"path" argument is empty in many cases, so this issue can't be fixed
in the view of "localrepository.__init__()".

Before this patch, it is fixed by empty-ness check ("not name") of
exception handler in "util.makedirs()".

    try:
        os.mkdir(name)
    except OSError, err:
        if err.errno == errno.EEXIST:
            return
        if err.errno != errno.ENOENT or not name:
            raise

This requires "localrepository.__init__()" to invoke "util.makedirs()"
with "path" instead of "self.root", because empty "path" is treated as
"current directory" and "self.root" becomes valid path.

But "hg clone" with empty destination can be detected also in
"hg.clone()" before "localrepository.__init__()" invocation, so this
patch re-fixes issue2528 by checking it in "hg.clone()".
2012-07-06 18:45:27 +09:00
Brodie Rao
7f47d4e347 check-code: ignore naked excepts with a "re-raise" comment
This also promotes the naked except check from a warning to an error.
2012-05-13 13:18:06 +02:00
Thomas Arendsen Hein
5e3d9e57d7 clone: always close source repository (issue2491)
This is especially needed for cloning from bundles as a temporary
bundlerepository is created which needs to be deleted after clone has
finished.
2012-04-03 22:01:28 +02:00
Kevin Bullock
2e6b4bf150 bookmarks: clone non-divergent bookmarks with @ in them 2012-03-21 16:39:38 -05:00
Matt Mackall
684f6eea71 phases: fix verify with secret csets
Verify uses repo.cancopy() to detect whether a repo is a plain old
local repo, so it was giving a confusing error message when secret
changesets were present.
2012-01-29 13:36:10 -06:00
Matt Mackall
e4d11ad28c scmutil: unify some 'no changes found' messages
This keeps the wording more consistent for secret csets
2012-01-25 17:14:08 -06:00
Alain Leufroy
9a455ccd0e outgoing: display info about secret changets while no sharable changeset found 2012-01-25 19:41:34 +01:00
Matt Mackall
eb2ed976cb bookmarks: backout locking change in 31cb6aaf3b7a
Repo lock only applies to data in .hg/store/
2012-01-18 14:56:52 -06:00
Mads Kiilerich
50c2110b65 bookmarks: primarily use repo lock, not wlock
Bookmarks are repository data, not working directory data. Only the current
bookmark is working directory data.

Some lock shuffling is required to avoid lockout between the initial mock lock
and locking of the localrepo instance that is created after copying.
2012-01-13 02:30:43 +01:00
Pierre-Yves David
e929cd5e49 discovery: introduce outgoing object for result of findcommonoutgoing
Simplifies client logic in multiple places since it encapsulates the
computation of the common and, more importantly, the missing node lists.

This also allows an upcomping patch to communicate precomputed versions of
these lists to clients.
2012-01-09 03:47:16 +01:00
Pierre-Yves David
b57da0b2af phases: on copy clone, do not copy phases data if repote is publishing 2011-12-26 13:48:31 +01:00
Arne Babenhauserheide
eaac554b05 clone: get all bookmarks before updating 2011-11-04 10:18:40 +01:00
Augie Fackler
ca0638e3d0 clone: don't save user's password in .hg/hgrc (Issue3122) 2011-11-22 12:06:42 -06:00
Matt Mackall
b066b57e3c backout 17bc9a6bb165 (issue3077) (issue3071)
Using util.realpath turns out to create complex issues on both Mac and
Windows. Back this change out for the release.
2011-10-29 11:02:23 -05:00
Thomas Arendsen Hein
51c498ead0 consistency: use util.realpath instead of os.path.realpath where useful
exceptions:
  hg: os.path.realpath used before util can be imported
  tests/run-tests.py: may not import mercurial modules
2011-10-24 13:51:24 +02:00
Simon Heimberg
f88e344226 hg: extract copying the store out of clone 2011-08-11 00:03:16 +02:00
Augie Fackler
8437ff81d4 hg: use safehasattr instead of hasattr 2011-07-25 15:22:18 -05:00
Idan Kamara
342150de40 peer: change arg name to convey it can be a repo as well 2011-07-05 14:28:55 +03:00
Mads Kiilerich
e8138203dd util: rename the util.localpath that uses url to urllocalpath (issue2875)
util is never imported by any other name than util, so this is mostly just a
simple search and replace from util.localpath to util.urllocalpath (assuming
other uses of util.localpath already has been renamed).
2011-07-01 17:37:09 +02:00
David Golub
3605e62f7c call reposetup for repositories returned from peer (issue2864)
Extension setup functions were not being called when repositories were
obtained using the peer function instead of the repository function.
2011-06-24 11:39:12 -04:00
Martin Geisler
7e528c7c9a hg: rename opts argument to peeropts in clone
This should make it clearer that the options are used with remoteui
only and are not used otherwise in hg.clone.
2011-06-14 16:33:46 +02:00
Matt Mackall
f0bc90519a hg: move peerschemes back to schemes
This will avoid breaking things with extensions until peers are fully
separated from repos.
2011-06-13 16:25:18 -05:00
Matt Mackall
f241322d80 hg: rearrange peer scheme lookup
There is now only peer scheme lookup. Repository lookup goes through
peer scheme lookup. When peer and repo types are finally separated,
repo lookup will use peer.local() to get a repository object.

The underbar is dropped so that extensions can patch the table.
2011-06-13 14:53:23 -05:00
Matt Mackall
aa85ea1250 hg: split peer and repo lookup tables 2011-06-11 14:14:52 -05:00
Matt Mackall
efecb99535 hg: change various repository() users to use peer() where appropriate
This gets all the easy cases (peers that aren't also used as repositories).
2011-06-10 11:43:38 -05:00
Matt Mackall
d049d4f6ce hg: have peer() call _lookup directly
Note that this means that peers no longer call the extension
repository setup hooks.
2011-06-10 11:43:38 -05:00
Matt Mackall
5f2e38a0df hg: add peer method 2011-06-10 11:43:38 -05:00
Peter Arrenbrecht
d836ee3cea hg: add opts argument to clone for internal remoteui 2011-06-08 18:24:33 +02:00
Peter Arrenbrecht
66eeabddd2 hg: use capable instead of capabilities 2011-06-06 21:18:35 +02:00
Martin Geisler
4cb518e9a1 hg: remove underscores in clone function 2011-05-27 12:42:36 +02:00
Brendan Cully
b1b428c2d8 clone: make default path absolute for all local paths
This fixes the default path when cloning local repositories with hg-git, since
hg-git cancopy() is false even for local repositories.
2011-05-18 23:20:26 -07:00
Peter Arrenbrecht
d4abc4d642 discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks
discovery.findoutgoing used to be a useful hook for extensions like
hgsubversion. This patch reintroduces this version of findcommonincoming
which is meant to be used when computing outgoing changesets.
2011-05-06 14:44: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
Peter Arrenbrecht
66c54cef75 bundlerepo: fix and improve getremotechanges
Fixes the regression where incoming could show local changes
introduced by rev eecf03f0ef7c.
2011-05-02 12:36:23 +02:00
Dan Villiom Podlaski Christiansen
a563dca62b share: create 'hgrc' using an opener, like clone 2011-05-01 18:43:20 +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
Peter Arrenbrecht
b867e650e6 discovery: drop findoutgoing and simplify findcommonincoming's api
This is a long desired cleanup and paves the way for new discovery.
To specify subsets for bundling changes, all code should use the heads
of the desired subset ("heads") and the heads of the common subset
("common") to be excluded from the bundled set. These can be used
revlog.findmissing instead of revlog.nodesbetween.

This fixes an actual bug exposed by the change in test-bundle-r.t
where we try to bundle a changeset while specifying that said changeset
is to be assumed already present in the target. This used to still
bundle the changeset. It no longer does. This is similar to the bugs
fixed by the recent switch to heads/common for incoming/pull.
2011-04-30 17:21:37 +02:00
Alexander Solovyov
0eb3836642 remove unused imports and variables 2011-04-30 13:59:14 +02:00
Idan Kamara
762d333ae9 eliminate various naked except clauses 2011-04-23 00:51:25 +03:00
Thomas Arendsen Hein
1b0518593c hg: make parseurl() consistently return normalised path
Before this the path was only normalised when a fragment was used.
2011-04-06 12:48:59 +02:00
Brodie Rao
3a43fa887e url: refactor util.drop_scheme() and hg.localpath() into url.localpath()
This replaces util.drop_scheme() with url.localpath(), using url.url for
parsing instead of doing it on its own. The function is moved from
util to url to avoid an import cycle.

hg.localpath() is removed in favor of using url.localpath(). This
provides more consistent behavior between "hg clone" and other
commands.

To preserve backwards compatibility, URLs like bundle://../foo still
refer to ../foo, not /foo.

If a URL contains a scheme, percent-encoded entities are decoded. When
there's no scheme, all characters are left untouched.

Comparison of old and new behaviors:

URL                      drop_scheme()   hg.localpath()    url.localpath()
===                      =============   ==============    ===============
file://foo/foo           /foo            foo/foo           /foo
file://localhost:80/foo  /foo            localhost:80/foo  /foo
file://localhost:/foo    /foo            localhost:/foo    /foo
file://localhost/foo     /foo            /foo              /foo
file:///foo              /foo            /foo              /foo
file://foo               (empty string)  foo               /
file:/foo                /foo            /foo              /foo
file:foo                 foo             foo               foo
file:foo%23bar           foo%23bar       foo%23bar         foo#bar
foo%23bar                foo%23bar       foo%23bar         foo%23bar
/foo                     /foo            /foo              /foo

Windows-related paths on Windows:

URL                      drop_scheme()   hg.localpath()    url.localpath()
===                      =============   ==============    ===============
file:///C:/foo           C:/C:/foo       /C:/foo           C:/foo
file:///D:/foo           C:/D:/foo       /D:/foo           D:/foo
file://C:/foo            C:/foo          C:/foo            C:/foo
file://D:/foo            C:/foo          D:/foo            D:/foo
file:////foo/bar         //foo/bar       //foo/bar         //foo/bar
//foo/bar                //foo/bar       //foo/bar         //foo/bar
\\foo\bar                //foo/bar       //foo/bar         \\foo\bar

Windows-related paths on other platforms:

file:///C:/foo           C:/C:/foo       /C:/foo           C:/foo
file:///D:/foo           C:/D:/foo       /D:/foo           D:/foo
file://C:/foo            C:/foo          C:/foo            C:/foo
file://D:/foo            C:/foo          D:/foo            D:/foo
file:////foo/bar         //foo/bar       //foo/bar         //foo/bar
//foo/bar                //foo/bar       //foo/bar         //foo/bar
\\foo\bar                //foo/bar       //foo/bar         \\foo\bar

For more information about file:// URL handling, see:
http://www-archive.mozilla.org/quality/networking/testing/filetests.html

Related issues:

- issue1153: File URIs aren't handled correctly in windows

  This patch should preserve the fix implemented in
  5c92d05b064e. However, it goes a step further and "promotes"
  Windows-style drive letters from being interpreted as host names to
  being part of the path.

- issue2154: Cannot escape '#' in Mercurial URLs (#1172 in THG)

  The fragment is still interpreted as a revision or a branch, even in
  paths to bundles. However, when file: is used, percent-encoded
  entities are decoded, so file:test%23bundle.hg can refer to
  test#bundle.hg ond isk.
2011-03-30 20:03:05 -07:00
Brodie Rao
00a75e8663 hg: use url.url to parse branch names in parseurl() 2011-03-30 20:02:09 -07:00
Brodie Rao
9b6a7577e1 hg: look up schemes using url.url 2011-03-30 20:02:07 -07:00
Adrian Buehlmann
92624f7391 set NOT_CONTENT_INDEXED on .hg dir (issue2694)
when running on Windows
2011-03-28 15:54:22 +02:00