Commit Graph

100 Commits

Author SHA1 Message Date
Matt Harbison
7d8bebd9c1 tests: remove (glob) annotations that were only for '\' matches
# skip-blame because this was mechanically rewritten the following script.  I
ran it on both *.t and *.py, but none of the *.py changes were proper.  All *.t
ones appear to be, and they run without addition failures on both Windows and
Linux.

  import argparse
  import os
  import re

  ap = argparse.ArgumentParser()
  ap.add_argument('path', nargs='+')
  opts = ap.parse_args()

  globre = re.compile(r'^(.*) \(glob\)(.*)$')

  for p in opts.path:
      tmp = p + '.tmp'
      with open(p, 'rb') as src, open(tmp, 'wb') as dst:
          for line in src:
              m = globre.match(line)
              if not m or '$LOCALIP' in line or '*' in line:
                  dst.write(line)
                  continue
              if '?' in line[:-3] or ('?' in line[:-3] and line[-3:] != '(?)'):
                  dst.write(line)
                  continue
              dst.write(m.group(1) + m.group(2) + '\n')
      os.unlink(p)
      os.rename(tmp, p)
2017-12-10 22:50:57 -05:00
Matt Harbison
bd8eaff510 tests: adjust hooks for Windows
I'm not sure why these weren't working on Windows.  The failures were generally
in the style of:

  -  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  1 -> 0
  +  remote: "phase-move: $HG_NODE:  $HG_OLDPHASE -> $HG_PHASE"

and

  -  abort: pretxnclose-bookmark.force-forward hook exited with status 1
  -  [255]
  +  abort: pretxnclose-bookmark.force-public hook exited with status 255
  +  [255]

These failures originated in 5625d0ddc285::6e3e88681b23.
2017-10-20 23:01:56 -04:00
Boris Feld
db2e8fadae bookmark: add a dedicated pretxnclose-bookmark hook
This new hook mirror the newly introduced 'txnclose-bookmark' but can abort the
transaction.
2017-10-08 18:50:14 +02:00
Boris Feld
4815e3ce8d bookmark: add a dedicated txnclose-bookmark hook
The new 'txnclose-bookmark' hook expose the bookmark movement information
stored in 'tr.changes['bookmarks]'. To provide a simple and straightforward
hook API to the users, we introduce a new hook called for each bookmark
touched. Since a transaction can affect multiple bookmarks, updating the
existing 'txnclose' hook to expose that information would be more complex. The
data for all moves might not fit in environment variables and iterations over
each move would be cumbersome. So the introduction of a new dedicated hook is
preferred in this changeset.

This does not exclude the addition to the full bookmark information to the
existing 'txnclose' in the future to help write more complex hooks.
2017-10-10 17:53:42 +02:00
Denis Laxalde
9efc7f05e3 transaction-summary: show the range of new revisions upon pull/unbundle (BC)
Upon pull or unbundle, we display a message with the range of new revisions
fetched. This revision range could readily be used after a pull to look out
what's new with 'hg log'. The algorithm takes care of filtering "obsolete"
revisions that might be present in transaction's "changes" but should not be
displayed to the end user.
2017-10-12 09:39:50 +02:00
Augie Fackler
f8d9a41b22 tests: update test-bookmarks to pass the import checker 2017-08-22 15:04:14 -04:00
David Demelier
f57348c7a4 bookmarks: allow deleting active bookmark using '.' 2017-08-24 09:23:06 +02:00
David Demelier
fbe91693e0 bookmarks: allow renaming active bookmark using '.' 2017-08-21 08:52:46 +02:00
FUJIWARA Katsunori
5a66369304 tests: make output lines conditional for testing with fsmonitor
Repository cloned-bookmark-default and tobundle exist in the working
directory of main test repository "repo". We should take care for
them, because it is known issue that fsmonitor can't handle nested
repositories.

These nested repositories are cloned from "repo", and the number of
unknown files = files in these repositories (including files under
.hg) will be changed easily in the future. But testing with fsmonitor
is not ordinary.

Therefore, test-bookmarks.t with fsmonitor might be broken silently.

