Commit Graph

1217 Commits

Author SHA1 Message Date
Pierre-Yves David
69d3fb6919 obsolete: extract obsolescence marker pulling into a dedicated function
Having a dedicated function will allow us to experiment with other exchange
strategies in an extension. As we have no solid clues about how to do it right,
being able to experiment is vital.

Some transaction tricks are necessary for pull. But nothing too scary.
2013-04-17 11:47:49 +02:00
Pierre-Yves David
0a4431da48 obsolete: extract obsolescence marker pushing into a dedicated function
Having a dedicated function will allows us to experiment with other exchange
strategies in an extension. As we have no solid clues about how to do it right,
being able to experiment is vital.

I intended a more ambitious extraction of push logic, but we are far too
advanced in the release cycle for it.
2013-04-17 11:18:36 +02:00
FUJIWARA Katsunori
ca3aae955c localrepo: use "vfs.rename()" instead of "util.rename()"
This patch makes "_journalfiles()" return a list of pairs of journal
file and corresponded vfs instance instead of a list of journal files
in full path, to use "vfs.rename()" instead of "util.rename()" in
"aftertrans()".

"undofiles()" still returns a list of undo files in full path, because
"repair.strip()" expects such list. It'll be also made to return a
list of pairs of undo file and corresponded vfs at vfs migration for
"repair.strip()" in the near future.
2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
2dcdc7d9fa localrepo: use "vfs.setflags()" instead of "util.setflags()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
721696db5d localrepo: use "vfs.readlink()" instead of "os.readlink()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
bc43776a26 localrepo: use "vfs.islink()" instead of "os.path.islink()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
8e88b218bd localrepo: use "vfs.rename()" instead of "util.rename()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
cd8d850700 localrepo: use "vfs.exists()" instead of "os.path.exists()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
0cbb846680 localrepo: use vfs instead of "os.path.*" in sharedpath checking
In the point of view of efficiency, "vfs" instance created in this
patch should be passed to and reuse in "store.store()" invocation just
after patched code block, because "store" object is initialized by vfs
created with "self.sharedpath".

eBut to focus just on migration from direct file I/O API accessing to
vfs, this patch uses created vfs as temporary one. Refactoring around
"store.store()" invocation will be done in the future.
2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
0860626b09 vfs: split "expand" into "realpath"/"expandpath" to apply each separately
Before this patch, vfs constructor applies both "util.expandpath()"
and "os.path.realpath()" on "base" path, if "expand" is True.

This patch splits it into "realpath" and "expandpath", to apply each
functions separately: this splitting can allow to use vfs also where
one of each is not needed.
2013-04-15 01:22:15 +09:00
Kevin Bullock
666c5947d4 merge with stable 2013-03-25 12:12:41 -05:00
Idan Kamara
8e15165a57 localrepo: always write the filtered phasecache when nodes are destroyed (issue3827)
When the strip command is run, it calls repo.destroyed, which in turn checks if
we read _phasecache, and if we did calls filterunknown on it and flushes the
changes immediately. But in some cases, nothing causes _phasecache to be read,
so we miss out on this and the file remains the same on-disk.

Then a call to invalidate comes, which should refresh _phasecache if it
changed, but it didn't, so it keeps using the old one with the stripped
revision which causes an IndexError.

Test written by Yuya Nishihara.
2013-03-23 13:34:50 +02:00
Matt Mackall
5e321b6e3e setparents: drop copies from dropped p2 (issue3843) 2013-02-28 21:29:31 -06:00
Pierre-Yves David
271a03e73f subrepo: allows to drop courtesy phase sync (issue3781)
Publishing server may contains draft changeset when they are created locally. As
publishing is the default, it is actually fairly common. Because of this
"inconsistency" phases synchronization may be done even to publishing server.

This may cause severe issues for subrepo. It is possible to reference read-only
repository as subrepo. Push in a super repo recursively push subrepo. Those
pushes to potential read only repo are not optional, they are "suffered" not
"choosed". This does not break because as the repo is untouched the push is
supposed to be empty. If the reference repo locally contains draft changesets, a
courtesy push is triggered to turn them public. As the repo is read only, the
push fails (after possible prompt asking for credential). Failure of the
sub-push aborts the whole subrepo push. This force the user to define a custom
default-push for such subrepo.

