Commit Graph

115 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
15fa88d61c bookmarks: show detailed status about outgoing bookmarks
Before this patch, "hg outgoing -B" shows only difference of bookmarks
between two repositories, and it isn't user friendly.

This patch shows detailed status about outgoing bookmarks at "hg
outgoing -B".

To avoid breaking backward compatibility with other tool chains, this
patch shows status, only if --verbose is specified,
2015-04-08 02:56:19 +09:00
FUJIWARA Katsunori
f7b7fe9dcb bookmarks: show detailed status about incoming bookmarks
Before this patch, "hg incoming -B" shows only difference of bookmarks
between two repositories, and it isn't user friendly.

This patch shows detailed status about incoming bookmarks at "hg
incoming -B".

To avoid breaking backward compatibility with other tool chains, this
patch shows status, only if --verbose is specified,
2015-04-08 02:56:19 +09:00
FUJIWARA Katsunori
71b8a887f2 bookmarks: show outgoing bookmarks more exactly
Before this patch, "hg outgoing -B" shows only bookmarks added
locally. Then, users can't know about bookmarks below before "hg push"
execution.

  - deleted locally (even though it may be added remotely from "hg pull" view)
  - advanced locally
  - diverged
  - changed (= remote revision is unknown for local)

This patch shows such bookmarks, too.
2015-04-08 02:56:19 +09:00
FUJIWARA Katsunori
c1a49db724 bookmarks: show incoming bookmarks more exactly
Before this patch, "hg incoming -B" shows only bookmarks added
remotely. Then, users can't know about bookmarks below before "hg
pull" execution.

  - advanced remotely
  - diverged
  - changed (remote revision is unknown for local)

This patch shows such bookmarks, too.
2015-04-08 02:56:19 +09:00
FUJIWARA Katsunori
928dad06e6 bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
This patch adds utility function "summary()", to replace comparing
bookmarks in "commands.summary()". This replacement finishes
centralizing the logic to compare bookmarks into "bookmarks.compare()".

This patch also adds test to check summary output with
incoming/outgoing bookmarks, because "hg summary --remote" is not
tested yet on the repository with incoming/outgoing bookmarks.

This test uses "(glob)" to ignore summary about incoming/outgoing
changesets.
2015-03-19 23:36:06 +09:00
FUJIWARA Katsunori
1c3d3702ce bookmarks: remove useless diff()
Previous patches removed code paths referring it.
2015-03-19 23:36:05 +09:00
FUJIWARA Katsunori
eefef22b72 bookmarks: add outgoing() to replace diff() for outgoing bookmarks
This replacement makes enhancement of "show outgoing bookmarks" easy,
because "compare()" can detect more detailed difference of bookmarks
between two repositories.
2015-03-19 23:36:05 +09:00
FUJIWARA Katsunori
db0c9bd871 bookmarks: add incoming() to replace diff() for incoming bookmarks
This replacement makes enhancement of "show incoming bookmarks" easy,
because "compare()" can detect more detailed difference of bookmarks
between two repositories.
2015-03-19 23:36:05 +09:00
FUJIWARA Katsunori
d8359fb8e3 bookmarks: reuse @number bookmark, if it refers changeset referred remotely
Before this patch, "@number" suffixed bookmark may be newly created at
each "hg pull" from the remote repository, if the bookmark in remote
repository diverges from one in local one.

This causes unexpected increase of "@number" suffixed bookmarks.

This patch reuses "@number" suffixed bookmark, if it refers the
changeset which is referred by the same bookmark in the remote
repository.
2015-03-17 18:20:24 +09:00
FUJIWARA Katsunori
995101b792 bookmarks: check @pathalias suffix before available @number for efficiency
Before this patch, available "@number" suffix is searched before
"@pathalias" suffix, even though the latter has higher priority than
the former if the latter exits.

This patch checks "@pathalias" suffix before available "@number" for
efficiency.

When an URL has multiple path definitions, the first one is used for
"pathalias" after this patch, even though the last one is used before
this patch, because:

  - this choice can terminate loop immediately for efficiency
  - such case seems to be rare
2015-03-17 18:20:24 +09:00
FUJIWARA Katsunori
2ae4c00003 bookmarks: prevent divergent bookmark from being updated unexpectedly
Before this patch, "@99" suffixed bookmark may be updated unexpectedly
by the bookmark value on the remote side at "hg pull", if all of "@1"
to "@99" suffixed bookmarks exist in the local repository, because
variable "n" still refers "@99" suffixed bookmark after the loop to
examine "@num" suffixes, even though it already exists in the local
repository.

This patch prevents divergent bookmark from being updated
unexpectedly, and shows warning message in such situation.

This patch uses original python script "seq.py" instead of "seq"
command to create sequence numbers in the test, because "seq" command
may not be available: it isn't defined in recent POSIX specification
(POSIX.1-2001 2013 Edition or XPG7)
2015-03-17 18:20:24 +09: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
Mads Kiilerich
b2b60414f6 spelling: fixes from proofreading of spell checker issues 2015-01-18 02:38:57 +01:00
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