This is reason why this patch uses "(glob)" for the number of unknown
files in "hg summary" output.

BTW, this patch doesn't use .hgignore to make test portable, because
.hgignore might cause another issue related to "walk_on_invalidate"
configuration of fsmonitor.
2017-07-03 02:52:39 +09:00
Pierre-Yves David
c876bd5bd3 bookmarks: explicitly convert to 'node' during initialization
We know the content of the file is supposed to be full hex. So we can do the
translation ourselves and directly check if the node is known.

As nice side effect we now have proper error handling for invalid node value.

Before:
! wall 0.021580 comb 0.020000 user 0.020000 sys 0.000000 (best of 134)

After:
! wall 0.009342 comb 0.010000 user 0.010000 sys 0.000000 (best of 302)
2017-06-07 22:26:43 +01:00
Yuya Nishihara
6f42d09a39 bookmarks: fix check of hash-like name to not abort by ambiguous identifier
'mark in repo' may raise LookupError. I set it to not be warned since bookmark
names shorter than 4 chars aren't checked and short names are likely to be
ambiguous.
2017-05-25 23:20:00 +09:00
Augie Fackler
5a83391bf4 bookmarks: warn about bookmark names that unambiguously resolve to a node (BC)
I just burned myself on this today because I left out the -r in my `hg
bookmark` command, which then left me confused because I didn't notice
the bookmark I created in the wrong place that was silently shadowing
the revision I was trying to check out. Let's warn the user.

This patch only enforces the check on bookmark names 4 characters long
or longer. We can tweak that if we'd like, I selected that since
that's the fewest characters shortest will use in the templater
output.

A previous version of this patch rejected such bookmarks. It was
proposed during review (and I agree) that the behavior change for a
bookmark named "cafe" or similar as history accumulated was a little
too weird, but that the warning definitely has merit.
2017-05-22 19:18:12 -04:00
Matt Harbison
98d41eff3c tests: quote paths in shell script hooks
Without the quoting, MSYS will remove the '\' directory separators, and the repo
can't be opened.
2017-04-01 15:23:26 -04:00
FUJIWARA Katsunori
25ed007f6f bookmarks: check HG_PENDING strictly
Before this patch, checking HG_PENDING in bookmarks.py might cause
unintentional reading unrelated '.hg/bookmarks.pending' in, because it
just examines existence of HG_PENDING environment variable.

This patch uses txnutil.trypending() to check HG_PENDING strictly.

This patch also changes share extension.

Enabling share extension (+ bookmark sharing) makes
bookmarks._getbkfile() receive repo to be shared (= "srcrepo"). On the
other hand, HG_PENDING always refers current working repo (=
"currepo"), and bookmarks.pending is written only into currepo.

Therefore, we should try to read .hg/bookmarks.pending of currepo in
at first. If it doesn't exist, we try to read .hg/bookmarks of srcrepo
in.

Even after this patch, an external hook spawned in currepo can't see
pending changes in currepo via srcrepo, even though such changes
become visible after closing transaction, because there is no easy and
cheap way to know existence of pending changes in currepo via srcrepo.

Please see https://www.mercurial-scm.org/wiki/SharedRepository, too.

BTW, this patch may cause failure of bisect in the repository of
Mercurial itself, if examination at bisecting assumes that an external
hook can see all pending changes while nested transactions across
repositories.

This invisibility issue will be fixed by subsequent patch, which
allows HG_PENDING to refer multiple repositories.
2017-02-21 01:21:00 +09:00
FUJIWARA Katsunori
ee08f6e022 tests: make directory to prevent test process from going out of $TESTTMP
Before this patch, test process for test-bookmarks.t goes out of
$TESTTMP at "cd .." before creation of "orderrepo" repository.

To prevent test process from going out of $TESTTMP, this patch makes
directory "repo" sub-directory and executes almost all test scenarios
in test-bookmarks.t under it.

