Commit Graph

102 Commits

Author SHA1 Message Date
Angel Ezquerra
88cbab7845 localrepo: remove all external users of localrepo.opener
This change touches every module in which repository.opener was being used, and
changes it for the equivalent repository.vfs. This is meant to make it easier
to split the repository.vfs into several separate vfs.

It should now be possible to remove localrepo.opener.
2015-01-15 23:17:12 +01:00
Ryan McElroy
cf43c21202 bookmarks: factor out repository lookup from writing bookmarks file
This will allow the share extension to extend bookmarks functionality to share
bookmarks between repositories.
2014-12-02 20:31:19 -08:00
Ryan McElroy
468da3b11a bookmarks: factor out bookmark file opening for easier extensibility 2014-11-27 00:24:25 -08:00
Pierre-Yves David
4012eb31b0 bookmark: read pending data when appropriate
If we are called by a hook and pending data exists, read it.
2014-09-28 21:27:48 -07:00
Pierre-Yves David
b9594d1c53 transaction: use 'location' instead of 'vfs' objects for file generation
The argument is now a location name. The location must be present in the
'vfsmap' provided to the transaction at creation time.
2014-10-17 20:53:42 -07:00
Pierre-Yves David
9984e5c699 bookmarks: fix formatting of exchange message (issue4439)
The message formatting was crashing when doing explicit pulling `hg pull -B X`.
This changeset fix it and improved the test coverage.
2014-11-05 17:25:00 +00:00
Gregory Szorc
ae20b321ce bookmarks: explicitly track identical bookmarks
bookmarks.compare() previously lumped identical bookmarks in the
"invalid" bucket. This patch adds a "same" bucket.

An 8-tuple for holding this state is pretty gnarly. The return value
should probably be converted into a class to increase readability. But
that is beyond the scope of a patch intended to be a late arrival to
stable.
2014-10-24 10:40:37 -07:00
Pierre-Yves David
2a99e9b2bc bookmarks: inform transaction-related hooks that some bookmarks were moved
We do not have enough information to provide any finer data, but this is still
useful information.
2014-10-12 08:29:31 -07:00
Pierre-Yves David
5b3e8ffd67 push: update bookmarks (on server) within a transaction
A nice side effect is that bookmarks sent through bundle2 are updated within the
same transaction as all other changes.
2014-09-28 17:35:33 -07:00
Pierre-Yves David
6638ea8bec pull: perform bookmark updates in the transaction 2014-09-28 15:21:38 -07:00
Pierre-Yves David
ab55792aad bookmark: add a bmstore.recordupdate to plug bookmarks into the transaction
Instead of manually writing bookmarks when they are updated, we can just record this
update to the transaction and rely on it to update the on-disk file.
2014-09-28 00:41:55 -07:00
Pierre-Yves David
6ae3ea078a bookmarks: split bookmark serialization and file handling
If we want to handle bookmarks in a transaction we need to decouple the file
handling and the actual production of the content. This is similar to how we
handle phases in transaction.
2014-09-27 03:10:33 -07:00
Pierre-Yves David
23ce37ca7e pull: merge bookmark updates and imports
We do all the things in one go now, updating existing bookmark, adding new ones,
and overwriting the ones explicitly specified for --bookmark. This impacts the
tests by removing some duplicated or unnecessary output.
2014-09-28 14:07:56 -07:00
Pierre-Yves David
3cfceb8bab pull: gather explicit bookmark pulls with bookmark updates
There is no reason to make them at different times. So we gather them. This is
the first step toward merging them.
2014-09-28 13:43:31 -07:00
Pierre-Yves David
c80fa5e562 bookmark: remove now unused pushtoremote function
Everything is unified in the push discovery now.
2014-09-26 23:04:35 -07:00
Pierre-Yves David
3560be20d0 bookmarks: allow updatefromremote to be quiet
This will be useful to use the function during clone (clone is not printing any
bookmark data right now)
2014-10-02 12:16:07 -05:00
Matt Mackall
667f516d70 bookmarks: fix divergent bookmark path normalization 2014-10-02 16:43:50 -05:00
Pierre-Yves David
6d9b081f23 bookmark: make the search for divergent names more robust
We translate the "url we update from" and "the url in the config" into their
canonical representation. This is useful for urls that have multiple equivalent
forms:

  /foo/bar/ == file:/foo/bar/ == file:///foo/bar


eg: hg pull --config path.bar=/foo/bar/ file:/foo/bar
2014-09-26 11:31:15 -07:00
Durham Goode
37c75eb0f0 bookmarks: allow pushkey if new equals current
Previously a bookmark pushkey would be rejected if the specified 'old' value
didn't match the servers 'current' value. This change allows this situation, as
long as the 'current' server value equals the 'new' pushkey value already.