This changeset introduce a prevention of this error client side by skipping the
courtesy phase synchronisation in problematic situation. The phases
synchronisation is skipped when four conditions are gathered:
- this is a subrepo push, (normal push to read-only repo)
- and remote support phase
- and remote is publishing
- and no changesets was pushed (if we pushed changesets, repo is not read only)

The internal config option used in this version is not definitive. It is here to
demonstrate a working fix to the issue.

In the future we probably wants to track subrepo changes and avoid pushing to
untouched one. That will prevent any attempt to push to read-only or unreachable
subrepo.

Another fix to prevent courtesy push from older clients to push to newer server
is also still needed.
2013-01-31 01:44:29 +01:00
Pierre-Yves David
d3771a5324 pull: fix crash when pulling changeset that get hidden locally (issue3788)
When you have obsolescence marker that apply to a pulled changesets, the added
changeset is immediately filtered. Then the list of added changeset needs to be
build against and unfiltered repo.
2013-01-29 15:26:10 +01:00
Kevin Bullock
9b7121a10b merge with stable 2013-03-01 10:05:37 -06:00
Bryan O'Sullivan
1f74847761 localrepo: iterate over manifest key/value pairs in status
This saves us a couple of dict lookups in the common case, and improves
the performance of the status method by 5% (measured with util.timed)
in a repo with a large manifest.
2013-02-22 10:05:22 -08:00
Durham Goode
7b7c4c6333 blackbox: do not translate the log messages
User 'timeless' in irc mentioned that having the blackbox be
translated would result in logs that:

- may be mixed language, if multiple users use the same repo
- are not google searchable (since searching for english gives more
  results)
- might not be readable by an admin if the employee is using hg in
  his native language

And therefore we should log everything in english.
2013-02-13 12:51:30 -08:00
Durham Goode
e35379ebe6 blackbox: only show new heads on incoming
The blackbox was logging every head after every incoming group.
Now we only log the heads that have changed.

Added a test.  Moved the hooks test to the bottom of the file since
the hooks interfer with the tests after it.
2013-02-13 11:07:01 -08:00
Durham Goode
484931bacf blackbox: log incoming changes via ui.log()
Logs incoming changes to a repo to ui.log(). Includes the number of changes
and the hashes of the heads after the new changes.

Example log line:
2013/02/09 08:35:19 durham> 1 incoming changes - new heads: cb9a9f314b8b

Currently the blackbox logs the unix user that is performing the push/pull.
It would be nice to log the http authorized user as well so it works with
hgweb, but that's outside the scope of this commit.
2013-02-09 09:04:48 -08:00
David Schleimer
1dc36ff74c commit: factor out post-commit cleanup into workingctx
This pulls some of the logic for the cleanup that needs to happen
after a commit has been made otu of localrepo.commit and into
workingctx.  This is part of a larger refactoring effort that will
eventually allow us to perform some types of merges in-memory.
2013-02-08 05:36:08 -08:00
David Schleimer
21ed11fec2 localrepo: use workingctx for validation in commit
This changes localrepo.commit to use the workingctx it creates form
the munged output of localrepo.status while running some precommit
validation.  Specifically, it uses functions that were already present
on the workingctx.  I believe this is a net readabilty improvement,
and that this makes these lines consistent with the refactoring in a
subsequent patch that pulls some of the validation logic into
workingctx so that it can be reused elsewhere.
2013-02-08 05:36:08 -08:00
David Schleimer
6086bc3471 localrepo: create context used for actual commit earlier
localrepo.commit creates a workingctx, calls self.status, does some
munging on the changes status returns, does some validation on those
changes, and then creates a new workingctx from the changes.  This
moves the creation of the new workginctx ahead of some validation,
with the intention of refactoring some of that validation logic into
the workingctx, so that it can be reused elsewhere.
2013-02-08 05:36:07 -08:00
Mads Kiilerich
5787baee50 spelling: fix some minor issues found by spell checker 2013-02-10 18:24:29 +01:00
Sune Foldager
4060ac68c4 validate: check for spurious incoming filelog entries
Accepting those will lead to "mild corruption", correctly reported as
an error by hg verify, but often not a problem in practice.

