Commit Graph

109 Commits

Author SHA1 Message Date
Pierre-Yves David
3e8a941a87 checkheads: extract obsolete post processing in its own function
The checkheads function is long and complex, extract that logic in a subfunction
is win in itself. As the comment in the code says, this postprocessing is
currently very basic and either misbehave or fails to detect valid push in many
cases. My deeper motive for this extraction is to be make it easier to provide
extensive testing of this case and strategy to cover them. Final test and logic
will makes it to core once done.
2017-03-21 23:30:13 +01:00
timeless
a57e86590a discovery: use single quotes in use warning 2016-09-20 23:47:30 +00:00
Ryan McElroy
78bbaf76bd discovery: explicitly check for None in outgoing init
c8fefe878a71 introduced default params for discovery.outgoing(), but it used a
falsy check instead of an explicit check for None. The result is that callers
that passed in an empty list would have that list overridden by the defaults,
which is not the expected behavior.

This was discovered by changes to the test-pushrebase.t test in Facebook's
repository of mercurial extensions.
2016-09-06 09:43:25 -07:00
Pierre-Yves David
cca37f1814 outgoing: add a 'missingroots' argument
This argument can be used instead of 'commonheads' to determine the 'outgoing'
set. We remove the outgoingbetween function as its role can now be handled by
'outgoing' itself.

I've thought of using an external function instead of making the constructor
more complicated. However, there is low hanging fruit to improve the current
code flow by storing some side products of the processing of 'missingroots'. So
in my opinion it make senses to add all this to the class.
2016-08-09 22:31:38 +02:00
Pierre-Yves David
a9e69178e3 outgoing: adds some default value for argument
We are about to introduce a third option to create an outgoing object:
'missingroots'. This argument will be mutually exclusive with 'commonheads' so
we implement some default value handling in preparation.

This will also help use to make more use of outgoing creation around the code
base.
2016-08-09 15:55:44 +02:00
Pierre-Yves David
f460bb8823 outgoing: pass a repo object to the constructor
We are to introduce more code constructing such object in the code base. It will
be more convenient to pass a repository object, all current users already
operate at the repository level anyway. More changes to the contructor argument
are coming in later changeset.
2016-08-09 15:26:53 +02:00
Gregory Szorc
9f5f743c8a discovery: move code to create outgoing from roots and heads
changegroup.changegroupsubset() contained somewhat low-level code for
constructing an "outgoing" instance from a list of roots and heads
nodes. It feels like discovery.py is a more appropriate location for
this code.

This code can definitely be optimized, as outgoing.missing will
recompute the set of changesets we've already discovered from
cl.between(). But code shouldn't be refactored during a move, so
I've simply inserted a TODO calling attention to that.
2016-08-03 22:07:52 -07:00
liscju
6d9c9237d1 bookmarks: allow pushing active bookmark on new remote head (issue5236)
Before 'hg push -B .' on new remote head complained with:
abort: push creates new remote head ...

It was because _nowarnheads was not expanding active bookmark
name, so it didn't add active bookmark "proper" name to no
warn heads list.
2016-05-24 23:36:27 +02:00
Ryan McElroy
3f80624a78 discovery: pass pushop to _nowarnheads
Previously, we passed only enough information to _nowarnheads to perform the old
calculation. However, extensions may want to use more information in this
calculation. Now that pushop is extensible, extensions will often want access
to the additional fields they have added to the pushop, so pass that through.