We are trying to write a hook that forces a server bookmark to move forward,
using a changegroup hook. If the user also pushed the bookmark, they would get
an error, since they computed their pushkey (old,new) pair before the server
moved the bookmark. Long term, bundle2 will let us do this more smartly, but
this change seems reasonable for now.
2014-08-26 04:58:41 -07:00
Matt Mackall
ffa85c3a41 bookmarks: avoid deleting primary bookmarks on rebase
Prior to this, doing "hg rebase -s @foo -d @" would delete @, which is
obviously wrong: a primary bookmark should never be automatically deleted.

This change blocks the deletion, but doesn't yet properly clean up the
divergence: @ should replace @foo.
2014-07-08 14:45:55 -05:00
Pierre-Yves David
971cefa104 push: move bookmarks exchange in the exchange module
The bookmark exchange code was already extracted during a previous cycle. This
changesets moves the extracted function in this module. This function will read
and write data in the `pushoperation` object and It  is preferable to have all
core function collaborating through this object in the same place.

This changeset is pure code movement only. Code change for direct consumption of
the `pushoperation` object will come later.
2014-01-30 17:46:51 -08:00
Sean Farley
8973f827ab update: consider successor changesets when moving active bookmark
Previously, when an obsolete changeset was bookmarked, successor changesets were not considered
when moving the bookmark forward. Now that a bare update will move to the tip most of the
successor changesets, we also update the bookmark logic to allow the bookmark to move with this
update.

Tests have been updated and keep issue4015 covered as well.
2014-01-15 17:48:48 -06:00
Siddharth Agarwal
9b0eab9940 bookmarks: make setcurrent with None an error 2013-11-15 18:41:40 -08:00
Siddharth Agarwal
e7e0c5ad48 bmstore.write: use unsetcurrent instead of setcurrent with None 2013-11-15 18:28:57 -08:00
FUJIWARA Katsunori
f4da0cbf73 bookmarks: rewrite pushing bookmarks in "localrepository.push()" by "compare()"
This patch adds "updateremote()", which uses "compare()" to compare
bookmarks between the local and the remote repositories, to replace
pushing local bookmarks in "localrepository.push()".
2013-11-08 12:45:52 +09:00
FUJIWARA Katsunori
22784f4191 bookmarks: rewrite pushing local bookmarks in "commands.push()" by "compare()"
This patch adds "pushtoremote()", which uses "compare()" to compare
bookmarks between the local and the remote repositories, to replace
pushing local bookmarks in "commands.push()".
2013-11-08 12:45:52 +09:00
FUJIWARA Katsunori
31a7d77dc6 bookmarks: rewrite "updatefromremote()" by "compare()"
To update entries in bmstore "localmarks", this patch uses
"bin(changesetid)" instead of "repo[changesetid].node()" used in
original "updatefromremote()" implementation, because the former is
cheaper than the latter.
2013-11-08 12:45:52 +09:00
FUJIWARA Katsunori
6a643dd87d bookmarks: add function to centralize the logic to compare bookmarks
This patch adds "compare()" function to centralize the logic to
compare bookmarks between two repositories.
2013-11-08 12:45:52 +09:00
Mads Kiilerich
eabc047878 spelling: random spell checker fixes 2013-10-24 01:49:56 +08:00
FUJIWARA Katsunori
23a7a98972 bookmarks: use "vfs.utime()" instead of "os.utime()" 2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
33e3348b3e bookmarks: use "vfs.unlink()" instead of "util.unlink()" 2013-10-15 00:51:04 +09:00
Kevin Bullock
7e226a7735 bookmarks: pull --update updates to active bookmark if it moved (issue4007)
This makes `hg pull --update` behave the same wrt the active bookmark as
`hg pull && hg update` does as of 13ea5e437ff8. A helper function,
bookmarks.calculateupdate, is added to prevent code duplication between
postincoming and update.
2013-08-01 21:43:14 -05:00
Sean Farley
3561df94aa bookmarks: resolve divergent bookmarks when moving active bookmark forward
This patch resolves divergent bookmarks between the current active bookmark
MARK and the new destination. This situation can arise when pulling new
changesets, abandoning your current changesets actively bookmarked with MARK
via strip, and then doing a bare update. The non-divergent but active bookmark
MARK is then moved to a common ancestor of the new changesets and the abandoned
changesets.