Enabled when server.validate is switched on.
2012-12-11 20:13:21 +01:00
Pierre-Yves David
38d5ce29ff stream_in: write the remote branchcache for a usage as wide as possible
Writing cache for unfiltered repo only is barely useful, Most repo user are now
at least use the `hidden` filter. This changeset now assigns the remote cache
for a filter as low as possible for a wider reuse as possible.
2013-01-16 00:12:01 +01:00
Pierre-Yves David
8dfd629879 destroyed: update unserved branchcache instead
Before this changesets the `destroyed` function  updated the branchcache for
unfiltered repository. As seen in a previous changeset, Read only repo does
not cares about the unfiltered repo. We now update it for `unserved`.
2013-01-15 23:33:07 +01:00
Pierre-Yves David
f72cabb4c0 destroyed: drop complex branchcache rebuilt logic
The strip code used a trick to lower the cost of branchcache update after a
strip. However is less necessary since we have branchcache collaboration.
Invalid branchcache are likely to be cheaply rebuilt again a near subset of the
repo.

Moreover, this trick would need update to be relevant in the now filtered
repository world. It currently update the unfiltered branchcache that few people
cares about. Make it smarter on that aspect would need complexes update of the
calling logic


So this mechanism is:
- Arguably needed,
- Currently irrelevant,
- Hard to update
and I'm dropping it.

We now update the branchcache in all case by courtesy of the read only reader.

This changeset have a few expected impact on the testsuite are different cache
are updated.
2013-01-16 00:09:26 +01:00
Pierre-Yves David
7bfec59c0b branchmap: update cache of 'unserved' filter on new changesets
The `commitctx` and `addchangegroup` methods of repo upgrade branchcache after
completion. This behavior aims to keep the branchcache in sync for read only
process as hgweb. See b4909adfc093 for details.

Since changelog filtering is used, those calls only update the cache for unfiltered repo.
One of no interest for typical read only process like hgweb.

Note: By chance in basic case, `repo.unfiltered() == repo.filtered('unserved')`

This changesets have the "unserved" cache updated instead. I think this is the
only cache that matter for hgweb.

We could imagine updating all possible branchcaches instead but:
- I'm not sure it would have any benefit impact. It may even increase the odd of
  all cache being invalidated.
- This is more complicated change.

So I'm going for updating a single cache only which is already better that
updating a cache nobody cares about.

This changeset have a few expected impact on the testsuite are different cache
are updated.
2013-01-16 00:08:08 +01: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
2d6545f8b6 subrepos: process subrepos in sorted order
Add sorted() in places found by testing with PYTHONHASHSEED=random and code
inspection.

An alternative to sprinkling sorted() all over would be to change substate to a
custom dict with sorted iterators...
2012-12-12 02:38:14 +01:00
Mads Kiilerich
26b3c84619 localrepo: store requirements sorted 2012-12-12 02:38:14 +01:00
Idan Kamara
ddb5b141cc localrepo: drop unnecessary check on wlock unlock
Calling out to dirstate one line before guarantees that it'll be in the filecache.
2013-01-10 23:57:03 +02:00
Idan Kamara
dc1e34eda3 rollback: don't clear the filecache
This was an old workaround to force the filecache to reload everything. Now
that the syncing issue is fixed, we no longer need it.
2013-01-09 20:36:53 +02:00
Idan Kamara
ca54b38975 destroyed: keep the filecache in sync with __dict__ (issue3335) (issue3693) (issue3743)
We need to make sure that if X is in the filecache then it's also in the
filecache owner's __dict__, otherwise it will go out of sync:

repo.X                  # first access to X, records stat info in
                        # filecache and updates __dict__
repo._filecache.clear() # removes X from _filecache but it's still in __dict__
repo.invalidate()       # iterates over _filecache and removes entries
                        # from __dict__, but X isn't in _filecache, so
                        # it's kept in __dict__
repo.X                  # X is fetched from __dict__, bypassing the filecache
2013-01-09 20:37:44 +02:00
Idan Kamara
b367739fa0 localrepo: write the phasecache when destroying nodes 2013-01-11 00:05:52 +02:00
Idan Kamara
a5fb16be88 localrepo: update the branchmap when destroying nodes
This was previously called directly during strip. Moving it to destroying
also means that it'll be called through _rollback, which seems harmless.
2013-01-05 16:50:12 +02:00
Idan Kamara
bd84da5670 localrepo: introduce destroying function 2012-12-15 20:08:13 +02:00
Idan Kamara
7b192e750c localrepo: don't refresh filecache entries that aren't in __dict__
We call invalidate to remove properties from __dict__ because they're
possibly outdated and we'd like to check for a new version. Next time
the property is accessed the filecache mechanism checks the current stat
info with the one recorded at the last time the property was read, if
they're different it recreates the property.