Specifically, the remotenames extension will use this information to allow
pushing new heads that are bookmarked without requiring --force.
2015-11-10 11:16:25 -08:00
Ryan McElroy
f7b3bc72e8 exchange: pass pushop to discovery.checkheads
Previously, we passed a bunch of parameters to discovery.checkheads, but all
of the arguments can be fetched out of pushop, which may contain a lot more
useful information for extensions now that pushop is extensible.
2015-11-10 11:13:21 -08:00
Ryan McElroy
4e01fb3c0d discovery: factor out calculation of heads to not warn about
In addition to taking a step towards getting an unreasonably large function
factored into smaller, more manageable functions, this will allow extensions
such as remotenames have more control over what pushes are allowed or not.
2015-11-06 09:48:24 -08:00
Matt Mackall
afeb6dfab1 bookmarks: don't allow pushing new head for existing mark with -B (issue4400) 2015-10-21 16:21:27 -05:00
Pierre-Yves David
fb6955396c discovery: put trivial branch first
Having the simple and tiny branch of the conditional first help readability. The
"else" that appears after a screen of code is harder to relate to a conditional.
2015-10-12 00:45:24 -07:00
Pierre-Yves David
501c6cbdbc discovery: reference relevant bug in the faulty code
We extend the comment about this code flaw with more code flaw.
2015-10-09 15:44:00 -07:00
Pierre-Yves David
38aa2ec3c6 discovery: fix a typo in a comment
The idea here is that the code is imperfect, not that it is impossible to get
something behaving properly.
2015-10-09 15:37:05 -07:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Pierre-Yves David
3f7eb46ea2 discovery: rename 'error' to 'errormsg'
The variable 'error' conflict with the module name that we would like to import
and use in a coming changeset.
2015-10-05 22:29:57 -07:00
Gregory Szorc
3ff440a6fc discovery: use absolute_import 2015-08-08 19:07:11 -07:00
Michael O'Connor
824e19a989 discovery: don't compute allfuturecommon when it won't be used
In repos with many changesets, the computation of allfuturecommon
can take a significant amount of time.  Since it's only used if
there's an obsstore, don't compute it otherwise.
2015-04-13 09:54:36 -04:00
Jordi Gutiérrez Hermoso
8eb132f5ea style: kill ersatz if-else ternary operators
Although Python supports `X = Y if COND else Z`, this was only
introduced in Python 2.5. Since we have to support Python 2.4, it was
a very common thing to write instead `X = COND and Y or Z`, which is a
bit obscure at a glance. It requires some intricate knowledge of
Python to understand how to parse these one-liners.

We change instead all of these one-liners to 4-liners. This was
executed with the following perlism:

    find -name "*.py" -exec perl -pi -e 's,(\s*)([\.\w]+) = \(?(\S+)\s+and\s+(\S*)\)?\s+or\s+(\S*)$,$1if $3:\n$1    $2 = $4\n$1else:\n$1    $2 = $5,' {} \;

I tweaked the following cases from the automatic Perl output:

    prev = (parents and parents[0]) or nullid
    port = (use_ssl and 443 or 80)
    cwd = (pats and repo.getcwd()) or ''
    rename = fctx and webutil.renamelink(fctx) or []
    ctx = fctx and fctx or ctx
    self.base = (mapfile and os.path.dirname(mapfile)) or ''

I also added some newlines wherever they seemd appropriate for readability

There are probably a few ersatz ternary operators still in the code
somewhere, lurking away from the power of a simple regex.
2015-03-13 17:00:06 -04:00
Pierre-Yves David
78f473bc9b discovery: prevent crash on unknown remote heads with old repo (issue4337)
When a remote is not capable of the `branchmap` wireproto command, we denote
incoming heads with None. This leads to a crash in the code in charge of
displaying the list of unknown remote heads.

We now properly detect this case and display a shorter message in this case.

The reason for this  `set([None])` value is now documented.
2014-08-14 16:26:41 -07:00
Stephen Lee
05934f0bb8 discovery: if a push would create a new head, mention the bookmark name if any 2014-03-08 19:02:39 +11:00
Mads Kiilerich
bdb0a37b31 discovery: don't report all "unsynced" remote heads (issue4230)
49e52fbb2acd made discovery more helpful - too helpful for some extreme use
cases.