This is preparation for new test added in subsequent patch.
2017-02-21 01:20:59 +09:00
Jun Wu
3ee7ba0bd8 tests: replace "cp -r" with "cp -R"
The POSIX documentation about "cp" [1] says:

  ....

  RATIONALE
    ....
    Earlier versions of this standard included support for the -r option to
    copy file hierarchies. The -r option is historical practice on BSD and
    BSD-derived systems. This option is no longer specified by POSIX.1-2008
    but may be present in some implementations. The -R option was added as a
    close synonym to the -r option, selected for consistency with all other
    options in this volume of POSIX.1-2008 that do recursive directory
    descent.

    The difference between -R and the removed -r option is in the treatment
    by cp of file types other than regular and directory. It was
    implementation-defined how the - option treated special files to allow
    both historical implementations and those that chose to support -r with
    the same abilities as -R defined by this volume of POSIX.1-2008. The
    original -r flag, for historic reasons, did not handle special files any
    differently from regular files, but always read the file and copied its
    contents. This had obvious problems in the presence of special file
    types; for example, character devices, FIFOs, and sockets.
    ....

  ....

  Issue 6
    The -r option is marked obsolescent.
    ....

  Issue 7
    ....
    The obsolescent -r option is removed.
    ....

  (No "Issue 8" yet)

Therefore it's clear that "cp -R" is strictly better than "cp -r".

The issue was discovered when running tests on OS X after 2e4d149e62aa.

[1]: pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html
2016-11-30 19:25:18 +00:00
Mads Kiilerich
38cb771268 spelling: fixes of non-dictionary words 2016-10-17 23:16:55 +02:00
Durham Goode
67594c134c transaction: allow running file generators after finalizers
Previously, transaction.close would run the file generators before running the
finalizers (see the list below for what is in each). Since file generators
contain the bookmarks and the dirstate, this meant we made the dirstate and
bookmarks visible to external readers before we actually wrote the commits into
the changelog, which could result in missing bookmarks and missing working copy
parents (especially on servers with high commit throughput, since pulls might
fail to see certain bookmarks in this situation).

By moving the changelog writing to be before the bookmark/dirstate writing, we
ensure the commits are present before they are referenced.

