Commit Graph

29 Commits

Author SHA1 Message Date
Mads Kiilerich
9d89999d53 rbc: fix invalid rbc-revs entries caused by missing cache growth
It was in some cases possible to end up writing to the cache file without
growing it first. The range assignment in _setcachedata would append instead of
writing at the requested position and thus write the new record in the wrong
place.

To fix this, we avoid looking up in too small caches, and when growing the
cache, do it right before writing the new record to it so we know it has been
done correctly.
2016-07-18 22:22:38 +02:00
Mads Kiilerich
602d2d5529 rbc: test case for cache file not growing correctly, causing bad new entries 2016-07-18 22:21:42 +02:00
Mads Kiilerich
a4030fe6b2 cache: rebuild branch cache from scratch when inconsistencies are detected
This should recover automatically from some corruptions that for unknown
reasons are seen in the wild.
2016-03-13 02:06:23 +01:00
timeless
c7f19c00a6 tests: change branches test to work cross platform
While it is not easy to make a file 000 on Windows, you can
emulate most of the behaviors by replacing the file with a directory.
2016-02-08 05:56:25 +00:00
Matt Mackall
1b6a04b2ec branch: don't warn about branches if repository has multiple branches already
This warning exists to prevent git users from prematurely polluting
their namespace when trying out Mercurial. But for repos that already
have multiple branches, understanding what branches are is not
optional so we should just shut up.
2015-05-22 17:08:59 -05:00
Durham Goode
e0b3f09a3b revbranchcache: write cache even during read operations
Previously we would only actually write the revbranchcache to disk if we were in
the middle of a write operation (like commit). Now we will also write it during
any read operation. The cache knows how to invalidate itself, so it shouldn't
become corrupt if multiple writers try at once (and the write-on-read
behavior/risk is the same as all our other caches).
2015-02-24 18:43:31 -08:00
Durham Goode
6d370da089 revbranchcache: add test for when the cache is not writable
The revbranchecache code already handled the case when the cache file wasn't
writable, but let's add a test as well so future changes don't regress this.
2015-03-17 14:29:56 -07:00
Mads Kiilerich
49a09d3e6c branchcache: add debug output whenever cache files use truncate
The cache files are usually append only but will automatically be truncated and
recover in exceptional situations. Add a debug notice when such exceptional
situations are encountered.
2015-01-14 01:15:26 +01:00
Mads Kiilerich
af5557983d tests: rework revision branch cache tests
The tests that were added with the revision branch cache in 6aa81b0c4658 had
suffered from bit rot in the development iterations. They were no longer that
"good".

Now, the tests are rewritten and reworked to be more readable and maintainable
and relevant for the actual implementation.

This also utilizes the new 'f' helper tool for keeping an eye the cache files.
2015-01-14 01:15:26 +01:00
Mads Kiilerich
61a36ea4fe revset: use localrepo revbranchcache for branch name filtering
Branch name filtering in revsets was expensive. For every rev it created a
changectx and called .branch() which retrieved the branch name from the
changelog.

Instead, use the revbranchcache.

The revbranchcache is used read-only. The revset implementation with generators
and callbacks makes it hard to figure out when we are done using/updating the
cache and could write it back. It would also be 'tricky' to lock the repo for
writing from within a revset execution. Finally, the branchmap update will
usually make sure that the cache is updated before any revset can be run.
The revbranchcache is used without any locking but is short-lived and used in a
tight loop where we can assume that the changelog doesn't change ... or where
it not is relevant to us if it does.

perfrevset 'branch(mobile)' on mozilla-central.
Before:
! wall 10.989637 comb 10.970000 user 10.940000 sys 0.030000 (best of 3)
After, no cache:
! wall 7.368656 comb 7.370000 user 7.360000 sys 0.010000 (best of 3)
After, with cache:
! wall 0.528098 comb 0.530000 user 0.530000 sys 0.000000 (best of 18)

The performance improvement even without cache come from being based on
branchinfo on the changelog instead of using ctx.branch().

Some tests are added to verify that the revbranchcache works and keep an eye on
when the cache files actually are updated.
2015-01-08 00:01:03 +01:00
Yuya Nishihara
ed7051c6c7 tests: write hgrc of more than two lines by using shell heredoc
Here document should be readable than repeating echo commands.
2014-11-04 23:41:46 +09:00
Yuya Nishihara
f415387791 branches: include active, closed and current flags in template output 2014-10-02 23:26:02 +09:00
Yuya Nishihara
ff85e4128c branches: merge white space to format string
Diffs of test output should be harmless.  A white space character is moved
into "log.changeset" color region.
2014-10-02 23:13:56 +09:00
Yuya Nishihara
690eb8ddf7 branches: port to generic templater 2014-10-02 22:59:56 +09:00
Iulian Stana
b1c3535a9b commit: amending with --close-branch (issue3445)
You can't close a branch that hasn't got a head.
newbranch + commit --close-branch must fail
newbranch + commit + commit --amend --close-branch must fail