Instead, we arbitrarily limit the list it at 4 and add 'or more'.
2014-04-24 16:47:22 +02:00
Mads Kiilerich
8c0ff878d1 discovery: make "note: unsynced remote changes!" less serious than a warning
This situation is not necessarily a problem and do not deserve a warning. It is
just some information that can guide the user in understanding what is going
on.

Making it 'debug' would usually not give the hint when it is relevant so we
make it a 'status' message.
2014-02-07 17:24:12 +01:00
Mads Kiilerich
303021da0b discovery: improve "note: unsynced remote changes!" warning
This message frequently caused confusion. "unsynced" is not a well established
user-facing concept in Mercurial and the message was not very specific or
helpful.

Instead, show a message like:
  remote has heads on branch 'default' that are not known locally: 6c0482d977a3

This message will also (when relevant) be shown before aborting on "push
creates new remote head".

A similar (but actually very different) message was addressed in cbd5a12a601a.
2014-02-06 02:19:38 +01:00
Matt Mackall
5a04f42dce push: backout b359130ef1bc due to test failures 2014-02-09 17:31:26 -06:00
Mads Kiilerich
fee088299f discovery: improve "note: unsynced remote changes!" warning
This note (which actually is a warning) frequently caused confusion.
"unsynced" is not a well established user-facing concept in Mercurial and the
message was not very specific or helpful.

Instead, show a messages like:
  remote has heads on branch 'default' that are not known locally: 6c0482d977a3
and show it before aborting on "push creates new remote head". This will also
give more of a hint in the case where the branch has been closed remotely and
'hg heads' thus not would show any new heads after pulling.

A similar (but actually very different) message was addressed in cbd5a12a601a.
2014-02-06 02:19:38 +01:00
Mads Kiilerich
a2af430785 discovery: cleanup of variable names and comments 2014-02-06 02:17:48 +01:00
Pierre-Yves David
df72d3d98f discovery: stop using nodemap for membership testing
Nodemap is not aware of filtering so we need to ask the changelog itself if a
node is known. This is probably a bit slower but such check does not dominated
discovery time. This is necessary if we want to run discovery on filtered repo.
2013-11-15 23:28:43 -05:00
Stephen Lee
7b97b6250a bookmarks: allow push -B to create a new remote head (issue2372)
Push is currently allowed to create a new head if there is a remote
bookmark that will be updated to point to the new head. If the
bookmark is not known remotely then push aborts, even if a -B argument
is about to push the bookmark. This change allows push to continue in
this case. This does not require a wireproto force.
2013-11-11 21:16:54 +11:00
Mads Kiilerich
a4925d4784 discovery: make note messages for new heads more readable 2013-11-16 15:46:29 -05:00
Mads Kiilerich
d93d477327 discovery: tweak error message for multiple branch heads 2013-11-16 15:46:29 -05:00
FUJIWARA Katsunori
9246c0599a discovery: revise hint message introduced by changeset 49ed20ea8da0
This patch revises hint message from "for detail about" introduced by
changeset 49ed20ea8da0 to "for details about", to unify it with the
hint message introduced by proceeding patch.
2013-10-03 23:16:07 +09:00
FUJIWARA Katsunori
3198fa3830 push: hide description about "-f" in the hint to prevent from using it easily
"use push -f to force" in the hint at abortion of "hg push" may cause
novice users to execute "push -f" easily without understanding about
problems of multiple branch heads in the repository.

This patch hides description about "-f" in the hint, and leads into
seeing "hg help push" for details about pushing new heads.
2013-10-03 23:16:06 +09:00
FUJIWARA Katsunori
477426f110 discovery: abort also when pushing multiple headed new branch
Before this patch, pushing with --new-branch permits to create
multiple headed branch on the destination repository.

But permitting to create new branch should be different from
permitting to create multiple heads on branch.