This implementation allows certain file generators to be after the finalizers.
We didn't want to move all of the generators, since it's important that things
like phases actually run before the finalizers (otherwise you could expose
commits as public when they really shouldn't be).

For reference, file generators currently consist of: bookmarks, dirstate, and
phases. Finalizers currently consist of: changelog, revbranchcache, and fncache.
2016-04-07 14:10:49 -07:00
FUJIWARA Katsunori
1430646025 update: omit redundant activating message for already active bookmark
This patch also adds "hg bookmarks" invocation into tests, where
redundant message is omitted but bookmark activity isn't clear from
context.
2016-03-12 04:35:42 +09:00
Pierre-Yves David
2dcf98d614 update: change default destination to tipmost descendant (issue4673) (BC)
Bare 'hg update' now brings you to the tipmost descendant (on the same branch).
Leaving the user on the same topological branch. The previous behavior, updating
to the tipmost changeset on the same branch could lead to jump from a
topological branch to another. This was confusing and impractical. As the only
conceivable reason for the old behavior have been address by the recently
introduce message about other heads, we can "safely" change this behavior

All test changes have been reviewed and seen a valid consequences.
2016-02-02 15:24:11 +00:00
Pierre-Yves David
2e0675043e update: warn about other topological heads on bare update
A concern around the user experience of Mercurial is user getting stuck on there
own topological branch forever. For example, someone pulling another topological
branch, missing that message in pull asking them to merge and getting stuck on
there own local branch.

The current way to "address" this concern was for bare 'hg update' to target the
tipmost (also latest pulled) changesets and complain when the update was not
linear. That way, failure to merge newly pulled changesets would result in some
kind of failure.

Yet the failure was quite obscure, not working in all cases (eg: commit right
after pull) and the behavior was very impractical in the common case
(eg: issue4673).

To be able to change that behavior, we need to provide other ways to alert a
user stucks on one of many topological head. We do so with an extra message after
bare update:

  1 other heads for branch "default"

Bookmark get its own special version:

  1 other divergent bookmarks for "foobar"

There is significant room to improve the message itself, and we should augment
it with hint about how to see theses other heads or handle the situation (see
in-line comment). But having "a" message is already a significant improvement
compared to the existing situation. Once we have it we can iterate on a better
version of it. As having such message is an important step toward changing the
default destination for update and other nicety, I would like to move forward
quickly on getting such message.

This was discussed during London - October 2015 Sprint.
2016-02-02 14:49:02 +00:00
FUJIWARA Katsunori
07d633b500 commands: advance current active bookmark at pull --update correctly
Before this patch, "hg pull --update" doesn't advance current active
bookmark correctly, if pulling itself doesn't advance it, even though
"hg pull" + "hg update" does so.

Existing test for "pull --update works the same as pull && update" in
test-bookmarks.t doesn't examine this case, because pulling itself
advance current active bookmark before actual updating the working
directory in that test case.

To advance current active bookmark at "hg pull --update" correctly,
this patch examines 'movemarkfrom' instead of 'not checkout'.

Even if 'not checkout' at the invocation of postincoming(), 'checkout'
is overwritten by "the revision to update to" value returned by
destutil.destupdate() in such case. Therefore, 'not checkout'
condition means "update destination is revision #0", and isn't
suitable for examining whether active bookmark should be advanced.

Even though examination around "movemarkfrom == repo['.'].node()" may
seem a little redundant just for this issue, this makes it easier to
compare (and unify in the future, maybe) with the same logic to update
bookmark at "hg update" below.

        if not ret and movemarkfrom:
            if movemarkfrom == repo['.'].node():
                pass # no-op update
            elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
                ui.status(_("updating bookmark %s\n") % repo._activebookmark)
            else:
                # this can happen with a non-linear update
                ui.status(_("(leaving bookmark %s)\n") %
                          repo._activebookmark)
                bookmarks.deactivate(repo)
2016-01-28 20:10:06 +09:00
Matt Mackall
5fb7b930ae bookmarks: don't deactivate on no-op update (issue4901) 2015-10-14 18:03:17 -05:00
Yuya Nishihara
e482010d79 revset: strip off "literal:" prefix from bookmark not found error
This is what branch() and tag() do.
2015-10-07 23:04:31 +09:00
Pierre-Yves David
6705b17abd bookmark: do not crash when active bookmark is forward and --date is used
The logic that decides where to update according to the active bookmark
location (when not on ".") was setting the rev to update to before we process
--date.  This lead to --date processing aborting because of duplicated
specification.

We reorder the two pieces of code and add a test for this.
2015-09-17 16:08:10 -07:00
Pierre-Yves David
885e11c51d bookmark: actually test update behavior in both cases
The test claimed to test pull --update behaved the same way as pull + update,
but the behavior of pull + update was never tested.

We now test both.
2015-09-17 17:17:54 -07:00
Siddharth Agarwal
20e8951b71 test-bookmarks.t: avoid nested repo
This is (a) pretty unnecessary and (b) breaks tests for the third-party
hgwatchman extension, which doesn't support nested repos.
2015-08-02 21:56:38 -07:00
Matt Mackall
9573c557ad bookmarks: clear active bookmark on non-linear update 2015-07-14 18:50:20 -05:00
Pierre-Yves David
5e9a275007 bookmarks: change bookmark within a transaction
For some time, bookmark can and should be moved in the transaction. This
changeset migrates the 'hg bookmarks' commands to use a transaction.

Tests regarding rollback and transaction hooks are impacted for
obvious reasons. Some have to be slightly updated to keep testing the
same things. Some can just be dropped because they do not make sense
anymore.
2014-09-28 00:49:36 -07:00
Gilles Moris
c60f7ce967 summary: move the parents phase marker to commit line (issue4688)
The phase of the pending commit depends on the parent of the working directory
and on the phases.newcommit configuration.
First, this information rather depend on the commit line which describe the
pending commit.
Then, we only want to be advertised when the pending phase is going to be higher
than the default new commit phase.

So the format will change from

$ hg summary
parent: 2:ab91dfabc5ad
 foo
parent: 3:24f1031ad244 tip
 bar
branch: default
commit: 1 modified, 1 unknown, 1 unresolved (merge)
update: (current)
phases: 1 secret (secret)

to

parent: 2:ab91dfabc5ad
 foo
parent: 3:24f1031ad244 tip
 bar
branch: default
commit: 1 modified, 1 unknown, 1 unresolved (merge) (secret)
update: (current)
phases: 1 secret
2015-05-29 22:23:58 +02:00
Ryan McElroy
f73efddf9c commands: rename current to active in variables and comments
Today, the terms 'active' and 'current' are interchangeably used throughout the
codebase in reference to the active bookmark (the bookmark that will be updated
with the next commit). This leads to confusion among developers and users.
This patch is part of a series to standardize the usage to 'active' throughout
the mercurial codebase and user interface.
2015-05-28 20:06:19 -07:00
Gilles Moris
7771de9187 summary: add a phase line (draft, secret) to the output
The number of draft and secret changesets are currently not summarized.
This is an important information because the number of drafts give some rough
idea of the number of outgoing changesets in typical workflows, without needing
to probe a remote repository. And a non-zero number of secrets means that
those changeset will not be pushed.

If the repository is "dirty" - some draft or secret changesets exists - then
summary will display a line like:

phases: X draft, Y secret (public)

The phase in parenthesis corresponds to the highest phase of the parents of
the working directory, i.e. the current phase.

By default, the line is not printed if the repository is "clean" - all
changesets are public - but if verbose is activated, it will display:

phases: (public)

On the other hand, nothing will be printed if quiet is in action.

A few tests have been added in test-phases.t to cover the -v and -q cases.
2015-05-14 17:38:38 +02:00
FUJIWARA Katsunori
6a05d7fab8 revset: raise RepoLookupError to make present() predicate continue the query
Before this patch, "bookmark()", "named()" and "tag()" predicates
raise "Abort", when the specified pattern doesn't match against
existing ones.

This prevents "present()" predicate from continuing the query, because
it only catches "RepoLookupError".

This patch raises "RepoLookupError" instead of "Abort", to make
"present()" predicate continue the query, even if "bookmark()",
"named()" or "tag()" in the sub-query of it are aborted.

This patch doesn't contain raising "RepoLookupError" for "re:" pattern
in "tag()", because "tag()" treats it differently from others. Actions
of each predicates at failure of pattern matching can be summarized as
below:

  predicate  "literal:"  "re:"
  ---------- ----------- ------------
  bookmark   abort       abort
  named      abort       abort
  tag        abort       continue (*1)

  branch     abort       continue (*2)
  ---------- ----------- ------------

"tag()" may have to abort in the (*1) case for similarity, but this
change may break backward compatibility of existing revset queries. It
seems to have to be changed on "default" branch (with "BC" ?).

On the other hand, (*2) seems to be reasonable, even though it breaks
similarity, because "branch()" in this case doesn't check exact
existence of branches, but does pick up revisions of which branch
matches against the pattern.

This patch also adds tests for "branch()" to clarify behavior around
"present()" of similar predicates, even though this patch doesn't
change "branch()".
2015-01-31 01:00:50 +09:00
Yuya Nishihara
5079a4aa16 bookmarks: port to generic templater 2014-10-03 00:43:22 +09:00
Yuya Nishihara
9ea06d6a89 bookmarks: split ui.write() so that it can be easily ported to formatter api
Test output changes because color labels are applied separately.
2014-10-03 00:36:36 +09:00
Michael O'Connor
306b55bcc9 revset: bookmark revset interprets 'literal:' prefix correctly (issue4329) 2014-08-11 23:45:08 -04:00
Matt Mackall
65d57189d4 unbundle: don't advance bookmarks (issue4322) (BC)
This behavior didn't make much sense and interacts badly with things
that use unbundle internally like shelve. Presumably, the original
rationale was that since bundles didn't contain bookmarks, this gave a
sense of keeping bookmarks up-to-date like would happen with a
corresponding pull. However, since it only updated the current active
bookmark, and bare update already did that anyway, this is pretty
slim.

Notably, the corresponding test actually works better without this
feature.
2014-08-10 23:09:23 -05:00
Stephen Lee
767b0ab60c update: show message when a bookmark is activated by update
When updating to a bookmark, mention that the bookmark is now
active.  This is a reminder that update does not move the
current bookmark if an explicit target is given - instead
it activates that target.
2013-03-07 14:17:56 +11:00
Siddharth Agarwal
1dfb639cc9 update: when deactivating a bookmark, print a message
This helps prevent user confusion when innocent-seeming commands like
'hg update -C .' are run.
2014-05-14 12:49:55 -07:00
Martin Geisler
7316194bdf tests: don't load unnecessary graphlog extension
Since graphlog is in core, we can use 'hg log -G' instead.
2013-11-22 19:14:17 +01: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
Kevin Bullock
21ed6a41e7 bookmarks: allow bookmark command to take multiple arguments
This change allows setting or deleting multiple bookmarks at once. If more than
one is being set and --inactive is not given, the first one is made active.
2013-05-02 21:28:18 -05:00
Sean Farley
a7c7655a58 bookmarks: fix bug that activated a bookmark even with -r passed
If the current revision was the target revision of -r, then the bookmark would
be active. Test cases have been updated accordingly.
2013-05-01 15:24:21 -05:00
Sean Farley
a1b3b895c9 bookmarks: resolve divergent bookmark when moving across a branch
This patch resolves a single divergent bookmark if a divergent bookmark exists
in the target revision and it current bookmark is not an ancestor of the target
revision, else it would already be handled by the previous patch in this
series.

Test coverage is added.
2013-04-30 21:12:49 -05:00
Sean Farley
b0f6662132 bookmarks: resolve divergent bookmarks when fowarding bookmark to descendant
This patch is a follow-up to 00b2764d68e4 that resolves divergent bookmarks
between the to-be-forwarded bookmark MARK and the new descendant. This
situation can happen when pulling new changesets, updating to the divergent
bookmark, abandoning the previous changesets with strip, and then moving MARK
to MARK@N.

Test coverage is added.
2013-05-01 15:31:39 -05:00
Durham Goode
1b7b932cfc translations: change label integer error to not specify the kind of label
The current error message used the kind (bookmark, branch, tag) in the message.
Unfortunately this isn't easily translatable since some languages give different
genders to these words. The fix is to not specify it at all, since it should be
implicit based on the command the user just ran.

Relevant discussions around this area:
http://selenic.com/pipermail/mercurial-devel/2012-October/045567.html
http://selenic.com/pipermail/mercurial-devel/2012-October/045600.html
2013-04-19 10:55:11 -07:00
Kevin Bullock
9a9dfa03ff bookmarks: moving the active bookmark deactivates it
After this change, moving the active bookmark somewhere other than the
current changeset (i.e., with --rev) deactivates it. Previously it would
remain in .hg/bookmarks.current, which seems like a bug.
2013-03-16 22:48:22 -05:00
Kevin Bullock
8d31377f62 bookmarks: allow (re-)activating a bookmark on the current changeset
Allow a bookmark that points to the current changeset to be made the
active bookmark without requiring --force. Previously, this would've
aborted with:

  abort: bookmark 'Z' already exists (use -f to force)
2013-03-16 21:36:44 -05:00
Kevin Bullock
101aaf42bc bookmarks: fix test broken by 820be3e4f9cb
The added test reflects an error in printing the origin node of the
bookmark that I fixed before committing, but I forgot to update the
test (whoops).
2013-03-16 21:21:54 -05:00
Kevin Bullock
f416be4da5 bookmarks: allow moving a bookmark forward to a descendant
Allow 'hg bookmark MARK', with an existing bookmark MARK, to move the
bookmark forward to the current or specified revision, if the target
revision is a descendant of the revision the bookmark currently points
to. Prints a status message including the revision the bookmark was
formerly at:

  $ hg bookmark Z
  moving bookmark 'Z' forward from 663762316562

Test coverage is added.
2013-03-15 23:39:07 -05:00