Commit Graph

32 Commits

Author SHA1 Message Date
Matt Mackall
b7afbe529a streamclone: allow uncompressed clones by default 2010-02-07 15:31:53 +01:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Benoit Boissinot
124669d7e0 sshrepo: move mkstemp() out of the try block, we don't use the exception
simpler fix for 434f13ccc1f6
2009-11-07 13:25:25 +01:00
Dirkjan Ochtman
d1740999b1 hgweb/sshserver: extract capabilities for easier modification 2009-11-05 11:07:01 +01:00
Martin Geisler
ae0794fd45 coding style: use a space after comma
I left a cases like 'lambda x,y:' alone -- the lack of a space does
not bother me as much when the variables are single letters.
2009-07-22 23:12:54 +02:00
Henrik Stuart
e3379206dc named branches: server branchmap wire protocol support (issue736)
The repository command, 'branchmap', returns a dictionary, branchname
-> [branchheads], and will be implemented for localrepo, httprepo and
sshrepo.

The following wire format is used for returning data:

branchname1 branch1head2 branch1head2 ...
branchname2 ...
...

Branch names are URL encoded to escape white space, and branch heads
are sent as hex encoded node ids. All branches and all their heads are
sent.

The background and motivation for this command is the desire for a
richer named branch semantics when pushing changesets. The details are
explained in the original proposal which is included below.


1. BACKGROUND

The algorithm currently implemented in Mercurial only considers the
graph theoretical heads when determining whether new heads are
created, rather than using the branch heads as a count (the algorithm
considers a branch head effectively closed when it is merged into
another branch or a new named branch is started from that point
onward).

Our particular problem with the algorithm is that we'd like to see the
following case working without forcing a push:

Upsteam has:

(0:dev) ---- (1:dev)
\
 `--- (2:stable)

Someone merges stable into dev:

(0:dev) ---- (1:dev) ------(3:dev)
\                         /
 `--- (2:stable) --------´

This can be pushed without --force (as it should).
Now someone else does some coding on stable (a bug fix, say):

(0:dev) ---- (1:dev) ------(3:dev)
\                          /
 `--- (2:stable) ---------´---------(4:stable)

This time we need --force to push.

We allow this to be pushed without using --force by getting all the
remote branch heads (by extending the wire protocol with a new
function).

We would, furthermore, also prefer if it is impossible to push a new
branch without --force (or a later --newbranch option so --force isn't
shoe-horned into too many disparate functions, if need be), except of
course in the case where the remote repository is empty.

This is what our patches accomplish.


2. ALTERNATIVES

We have, of course, considered some alternatives to reconstructing
enough information to decide whether we are creating new remote branch
heads, before we added the new wire protocol command.

2.1. LOOKUP ON REMOTE

The main alternative is to use the information from remote.heads() and
remote.lookup() to try to reconstruct enough graph information to
decide whether we are creating new heads. This is not adequate as
illustrated below.

Remember that each lookup is typically a request-response pair over
SSH or HTTP(S).

If we have a simple repository at the remote end like this:

(0:dev) ---- (1:dev) ---- (3:stable)
\
 `--- (2:dev)

then remote.heads() will yield [2, 3]. Assume we have nodes [0, 1, 2]
locally and want to create a new node, 4:dev, as a descendant from
(1:dev), which should be OK as 1:dev is a branch head.

If we do remote.lookup('dev') we will get [2]. Thus, we can get
information about whether a branch exists on the remote server or not,
but this does not solve our problem of figuring out whether we are
creating new heads or not.

Pushing 4:dev ought to be OK, since after the push, we still only have
two heads on branch a.

Using remote.lookup() and remote.heads() is thus not adequate to
consistently decide whether we are creating new remote heads (e.g. in
this situation the latter would never return 1:dev).

2.2. USING INCOMING TO RECONSTRUCT THE GRAPH

An alternative would be to use information equivalent to hg incoming
to get the full remote graph in addition to the local graph.

To do this, we would have to get a changegroup(subset) bundle
representing the remote end (which may be a substantial amount of
data), getting the branch heads from an instantiated bundlerepository,
deleting the bundle, and finally, we can compute the prepush logic.

While this is backwards compatible, it will cause a possibly
substantial slowdown of the push command as it first needs to pull in
all changes.


3. FURTHER ARGUMENTS IN FAVOUR OF THE BRANCHMAP WIRE-PROTOCOL EXTENSION

Currently, the commands incoming and pull, work based on the tip of a
given branch if used with "-r branchname", making it hard to get all
revisions of a certain branch only (if it has multiple heads). This
can be solved by requesting the remote's branchheads and letting the
revisions to be used with the command be these heads. This can be done
by extending the commands with a new option, e.g.:

hg pull -b branchname

which will be turned into the equivalent of:

hg pull -r branchhead1 -r branchhead2 -r branchhead3

We have a simple follow-up patch that can do this ready as well
(although not submitted yet as it is pending the acceptance of the
branch patch).


4. WRAP-UP

We generally find that the branchmap wire protocol extension can
provide better named branch support to Mercurial. Currently, some
things, like the initial push scenario in this mail, are fairly
counter-intuitive, and the more often you have to force push, the more
it is likely you will get a lot of spurious and unnecessary merge
nodes. Also, restricting incoming and pull to all changes on a branch
rather than changes on the tip-most head would be a sensible extension
to making named branches a first class citizen in Mercurial.
Currently, named branches sometimes feel like a late-coming unwanted
step-child.

We have run it in a production environment for a while, with fewer
multiple heads occurring in our repositories and fewer confused users
as a result.

Also, it fixes the long-standing issue 736.

Co-contributor: Sune Foldager <cryo@cyanite.org>
2009-05-23 17:02:49 +02:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Ronny Pfannschmidt
5356baa346 switch lock releasing in the core from gc to explicit 2009-04-22 02:01:22 +02:00
Peter Arrenbrecht
19591b6a8c cleanup: drop unused assignments 2009-03-23 13:13:06 +01:00
Dirkjan Ochtman
ecc1ada3d6 make streamclone.stream_out() a generator 2008-08-15 13:25:57 +02:00
Thomas Arendsen Hein
0299adbd70 sshserver: Don't try to close fp if mkstemp failed 2008-04-23 11:40:33 +02:00
Joel Rosdahl
5dae3059a0 Expand import * to allow Pyflakes to find problems 2008-03-06 22:23:26 +01:00
Matt Mackall
f277b2676b hook: redirect stdout to stderr for ssh and http servers 2008-01-11 13:06:38 -06: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
Eric Hopper
68a9f0d42a sshrepo: add passing of lookup exceptions 2006-09-09 18:25:06 -07:00
Eric Hopper
cab8740b9b Adding changegroupsubset and lookup to ssh protocol so pull -r and
clone -r can be supported.
2006-09-09 18:25:06 -07:00
Thomas Arendsen Hein
0a7b982aa6 Whitespace/Tab cleanup 2006-10-01 19:26:33 +02:00
Vadim Gelfer
dc377b58c1 update copyrights. 2006-08-12 12:30:02 -07:00
Vadim Gelfer
0778999161 hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
all repository classes now have url() method that returns url of repo.
2006-07-25 13:50:32 -07:00
Vadim Gelfer
a7bbf7d88f rename stream hgrc option to compressed. 2006-07-16 10:04:16 -07:00
Vadim Gelfer
f7b6882acb clone: disable stream support on server side by default.
enable in hgrc like this:
[server]
stream=True
2006-07-15 16:06:35 -07:00
Vadim Gelfer
9ea4436262 add support for streaming clone.
existing clone code uses pull to get changes from remote repo.  is very
slow, uses lots of memory and cpu.

new clone code has server write file data straight to client, client
writes file data straight to disk.  memory and cpu used are very low,
clone is much faster over lan.

new client can still clone with pull, can still clone from older servers.
new server can still serve older clients.
2006-07-14 11:17:22 -07:00
Vadim Gelfer
9117f9f380 extend network protocol to stop clients from locking servers
now all repositories have capabilities slot, tuple with list of names.

if 'unbundle' capability present, repo supports push where client does
not need to lock server.  repository classes that have unbundle capability
also have unbundle method.

implemented for ssh now, will be base for push over http.

unbundle protocol acts this way.  server tells client what heads it
has during normal negotiate step.  client starts unbundle by repeat
server's heads back to it.  if server has new heads, abort immediately.
otherwise, transfer changes to server.  once data transferred, server
locks and checks heads again.  if heads same, changes can be added.
else someone else added heads, and server aborts.

if client wants to force server to add heads, sends special heads list of
'force'.
2006-06-15 16:37:23 -07:00
Matt Mackall
3debcf9f86 Initial implementation of hello command for ssh 2006-06-09 17:47:38 -05:00
Vadim Gelfer
d2bc16b368 fix comment. 2006-06-04 10:32:13 -07:00
Vadim Gelfer
fd56f76ec7 merge change to ssh protocol. 2006-06-04 10:29:34 -07:00
Vadim Gelfer
c57ade3a95 refactor ssh server. 2006-06-04 10:26:05 -07:00