You must not be allowed to close a branch that is not defined.
2013-05-02 19:36:47 +03:00
Yuya Nishihara
7976fca292 branch: strip whitespace before testing known branch name
Because dirstate._branch() strips leading/trailing spaces from .hg/branch,
"hg branch ' foo '" should abort if branch "foo" exists in another head.

tag command had a similar bug and fixed by 11d102903884.
2013-05-07 23:49:03 +09:00
Mads Kiilerich
7c13eeb821 commit: allow closing "non-head" changesets
Backout 308a153b9120. The changeset prevented closing non-head changesets but
did not provide any rationale or test case and I don't see what value it adds.
Users might have their reasons to commit something anywhere - and close it
immediately.

And contrary to the comment that is removed: The topo heads set is _not_
included in the branch heads set of the current branch. It do not include
closed topological heads.

The change thus prevented closing commits on top of closing commits. A valid
usecase for that is to merge closed heads to reduce the number of topological
heads.

The only existing test coverage for this is the failing double close in
test-revset.t. It was added in dc0e42c06b4e and seems to not be intentional.
2013-04-10 13:12:24 +02:00
Tim Henigan
68a1fc4488 update: allow update to existing branches with invalid names (issue3710)
Starting with 049792af94d6, users are no longer able to update a
working copy to a branch named with a "bad" character (such as ':').

Prior to v2.4, it was possible to create branch names using "bad"
characters, so this breaks backwards compatibility.

Mercurial must allow users to update to existing branches with bad
names.  However, it should continue to prevent the creation of new
branches with bad names.

A test was added to confirm that 'hg update' works as expected. The
test uses a bundled repo that was created with an earlier version of
Mercurial.
2012-11-27 08:47:35 -05:00
Wagner Bruna
cc8c722c61 scmutil: generalize message to make it more i18n-friendly 2012-10-21 11:20:33 -02:00
Kevin Bullock
13bf0fbbec scmutil: add bad character checking to checknewlabel
This factors out the checks from tags and bookmarks, and newly applies
the same prohibitions to branches. checknewlabel takes a new parameter,
kind, indicating the kind of label being checked.

Test coverage is added for all three types of labels.
2012-10-17 21:42:06 -05:00
Mads Kiilerich
fa1c4e5ebe tests: add missing trailing 'cd ..'
Many tests didn't change back from subdirectories at the end of the tests ...
and they don't have to. The missing 'cd ..' could always be added when another
test case is added to the test file.

This change do that tests (99.5%) consistently end up in $TESTDIR where they
started, thus making it simpler to extend them or move them around.
2012-06-11 01:40:51 +02:00
Travis Herrick
c8cb411c3a branches: quiet option observes other parameters 2012-05-06 17:12:22 -07:00
Matt Mackall
a69962e18c branch: warn on branching 2011-12-08 14:32:44 -06:00
Peter Arrenbrecht
5fbc4a50f1 localrepo: reuse parent manifest in commitctx if no files have changed
This speeds up the in-memory version of debugbuilddag that I'm
working on considerably for the case where we want to build just
a 00changelog.i (for discovery tests, for instance).

There are a couple of test changes because node ids in tests
have changed.

The changes to the patch names in test-mq-qdelete.t were required
because they could collide with nodeid abbreviations and newly
actually do (patch "c" collides with id "cafe..." for patch "b").
2011-05-02 19:20:29 +02:00
Danek Duvall
e826f21afa color: add support for terminfo-based attributes and color
Using terminfo instead of hard-coding ECMA-48 control sequences provides a
greater assurance that the terminal codes are correct for the current
terminal type; not everything supports the ANSI escape codes.

It also allows us to use a wider range of colors when a terminal emulator
supports it (such as 16- or 256-color xterm), and a few more non-color
attributes, such as the ever-popular blink.
2011-04-21 13:47:45 -07:00
Mads Kiilerich
635406bf76 tests: use (esc) for all non-ASCII test output 2010-11-08 01:41:41 +01:00
Matt Mackall
08439e0f2d tests: add exit codes to unified tests 2010-09-16 17:51:32 -05:00
Jeremy Whitlock
0a6d3a397f color: enable branches support
This commit updates the branches command to use ui.label for the branch names
and the changeset.  This implementation allows assigning colors to the four
states of a branch: active, closed, current and inactive.  While you can
configure color for the four states, only current and closed have default colors
of green and black bold respectively.
2010-07-28 23:05:03 -06:00
Martin Geisler
20296bc59a tests: unify test-branches 2010-08-14 03:06:52 +02:00