Previously we refreshed the stat info on all properties in the filecache
when the lock is released, including properties that are missing from
__dict__. This is a problem because:

  l = repo.lock()
  repo.P          # stat info S for P is recorded in _filecache
  <changes are made to repo.P indirectly, e.g. underlying file is replaced>
                  # P's new stat info = S'
  l.release()     # filecache refreshes, records S' as P's stat info

At this point our filecache contains P with stat info S', but P's
version is from S, which is outdated.

The above happens during _rollback and strip. Currently we're wiping the
filecache and forcing everything to reload from scratch which works but
isn't the right solution.
2012-12-16 23:13:02 +02: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
433ce5d8f8 clfilter: drop extra filtering in localpeer
The repository used by localpeer is already filtered. We no longer
need to call a special function.
2013-01-06 04:28:52 +01:00
Pierre-Yves David
158ce0ffec clfilter: make localpeer use a repo with "unserved" filter
This changeset installs a broad filter on most repos used for
serving. This removes the need to use the `visiblehead`/`visiblebranchmap`
functions, and ensures that changesets we should not serve are in
fact never served.

We do not use filtering on hgweb yet, as there is still a number
of issues to solve there.
2013-01-06 04:41:11 +01:00
Pierre-Yves David
136b6255e0 hidden: drop of the repo.hiddenrevs property
It does not have any user left
2013-01-03 18:52:59 +01:00
Pierre-Yves David
49792eaad1 hidden: drop cache on hiddenrevs property
The `filteredrevs` function already have a cache mechanism. And this cache in
invalidated at the same time than the current property cache. So we drop the
cache on the property.

The property itself is going to be dropped soon.
2013-01-08 14:16:49 +01:00
Pierre-Yves David
d9a61344d3 hidden: move computation in filter function
There is not good reason for this computation to be handle in a different way
from the other. We are moving the computation of hidden revs in the filter
function. In later changesets, code that access to `repo.hiddenrevs` will be
updated and the property dropped.
2013-01-08 14:10:29 +01:00
Pierre-Yves David
9f5750c56a destroyed: filter unknown before computing branchcache
Branchcache of filtered version need up to date phase data.
2013-01-04 19:05:20 +01:00
Pierre-Yves David
dd98ce8d6f branchmap: disable fallback to unfiltered branchcache
Disables this simple optimisation to allow coming more powerfull approach: cache
collaboration.

Our goal is to have branchcache collaborate. This means that unfiltered
branchcache will fallback to some filtered branchcache if invalid. We can't have
the filtered branchcache to use the unfiltered one. That would loop.
2013-01-02 01:36:57 +01:00
Idan Kamara
92fd1426f3 localrepo: filter unknown nodes from the phasecache on destroyed
When commit is followed by strip (qrefresh), phasecache contains nodes that were
removed from the changelog. Since phasecache is filecached with .hg/store/phaseroots
which doesn't change as a result of stripping, we have to filter it manually.

If we don't write it immediately, the next time it is read from disk the nodes
will be filtered again. That's what happened before, but there's no reason not
to write it immediately.

The change in test-keyword.t is caused by the above.
2012-12-21 17:19:52 +01:00
Pierre-Yves David
458159ba53 localrepo: drop _cacheabletip method
It iss dead code now.
2013-01-04 01:37:38 +01:00
Pierre-Yves David
0cd9115520 branchmap: enable caching for filtered version too
The `_branchcache` attribute is turned into a dictionary. Key are filter name and
value is a `branchcache` object. Unfiltered version is cached as `None` filter.

The attribute is renamed to `_branchcaches` to avoid confusion with the previous
one. Both old and new contents are dictionary even if their contents are
different. I prefer possible extension code to crash right away instead of just
messing the wrong dictionary.

As all different caches work isolated to each other, this code keeps the
previous behavior of using the unfiltered cache  we nothing is filtered.  This
is a cheap way to have cache collaborate and nullify potential impact in the
default case.
2012-12-24 03:21:15 +01:00