This patch prevents from careless pushing multiple headed new branch,
and requires --force to push such branch forcibly.
2013-10-01 00:26:22 +09:00
Kevin Bullock
93f9cb7f25 filtering: rename filters to their antonyms
Now that changelog filtering is in place, it's become evident that
naming the filters according to the set of revs _not_ included in the
filtered changelog is confusing. This is especially evident in the
collaborative branch cache scheme.

This changes the names of the filters to reflect the revs that _are_
included:

  hidden -> visible
  unserved -> served
  mutable -> immutable
  impactable -> base

repoview.filteredrevs is renamed to filterrevs, so that callers read a
bit more sensibly, e.g.:

  filterrevs('visible') # filter revs according to what's visible
2013-01-13 01:39:16 -06:00
Mads Kiilerich
d12d20b98d discovery: process heads in sorted order 2013-01-15 02:59:12 +01:00
Pierre-Yves David
4bd2fce08b branchmap: pass revision insteads of changectx to the update function
Creation of changectx objects is very slow, and they are not very
useful. We are going to drop them. The first step is to change the
function argument type.
2013-01-08 01:28:39 +01:00
Pierre-Yves David
1e2601accd discovery: drop the visibleheads function
It has no users left. (Using filtering explicitly is easier.)
2013-01-06 04:50:14 +01:00
Pierre-Yves David
3db2a036e8 clfilter: remove the last usage of visibleheads
We can just inline the filtering now that all server code uses
changelog filtering directly.
2013-01-06 04:48:22 +01:00
Pierre-Yves David
d494152aab discovery: drop the visiblebranchmap function 2013-01-05 18:57:09 +01:00
Pierre-Yves David
5e4e0ce72d branchmap: make update a method 2012-12-22 17:08:15 +01:00
Pierre-Yves David
0b84a3fa35 branchmap: store branchcache in a dedicated object
Value and key of branchcache would benefit from being hold by the same object.
Moreover some logic (update, write, validation) could be move on such object.

The creation of this object is the first step toward this move. The result will
clarify branchcache related code and hide most of the detail in the class
itself. This encapsulation will greatly helps implementation of branchcache for
filtered view of the repo.
2012-12-22 01:44:42 +01:00
Pierre-Yves David
0e27877238 branchmap: extract _updatebranchcache from repo 2012-12-19 14:49:06 +01:00
Pierre-Yves David
ad4e0f7344 clfilter: use filtering in visibleheads
This is the second real use of changelog filtering. The change is very small to
allow testing the new filter with a setup close to the original one.

We replace custom post processing on `heads`function by call to the standard
code pass on a filtering repo.

In later coming will have wider usage of filtering that will make the dedicated
function useless.
2012-12-17 17:27:12 +01:00
Pierre-Yves David
33f9591972 clfilter: use filtering in visiblebranchmap
Here is the first real use of changelog filtering. The change is very small to
allow testing the new filter with a setup close to the original one.

We replace custom post processing on branchmap function by call to the
standard code pass on a filtering repo.

In later coming will have wider usage of filtering that will make the dedicated
function useless.
2012-12-17 17:42:34 +01:00
Pierre-Yves David
19b261d640 obsolete: have allsuccessors takes a list of nodes
Additional logic, used to detect mutable history troubles, will need to quickly
compute successors of a whole set of changeset.
2012-10-16 15:49:58 +02:00
Pierre-Yves David
1d9b00f6af obsolete: rename anysuccessors into allsuccessors
The "any" prefix looks like it returned a boolean. `allsuccessors` is more
accurate.
2012-10-19 00:30:11 +02:00
Pierre-Yves David
342b88a402 bookmarks: extract valid destination logic in a dedicated function
We usually update bookmarks only if the new location is descendant of the old
bookmarks location.  We extract this logic into a function. This is the first
step to allow more complex logic using obsolescence in this validation of the
bookmark movement.
2012-08-26 00:28:56 +02:00
Pierre-Yves David
ad749501f8 checkheads: don't warn about unsynced changes that we ill obsolete
We won't be able to pull them after this push.
2012-08-26 00:27:44 +02:00