Test coverage is added.
2013-05-01 15:34:45 -05:00
Pierre-Yves David
ccfae81adc obsolete: extract foreground computation from bookmark.validdest
This foreground logic will be reused by update logic.
2013-04-16 15:16:33 +02:00
Siddharth Agarwal
262d694589 pull: list bookmarks before pulling changesets (issue3873)
Consider a bookmark B that exists both locally and remotely. If B is updated
remotely, and then a pull is performed where the pull set contains the new
location of B, the bookmark is updated locally. However, if remote B is
updated in the middle of a pull to a location not in the pull set, the
bookmark won't be updated locally at all.

To fix this, list bookmarks before pulling in changesets, not after. This
still leaves a race open if B gets moved in between listing bookmarks and
pulling in changesets, but the race window is much smaller. Fixing the race
properly would require a bundle format upgrade.

test-hook.t's output changes because we no longer do two listkeys calls during
pull, just one.

test-pull-http.t's output changes because we now search for bookmarks before
searching for changes.
2013-03-29 19:54:06 -07:00
Siddharth Agarwal
109e952c51 bookmarks.updatefromremote: rename local rb to remotemarks
This local will become a parameter in an upcoming patch, so give it a more
descriptive name. The name stays similar to the existing localmarks.
2013-03-29 18:28:59 -07:00
Siddharth Agarwal
f56fcc5796 bookmarks: factor out delete divergent code
Deleting divergent bookmarks is more generally useful than just in
bookmarks.update.
2013-01-30 15:35:00 -08:00
Kevin Bullock
c8bd540ea2 bookmarks: hide bookmarks on filtered revs from listkeys
Don't expose unserved changesets to remote repos. Thanks to Sean Farley
<sean.michael.farley@gmail.com> for tracking down the issue and
Pierre-Yves David <pierre-yves.david@ens-lyon.org> for the fix.
2013-01-27 15:13:53 -06:00
Kevin Bullock
dc307a1121 update: update to current bookmark if it moved out from under us (issue3682)
If the current bookmark (the one listed in .hg/bookmarks.current)
doesn't point to a parent of the working directory, e.g. if it was moved
by a pull, use that as the update target instead of the tipmost
descendent.

A small predicate is (finally) added to the bookmarks module to check
whether the current bookmark is also active.
2013-01-21 13:47:10 -06:00
Mads Kiilerich
4ff2b11ec9 bookmarks: process pulled remote bookmarks in sorted order 2013-01-15 02:59:12 +01:00
Kevin Bullock
2ad73cfc74 bookmarks: spelling correction in docstring 2012-12-07 11:30:38 -06:00
Pierre-Yves David
7ce187106f clfilter: bookmark.validdest should run on unfiltered repo
The logic recently added to `bookmark.validdest` uses data about obsolete
changesets to see if a bookmark destination is valid. Obsolete changesets
are likely to be filtered, so we need to work on an unfiltered repository.
2012-10-08 17:26:23 +02:00
Augie Fackler
9766845689 bookmarks: introduce a bmstore to manage bookmark persistence
Bookmarks persistence still showed a fair amount of its legacy as a
monkeypatching extension. This encapsulates all bookmarks
serialization and parsing in a single class, and offers a single
location where other bookmarks storage engines can be substituted
in. As a result, many files no longer import the bookmarks module,
which strikes me as an encapsulation win.

This doesn't do anything to the current bookmark state yet, but I'm
hoping put that in the bmstore class as well.
2012-11-07 16:21:39 -06:00
Pierre-Yves David
9a87309c77 bookmark: remove useless line in validdest
This case is already covered by the `if old == new:` conditional at the start of
the function.
2012-10-24 18:11:17 +02:00
Pierre-Yves David
e4be0103aa bookmark: issue a single call to allsuccessors per loop
Update to this code was minimalist when `allsuccessors` argument were changed
from a list to a set. As this code is getting my attention again I realised we
can drastically simplify this part of the code by issue a single call to
`allsuccessors`.
2012-10-24 17:55:21 +02:00
Pierre-Yves David
d33a990ff6 bookmark: simplify mutability check in validdest
There is no need to check phase by hand. We already have a ctx method for that.
2012-10-24 17:26:40 +02:00
Thomas Arendsen Hein
6a57af18d2 bookmark: simplify nodemap check introduced in the previous changeset 2012-10-26 09:29:50 +02:00
Pierre-Yves David
b13f928861 bookmark: prevent crashing when a successor is unknown locally (issue3680)
The `%ln` revset substitution does not accept unknown node. We prune unknown
node from potential successors before computing descendants.

This have no impact on the result of this function.

- Descendants of unknown changeset as unknown,
- all successors of unknown changesets are already return by the call who
  returned those same unknown changesets,
- unknown changesets are never a valid destination for a bookmark.
2012-10-25 23:43:52 +02: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