Commit Graph

1295 Commits

Author SHA1 Message Date
Pierre-Yves David
4d4c1e240e clfilter: add actual repo filtering mechanism
We add a `filtered` method on repo. This method return an instance of `repoview`
that behaves exactly as the original repository but with a filtered changelog
attribute. Filters are identified by a "name". Planned filter are `unserved`,
`hidden` and `mutable`. Filtering the repository in place what out of question
as it wont not allows multiple thread to share the same repo. It would makes
control of the filtering scope harder too. See the `repoview` docstring for
details.

A mechanism to compute filtered revision is also installed. Some caches will be
installed in later commit.
2012-12-20 15:32:42 +01:00
Siddharth Agarwal
28d6c979cc localrepo: use lazy ancestor membership testing
For a repository with over 400,000 commits, rebasing one revision near tip,
this avoids two treks up the DAG, speeding the operation up by around 1.6
seconds.
2012-12-17 20:43:37 -08:00
Pierre-Yves David
fe7c7f379e clfilter: fix nodemap usage in getbundle
With the current implementation, `changelog.nodemap` is not filtered. So some
filtered changeset in common are not filtered by `n in nodemap`. This leads to
crash lower in the stack when the bundle generation try to access those node on
a filtered changelog.
2012-12-10 18:12:41 +01:00
Pierre-Yves David
2038eca723 obsolete: refuse to push divergent changeset
As other troubles `unstable` and `bumped`. Followup patches may simplify the
push code with unification of "obsolescence troubles" handling.
2012-11-10 02:19:20 +01:00
Mads Kiilerich
ac8e1fc147 check-code: there must also be whitespace between ')' and operator
The check pattern only checked for whitespace between keyword and operator.

Now it also warns:
 >     x = f(),7
 missing whitespace after ,
 >     x = f()+7
 missing whitespace in expression
2012-12-09 23:33:16 +01:00
Kevin Bullock
1ff9eb737c push: reunite comment with the line of code it describes 2012-12-07 12:03:37 -06:00
Pierre-Yves David
5ccc6bfa9a clfilter: rename unfilteredmeth to unfilteredmethod
As originally intended.
2012-11-30 22:34:21 +01:00
Pierre-Yves David
ff24df652d clfilter: ensure that filecache on localrepo is unfiltered
All filecache usage on repo is for logic that should be unfiltered. The
caches should be common to all filtered instances, and computation must
be done unfiltered.  A dedicated storecache subclass is created for
this purpose.
2012-10-08 19:34:04 +02:00
Pierre-Yves David
b25a880a8e clfilter: add a propertycache that must be unfiltered
Some of the localrepo property caches must be computed unfiltered and
stored globally. Some others must see the filtered version and store data
relative to the current filtering.

This changeset introduces two classes `unfilteredpropertycache`
and `filteredpropertycache` for this purpose. A new function
`hasunfilteredcache` is introduced for unambiguous checking for cached
values on unfiltered repos.

A few tweaks are made to the property cache class to allow overriding
the way the computed value is stored on the object.

Some logic relative to _tagcaches is cleaned up in the process.
2012-10-08 20:02:20 +02:00
Pierre-Yves David
f922bebdae clfilter: use unfiltered repo for bookmark push logic
The remote location of the bookmark may be filtered locally. This
changeset ensures that bookmark movement logic has access to all the
repo's content.
2012-10-08 17:50:02 +02:00
Pierre-Yves David
d9bba16b21 clfilter: unfilter some parts of the push logic
Computation of common changesets during push needs to be done on the
widest set possible. An unfiltered version of the repo is kept for
discovery and various revset calls. The discovery code itself enforces
the filtering of unserved outgoing changeset.
2012-10-08 17:41:07 +02:00
Pierre-Yves David
a986d5d38d clfilter: ensure changeset creation in the repo is run unfiltered
This applies to both creation of new commits and application of
changegroups.
2012-11-26 19:24:11 +01:00
Pierre-Yves David
2fcc95d40f clfilter: ensure changegroup generation is run unfiltered
Changegroup generation logic needs to be aware of the whole repository
to work properly.
2012-11-26 19:23:25 +01:00
Pierre-Yves David
2f515d9fde clfilter: ensure rollback is run unfiltered
Rollback logic needs to be aware of the whole repository to work properly.
2012-11-26 19:21:24 +01:00
Pierre-Yves David
e0ecf6ce0b clfilter: ensure cache invalidation is done on the main unfiltered repo
The proxy version will not hold any cache for now. But we have to ensure
all cache operations are done on the unfiltered version.
2012-11-26 19:22:12 +01:00
Pierre-Yves David
e12b53d0bd clfilter: ensure that tag logic runs unfiltered
The current tag logic is not aware of filtering. We keep the status quo,
ensuring that the tag cache is computed as before: without any filtering.
2012-11-26 19:26:24 +01:00
Pierre-Yves David
bc880d748e clfilter: ensure branchcache logic runs unfiltered
The current branchcache construction is not aware of filtering. We keep
the status quo, ensuring that the branch cache logic is computed as
before: without any filtering.
2012-11-26 19:25:44 +01:00
Pierre-Yves David
edc0b7dbec clfilter: introduce an unfilteredmethod decorator
This decorator ensure the method in run on an unfiltered version of the
repository. See follow-up commit for details.

This decorator is not named `unfiltered` because it would clash with the
`unfilteredmethod` on `localrepo` itself.
2012-11-26 19:11:13 +01:00
Pierre-Yves David
8d8e5b22ad clfilter: introduce an "unfiltered" method on localrepo
This commit is part of the changelog level filtering effort. It returns
the main "unfiltered" version of a repo-like object. For localrepo this
means the same localrepo object. But this method will be overwritten
by the filtered versions of a repository to return the core unfiltered
version of the repo.

Introducing this simple method first allows later commits to prepare
for the use of a filtered version of a repository.

A new repo method is added because a lot of users may call it. At the
end of this series of commits, about 40 calls exist in core and hgext.
2012-11-21 00:36:29 +01: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
42a23bce4e obsolete: add missing line feed in debug error message 2012-10-19 13:52:34 +02:00
Thomas Arendsen Hein
6e6ed4e398 localrepo: translate "push includes X changeset" only once
This was introduced in 72831ff4aa10
2012-10-23 09:22:46 +02:00
Pierre-Yves David
b3155544bd push: refuse to push bumped changeset
This applies the same logic as used for `obsolete` and `unstable` changesets.
Refuse to push them without force.

We'll probably want to factor this logic with two new functions
`pctx.troubled()` and `ctx.troubles()`. But I'm waiting for the third
"trouble" to make it into core.
2012-10-19 00:50:12 +02:00
push includes an xxx changeset: yyyyyyyyyy
8af08441ab obsolete: simplify push abort message
to:   push includes xxx changeset: yyyyyyyyyy
2012-10-19 00:46:39 +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
Kevin Bullock
4abe92a68a tag: disallow '\0' in tag names
This brings the list of disallowed characters in line with bookmarks.
2012-10-17 21:39:07 -05:00
Tomasz Kleczek
8b2ac179dd branchcache: fetch source branchcache during clone (issue3378)
Recomputing branch cache on clone may be expensive,
therefore if possible we fetch it along with the data.

- If the clone is performed by copying, we just copy branchcache file.
- If we localrepo.clone and streaming then we follow the procedure:
  1. Fetch branchmap from the remote
  2. Fetch the actual data.
  3. Find the latest rev within branch heads (tip at the time of
     branchmap fetch)
  4. Update the cache for the revs in [remotetip+1, tip]

This way we ensure that the branchcache is correct even in case
of races with commits.
2012-10-03 13:19:53 -07:00
Pierre-Yves David
db63606246 hidden: remove tags use in hidden computation
Tags initially prevented revision to be hidden. It seemed a bad idea to have
tags refer to revisions that one can't see. But proper filtering of hidden
revisions excludes them from tag computation. Coming changelog filtering will do
that. Anyway, tags that really matter will likely be public and therefore not
hidden.

The current working directory parent and bookmarked revision are still not
hidden. Bookmarks were likely automatically moved at rewrite time, bookmarks
that remain on obsolete revisions were probably moved there on purpose.
2012-09-03 14:35:31 +02:00
Pierre-Yves David
3fc4db8ab5 clfilter: do not use tags cache if there are filtered changesets
If there are filtered changesets the cache is not valid. We'll have to cache
tags for filtered state too, but for now recomputing the tags is enough.
2012-09-03 14:35:05 +02:00
Pierre-Yves David
9ed771c48f clfilter: do not use branchmap cache if there are filtered changesets
If there are filtered changesets the cache is not valid. We'll have to cache
branchmap for filtered state too, but for now recomputing the branchmap is
enough.
2012-09-03 14:34:19 +02:00
Pierre-Yves David
df82aab75f clfilter: remove usage of range in favor of iteration over changelog
If we want to apply filtering at changelog level, we need to iterate over it.
See previous changeset description for details.
2012-09-20 19:01:53 +02:00
Pierre-Yves David
2b76effa06 filter: updatebranchcache during addchangegroup instead of after lock
The forced recomputation of the branch cache was introduced by `b4909adfc093`.
Back there, `addchangegroup` did not handle any lock logic.

Later `6042c410e045` introduced lock logic to `addchangegroup`. Its description
does not explain why the `updatebranchcache` call is made outside locking. I
believe that the lock was released there because it fit well with the transaction
release already in the code.

Finally `1eda82d76f0c` moved all "unlocked" code of `addchangegroup` to an
`repo._afterlock` callback.

I do not think that the call to `updatebranchcache()` requires to be done
outside locking. That may even be a bad idea to do so. Bringing this call back
in the `addchangegroup` function makes the flow simpler and eases the following
up changelog level filtering business.
2012-09-03 14:03:38 +02:00
FUJIWARA Katsunori
3562bbd4bf localrepo: use "vfs" constructor/field for initialization around "store" 2012-08-31 02:06:29 +09:00
FUJIWARA Katsunori
c303a9b344 localrepo: use "vfs" constructor instead of "opener" one
This patch also changes initialization order of "*opener" and "*vfs"
fields: first, "*vfs" fields are initialized , and then, "*opener"
ones are initialized.
2012-08-31 02:06:29 +09:00
Pierre-Yves David
342b88a402 bookmarks: extract valid destination logic in a dedicated function
We usually update bookmarks only if the new location is descendant of the old
bookmarks location.  We extract this logic into a function. This is the first
step to allow more complex logic using obsolescence in this validation of the
bookmark movement.
2012-08-26 00:28:56 +02:00
Bryan O'Sullivan
dc9ede17dc Merge spelling fixes 2012-09-11 08:36:09 -07:00
Pierre-Yves David
785d90eba0 obsolete: introduce caches for all meaningful sets
This changeset introduces caches on the `obsstore` that keeps track of sets of
revisions meaningful for obsolescence related logics. For now they are:

- obsolete: changesets used as precursors (and not public),
- extinct:  obsolete changesets with osbolete descendants only,
- unstable: non obsolete changesets with obsolete ancestors.

The cache is accessed using the `getobscache(repo, '<set-name>')` function which
builds the cache on demand. The `clearobscaches(repo)` function takes care of
clearing the caches if any.

Caches are cleared when one of these events happens:

- a new marker is added,
- a new changeset is added,
- some changesets are made public,
- some public changesets are demoted to draft or secret.

Declaration of more sets is made easy because we will have to handle at least
two other "troubles" (latecomer and conflicting).

Caches are now used by revset and changectx. It is usually not much more
expensive to compute the whole set than to check the property of a few elements.
The performance boost is welcome in case we apply obsolescence logic on a lot of
revisions. This makes the feature usable!
2012-08-28 20:52:04 +02:00
timeless@mozdev.org
fbc4fce27b en-us: initialization 2012-08-17 13:58:19 -07:00
timeless@mozdev.org
6ed8f5a58d spelling: synchronize 2012-08-17 13:58:19 -07:00
timeless@mozdev.org
36508e0e39 spelling: supersede 2012-08-17 13:58:19 -07:00
timeless@mozdev.org
326011a329 spelling: efficiently 2012-08-17 13:58:18 -07:00
timeless@mozdev.org
2a09dc2301 spelling: Explicitly 2012-08-17 13:58:18 -07:00
Sune Foldager
801d60844a rollback: write dirstate branch with correct encoding 2012-08-15 12:04:50 +02:00
Pierre-Yves David
76446449c3 test: remove invalid hidden rev in graphlog test
The hidden set of revision can not have descendant outside this set.

The extension is patched to raise and exception when this happen.
2012-08-30 22:13:24 +02:00
Mads Kiilerich
e973af65d0 improve some comments and docstrings, fixing issues found when spell checking 2012-08-21 02:41:20 +02:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Matt Mackall
30afcc9869 commit: normalize filenames when checking explicit files (issue3576) 2012-08-17 14:37:59 -05:00
Idan Kamara
45c5c92f05 localrepo: clear the filecache on _rollback() and destroyed()
This restores the old behaviour of clearing the filecache when the repo is
destroyed but combines it with also clearing it on _rollback. Before, we tried
to only call it through _rollback but that ruined callers of destroyed.

Doing it on both code paths covers destroyed being called from somewhere
else, e.g. strip.
2012-07-28 22:40:30 +03:00
Thomas Arendsen Hein
5fae640775 obsolete: fix typos in comments introduced by 2a0d51a9982b 2012-07-31 15:57:50 +02:00
Mads Kiilerich
688b9e2048 check-code: indent 4 spaces in py files 2012-07-31 03:30:42 +02:00
Pierre-Yves David
fd393b84f3 pushkey: do not exchange obsole markers if feature is disabled
This apply to both push and pull both when client or server.
2012-07-28 13:33:06 +02:00
Pierre-Yves David
2b1b13bd1d obsolete: warns if markers exist in a repo where the feature is not enabled
We don't simply abort to allow the user to run other diagnostic commands.
2012-07-28 13:05:25 +02:00
Pierre-Yves David
dd7869713e pushkey: splits obsolete marker exchange into multiple keys
Obsolete markers are now exchanged in smaller pieces that fit in a http header.

This changes is done to avoid 400 bad request error when exchanging obsolete
puskey over http.

The last key pushed is always hold by the "dump0" key to ensure an easy place to
hook for people who need it.
2012-07-27 18:32:56 +02:00
Pierre-Yves David
44bf164af6 obsolete: add debug output regarding obsolete marker exchange. 2012-07-26 16:41:42 +02:00
Pierre-Yves David
a4bba98ab8 pushkey: add more verbose debug output regarding pushkey
Very few data are displayed now, making it hard to debug phases and obsolete
related issues.
2012-07-28 12:28:35 +02:00
Patrick Mezard
f40d444448 push: do not try to push remote obsolete if local has none 2012-07-24 21:20:56 +02:00
Patrick Mezard
7221d12e58 discovery: add extinct changesets to outgoing.excluded
Before this change, push would incorrectly fast-path the bundle
generation when extinct changesets are involved, because they are not
added to outgoing.excluded. The reason to do so are related to
outgoing.excluded being assumed to contain only secret changesets by
scmutil.nochangesfound(), when displaying warnings like:

 changes found (ignored 9 secret changesets)

Still, outgoing.excluded seems like a good API to report the extinct
changesets instead of dedicated code and nothing in the docstring
indicates it to be bound to secret changesets. This patch adds extinct
changesets to outgoing.excluded and fixes scmutil.nochangesfound() to
filter the excluded node list.

Original version and test by Pierre-Yves.David@ens-lyon.org
2012-07-25 19:34:31 +02:00
Pierre-Yves David
dab9cf6c01 _updatebranchcache: prevent deleting dict key during iteration
We use dict.keys() to fetch all keys before starting to delete some. Otherwise
python complains that the dictionnary is altered during iteration.
2012-07-17 16:16:17 +02:00
Pierre-Yves.David@ens-lyon.org
a82f344ba4 obsolete: mark unreachable extinct changesets as hidden
The repo.hiddenrevs set is updated with all extinct() changesets which aren't
descendants of either:

- the current working copy,
- a bookmark,
- a tag.
2012-07-16 17:56:50 +02:00
Pierre-Yves David
edc2b520d9 hidden: move hiddenrevs set on the repository
This set is always accessed through the repo for now. Having this set
carried by the changelog make it complicated to:

- initialize it, computing hidden set may involve revset call
- lazy compute it, (1) only the changelog can detect someone access it,
                   (2) only the repo have enought knowledge to compute it.

In later version I expect he changelog to apply filtering itself and the set to
be carried by changelog again.
2012-07-16 17:44:46 +02:00
Pierre-Yves David
afa28ff113 repo: move visibleheads and visiblebranchmap logic in discovery
They were previously inside the mercurial.phases module, but obsolete
logic will need them to exclude `extinct` changesets from pull and
push.

The proper and planned way to implement such filtering is still to apply a
changelog level filtering. But we are far to late in the cycle to implement and
push such a critical piece of code (changelog filtering). With Matt Mackall
approval I'm extending this quick and dirty mechanism for obsolete purpose.

Changelog level filtering should come during the next release cycle.
2012-07-17 01:22:31 +02:00
Pierre-Yves David
ae5abd69f4 localpeer: return only visible heads and branchmap
Now that we have localpeer, we can apply filtering on heads and branchmap the
same way it's done for wireprotocol peer.
2012-07-17 01:04:45 +02:00
Sune Foldager
e82027e6f3 peer: remove cancopy from peer api; use directly on repo instead 2012-07-13 21:52:37 +02:00
Sune Foldager
7045c35403 peer: introduce canpush and improve error message 2012-07-13 21:52:28 +02:00
Peter Arrenbrecht
ef7b77046e peer: introduce real peer classes
This change separates peer implementations from the repository implementation.
localpeer currently is a simple pass-through to localrepository, except for
legacy calls, which have already been removed from localpeer. This ensures that
the local client code only uses the most modern peer API when talking to local
repos.

Peers have a .local() method which returns either None or the underlying
localrepository (or descendant thereof). Repos have a .peer() method to return
a freshly constructed localpeer. The latter is used by hg.peer(), and also to
allow folks to pass either a peer or a repo to some generic helper methods.
We might want to get rid of .peer() eventually.

The only user of locallegacypeer is debugdiscovery, which uses it to pose as a
pre-setdiscovery client. But we decided to leave the old API defined in
locallegacypeer for clarity and maybe for other uses in the future.

It might be nice to actually define the peer API directly in peer.py as stub
methods. One problem there is, however, that localpeer implements
lock/addchangegroup, whereas the true remote peers implement unbundle.
It might be desireable to get rid of this distinction eventually.
2012-07-13 21:47:06 +02:00
Pierre-Yves David
9cbee4c2aa push: fix bug in detection of remote obsolete support
Current code check obsolete availability in local repo.
2012-07-12 03:03:19 +02:00
Pierre-Yves David
3f157ec6fb push: refuse to push unstable changesets without force
User should resolve unstability locally before pushing the same way we encourage
user to merge locally instead of pushing a new remote head.

If we are to push obsolete changeset, at least one set of the pushed set will be
either obsolete or unstable. The check is narrowed to only heads.
2012-07-10 01:39:03 +02:00
Pierre-Yves David
34e21f9d79 push: refuse to push obsolete changesets
This is a first version. Simple but not very efficient.

Note that this changeset introduce the "obsolete" word in the UI.
2012-07-10 01:32:18 +02:00
FUJIWARA Katsunori
64cae05faf localrepo: use file API via vfs while ensuring repository directory
As a part of migration to vfs, this patch invokes some file API
indirectly via vfs, while ensuring repository directory in the
constructor of "localrepository" class.

New file API are added to "scmutil.abstractopener" class, because they
are also used via other derived classes than "scmutil.opener".

But "join()" is not yet defined other than "scmutil.opener" class,
because it should not be used via other opener classes yet.
2012-07-06 18:45:27 +09:00
FUJIWARA Katsunori
1c926cc201 localrepo: use "vfs" intead of "opener" while ensuring repository directory
As a part of migration to vfs, this patch uses "self.vfs" instead of
"self.opener", while ensuring repository directory in the constructor
of "localrepository" class.
2012-07-06 18:45:27 +09:00
FUJIWARA Katsunori
204c7d4046 localrepo: use the path relative to "self.vfs" instead of "path" argument
As a part of migration to vfs, this patch uses "self.root", which can
be recognized as the path relative to "self.vfs", instead of "path"
argument.

This fix allows to make invocations of "util.makedirs()" and
"os.path.exists()" while ensuring repository directory in
"localrepository.__init__()" ones indirectly via vfs.

But this fix also raises issue 2528: "hg clone" with empty destination.

"path" argument is empty in many cases, so this issue can't be fixed
in the view of "localrepository.__init__()".

Before this patch, it is fixed by empty-ness check ("not name") of
exception handler in "util.makedirs()".

    try:
        os.mkdir(name)
    except OSError, err:
        if err.errno == errno.EEXIST:
            return
        if err.errno != errno.ENOENT or not name:
            raise

This requires "localrepository.__init__()" to invoke "util.makedirs()"
with "path" instead of "self.root", because empty "path" is treated as
"current directory" and "self.root" becomes valid path.

But "hg clone" with empty destination can be detected also in
"hg.clone()" before "localrepository.__init__()" invocation, so this
patch re-fixes issue2528 by checking it in "hg.clone()".
2012-07-06 18:45:27 +09:00
FUJIWARA Katsunori
765d4328c8 localrepo: use "self.wvfs.join()" instead of "os.path.join()"
As a part of migration to vfs, this patch uses "self.wvfs.join()"
instead of "os.path.join()", while initialization of fields in the
constructor of "localrepository" class.
2012-07-06 18:45:27 +09:00
FUJIWARA Katsunori
d20072de6a localrepo: use path expansion API via vfs
As a part of migration to vfs, this patch moves path expansion API
invocations in the constructor of "localrepository" to the constructor
of "opener", because the root path to the repository is very important
to handle paths using non-ASCII characters correctly.

This patch also rearrange initialization order of "wvfs" field,
because it is required to initialize "self.root".
2012-07-06 18:45:27 +09:00
FUJIWARA Katsunori
dad1f854dd localrepo: add "vfs" fields to "localrepository" for migration from "opener"
As a part of migration to vfs, this patch adds "vfs" fields to
"localrepository" class.

This allows new codes to access current "opener" objects related to
repositories via "vfs" fields, so patches referring to "vfs" will
replace referring to "opener" in time.

This patch also adds initializations for "vfs" fields to
"statichttprepository" class derived from it, because its constructor
doesn't invoke the constructor of "localrepository", so "vfs" fields
should be initialized explicitly as same as "opener" fields: it has no
working directory, so "wvfs" field is not added.
2012-07-06 18:45:26 +09:00
Martin Geisler
c52341ae3f merge with main 2012-07-12 10:03:50 +02:00
Bryan O'Sullivan
f9d692c823 localrepo: make requirements and openerreqs mutable by subclasses
This is necessary for extensions that need to modify a repo's
requirements.
2012-07-11 15:36:00 -07:00
Pierre-Yves David
100b68ca2e obsolete: write obsolete marker inside a transaction
Marker are now written as soon as possible but within a transaction. Using a
transaction ensure a proper behavior on error and rollback compatibility.

Flush logic are not necessary anymore and are dropped from lock release.

With this changeset, the obsstore is open, written and closed for every single
added marker. This is expected to be highly inefficient and batched write should
be implemented "quickly".

Another issue is that every flush of the file will invalidate the obsstore
filecache and trigger a full re instantiation of the repo.obsstore attribute
(including, reading and parsing entry). This is also expected to be highly
inefficient and proper filecache operation should be implemented "quickly" too.

A side benefit of the filecache issue is that repo.obsstore  object is properly
invalidated on transaction abortion.
2012-07-04 02:21:04 +02:00
Pierre-Yves David
587d4505e1 obsolete: append new markers to obsstore file instead of rewriting everything
This is the second step toward incremental writing of marker inside a
transaction. The obsstore file is now handled append only.

Header writing have been extracted from _writemarkers.

Because the _writemarkers method have been dropped, the push code
directly reuse the serialised content of local repo `listkeys`. This
is not very pretty, but this part of the protocol still need major
improvement anyway.
2012-07-04 02:02:48 +02:00
Pierre-Yves David
3fa4ff72f7 obsolete: move obsolete markers read/write logic to obsstore object
This is the first step toward incremental writing of obsolete marker within a
transaction.

For this purpose, obsstore is now given its repo sopener. This make it able to
handles read and write to the obsstore file itself. Most IO logic is removed
from localrepo and handled by obsstore object directly.
2012-07-04 02:00:36 +02:00
Pierre-Yves.David@ens-lyon.org
d60eedc2d6 obsolete: exchange obsolete marker over pushkey
For a version of the exchange, all markers are exchange. This won't
scale and we will need a better protocol later.
2012-06-07 19:21:59 +02:00
Pierre-Yves.David@ens-lyon.org
f9dd15112c obsolete: introduction of obsolete markers
Markers are stored as binary records in a log structured file in
.hg/store/obsstore.
2012-06-07 19:07:39 +02:00
Joshua Redstone
fe77ca6b46 strip: incrementally update the branchheads cache after a strip
This function augments strip to incrementally update the branchheads cache
rather than recompute it from scratch.  This speeds up the performance of strip
and rebase on repos with long history.  The performance optimization only
happens if the revisions stripped are all on the same branch and the parents of
the stripped revisions are also on that same branch.

This adds a few test cases, particularly one that reproduces the extra heads
that mpm observed.
2012-05-18 12:45:47 -07:00
Joshua Redstone
8395f62c2f localrepo: convert _updatebranchcache from nodespace to revspace
_updatebranchcache used to use revlog.reachable.  After the switch to
revlog.ancestors, we can now clean it up a bit and switch the algorithm from
nodes to revs.
2012-06-01 08:56:17 -07:00
Joshua Redstone
09130c5cf2 revlog: remove reachable and switch call sites to ancestors
This change does a trivial conversion of callsites to ancestors.
Followon diffs will switch the callsites over to revs.
2012-06-08 08:39:44 -07:00
Martin Geisler
9b2274c69f localrepo: lowercase "unexpected response" message 2012-06-12 14:18:18 +02:00
Bryan O'Sullivan
6ba97b40c1 revlog: ancestors(*revs) becomes ancestors(revs) (API)
Accepting a variable number of arguments as the old API did is
deeply ugly, particularly as it means the API can't be extended
with new arguments.  Partly as a result, we have at least three
different implementations of the same ancestors algorithm (!?).

Most callers were forced to call ancestors(*somelist), adding to
both inefficiency and ugliness.
2012-06-01 12:37:18 -07:00
Matt Mackall
6c79e00693 localrepo: move filecache clearing into invalidate
Moving from self.destroy to _rollback fixed rollback fixed rollback
but broke mq. Move it lower rather than sideways.
2012-06-01 23:44:10 -05:00
Matt Mackall
da90115a02 merge with stable 2012-06-01 15:14:29 -05:00
Idan Kamara
6259990e39 localrepo: clear _filecache earlier to really force reloading (issue3462)
b67b333b0d8a attempted to force the filecaches in localrepo to reload
everything after a rollback. But simply clearing _filecache isn't enough,
invalidate() needs to be called before/after. localrepo._rollback calls
invalidate() already, so we clear the map right afterwards which ensures
everything will be reread.
2012-05-29 18:27:12 +03:00
Augie Fackler
e8eca68a89 clone: add progress calls to uncompressed code path 2012-05-21 14:25:46 -05:00
Matt Mackall
7e8d9b6e6f branchcache: backout 29529231e17d 2012-05-17 15:34:59 -05:00
Brodie Rao
ab32f1721d context: add changectx.closesbranch() method
This removes the duplicated code for inspecting the 'close' extra field in
a changeset.
2012-05-13 14:04:06 +02:00
Brodie Rao
d36ae7f264 localrepo: add branchtip() method for faster single-branch lookups
For the PyPy repo with 744 branches and 843 branch heads, this brings
hg log -r default over NFS from:

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
        3249            0      1.3222      1.3222   <open>
        3244            0      0.6211      0.6211   <method 'close' of 'file' objects>
        3243            0      0.0800      0.0800   <method 'read' of 'file' objects>
        3241            0      0.0660      0.0660   <method 'seek' of 'file' objects>
        3905            0      0.0476      0.0476   <zlib.decompress>
        3281            0      2.6756      0.0472   mercurial.changelog:182(read)
       +3281            0      2.5256      0.0453   +mercurial.revlog:881(revision)
       +3276            0      0.0389      0.0196   +mercurial.changelog:28(decodeextra)
       +6562            0      0.0123      0.0123   +<method 'split' of 'str' objects>
       +6562            0      0.0408      0.0073   +mercurial.encoding:61(tolocal)
       +3281            0      0.0054      0.0054   +<method 'index' of 'str' objects>
        3241            0      2.2464      0.0456   mercurial.revlog:818(_loadchunk)
       +3241            0      0.6205      0.6205   +<method 'close' of 'file' objects>
       +3241            0      0.0765      0.0765   +<method 'read' of 'file' objects>
       +3241            0      0.0660      0.0660   +<method 'seek' of 'file' objects>
       +3241            0      1.4209      0.0135   +mercurial.store:374(__call__)
       +3241            0      0.0122      0.0107   +mercurial.revlog:810(_addchunk)
        3281            0      2.5256      0.0453   mercurial.revlog:881(revision)
       +3280            0      0.0175      0.0175   +mercurial.revlog:305(rev)
       +3281            0      2.2819      0.0119   +mercurial.revlog:847(_chunkraw)
       +3281            0      0.0603      0.0083   +mercurial.revlog:945(_checkhash)
       +3281            0      0.0051      0.0051   +mercurial.revlog:349(flags)
       +3281            0      0.0040      0.0040   +<mercurial.mpatch.patches>
       13682            0      0.0479      0.0248   <method 'decode' of 'str' objects>
       +7418            0      0.0228      0.0076   +encodings.utf_8:15(decode)
          +1            0      0.0003      0.0000   +encodings:71(search_function)
        3248            0      1.3995      0.0246   mercurial.scmutil:218(__call__)
       +3248            0      1.3222      1.3222   +<open>
       +3248            0      0.0235      0.0184   +os.path:80(split)
       +3248            0      0.0084      0.0068   +mercurial.scmutil:92(__call__)
Time: real 2.750 secs (user 0.680+0.000 sys 0.360+0.000)

down to:

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
          55           31      0.0197      0.0163   <__import__>
          +1            0      0.0006      0.0002   +mercurial.context:8(<module>)
          +1            0      0.0042      0.0001   +mercurial.revlog:12(<module>)
          +1            0      0.0002      0.0001   +mercurial.match:8(<module>)
          +1            0      0.0003      0.0001   +mercurial.dirstate:7(<module>)
          +1            0      0.0057      0.0001   +mercurial.changelog:8(<module>)
           1            0      0.0117      0.0032   mercurial.localrepo:525(_readbranchcache)
        +844            0      0.0015      0.0015   +<binascii.unhexlify>
        +845            0      0.0010      0.0010   +<method 'split' of 'str' objects>
        +843            0      0.0045      0.0009   +mercurial.encoding:61(tolocal)
        +843            0      0.0004      0.0004   +<method 'setdefault' of 'dict' objects>
          +1            0      0.0003      0.0003   +<method 'close' of 'file' objects>
           3            0      0.0029      0.0029   <method 'read' of 'file' objects>
           9            0      0.0018      0.0018   <open>
         990            0      0.0017      0.0017   <binascii.unhexlify>
          53            0      0.0016      0.0016   mercurial.demandimport:43(__init__)
         862            0      0.0015      0.0015   <_codecs.utf_8_decode>
         862            0      0.0037      0.0014   <method 'decode' of 'str' objects>
        +862            0      0.0023      0.0008   +encodings.utf_8:15(decode)
         981            0      0.0011      0.0011   <method 'split' of 'str' objects>
         861            0      0.0046      0.0009   mercurial.encoding:61(tolocal)
        +861            0      0.0037      0.0014   +<method 'decode' of 'str' objects>
         862            0      0.0023      0.0008   encodings.utf_8:15(decode)
        +862            0      0.0015      0.0015   +<_codecs.utf_8_decode>
           4            0      0.0008      0.0008   <method 'close' of 'file' objects>
         179          154      0.0202      0.0004   mercurial.demandimport:83(__getattribute__)
         +36           11      0.0199      0.0003   +mercurial.demandimport:55(_load)
         +72            0      0.0001      0.0001   +mercurial.demandimport:83(__getattribute__)
         +36            0      0.0000      0.0000   +<getattr>
           1            0      0.0015      0.0004   mercurial.tags:148(_readtagcache)
Time: real 0.060 secs (user 0.030+0.000 sys 0.010+0.000)
2012-05-13 14:04:04 +02:00
Joshua Redstone
d70249edef localrepo: strip now incrementally updates the branchheads cache
Destroying history via strip used to invalidate the branchheads cache,
causing it to be regenerated the next time it is read. This is
expensive in large repos. This change converts strip to pass info to
localrepo.destroyed() to enable to it to incrementally update the
cache, improving the performance of strip and other operations that
depend on it (e.g., rebase).

This change also strengthens a bit the integrity checking of the
branchheads cache when it is read, by rejecting the cache if it has
nodes in it that no longer exist.
2012-05-11 10:35:54 -07:00
David Soria Parra
2ce902d434 localrepo: introduce bookmarkheads
Similar to branch heads we introduce the notion of bookmarkheads.
Bookmarkheads are changests that are bookmarked with the given bookmark
or a diverged version
2012-05-13 11:54:58 +02:00
David Soria Parra
7ffe2b2eb4 bookmarks: delete divergent bookmarks on merge 2012-05-12 21:28:10 +02:00
Brodie Rao
7f47d4e347 check-code: ignore naked excepts with a "re-raise" comment
This also promotes the naked except check from a warning to an error.
2012-05-13 13:18:06 +02:00
Matt Mackall
05e48d4041 merge with stable 2012-05-13 12:52:24 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Patrick Mezard
641ee7d3ba phases: introduce phasecache
The original motivation was changectx.phase() had special logic to
correctly lookup in repo._phaserev, including invalidating it when
necessary. And at other places, repo._phaserev was accessed directly.

This led to the discovery that phases state including _phaseroots,
_phaserev and _dirtyphase was manipulated in localrepository.py,
phases.py, repair.py, etc. phasecache helps encapsulating that.

This patch replaces all phase state in localrepo with phasecache and
adjust related code except for advance/retractboundary() in phases.
These still access to phasecache internals directly. This will be
addressed in a followup.
2012-05-12 00:24:07 +02:00
Jesse Glick
a1ec63bdbc localrepo: optimize internode status calls using withflags
Introduce manifestdict.withflags() to get a set of all files which have any
flags set, since these are likely to be a minority. Otherwise checking .flags()
for every file is a lot of dictionary lookups and is quite slow.
2012-05-04 15:56:45 -04:00
Jesse Glick
17675847fa localrepo: optimize internode status calls using match.always
Introduce match.always() to check if a match object always says yes, i.e.
None was passed in. If so, mfmatches should not bother iterating every file in
the repository.
2012-05-04 15:54:55 -04:00
redstone
7ea2f3b663 localrepo: cleanup var names and comments
Cosmetic cleanups.  Fix comment typo referring to the notion of multiple tips.
Make variable describing a generator end in 'gen'.
Fix another var containing a node not to end with 'rev'.
2012-05-11 10:53:12 -07:00
Patrick Mezard
352ebc2cec phases: stop modifying localrepo in writeroots()
Also pass the phaseroots being written for clarity. repo._dirtyphases
was already reset to False at call site.
2012-05-10 18:52:07 +02:00
Patrick Mezard
f8945add9d phases: stop modifying localrepo in readroots()
phasedefaults is also passed explicitely to help the casual reader
understand where it is used without grepping all the sources.
2012-05-10 18:52:04 +02:00
Patrick Mezard
e918020a6f phases: call filterunknown() in readroots()
One less function manipulating localrepo state.
2012-05-10 18:21:15 +02:00
Patrick Mezard
2c65c226cf localrepo: add setparents() to adjust dirstate copies (issue3407)
The fix introduced in 3509b9cf8f86 was only partially successful. It is correct
to turn dirstate 'm' merge records into normal/dirty ones but copy records are
lost in the process. To adjust them as well, we need to look in the first
parent manifest to know which files were added and preserve only related
records. But the dirstate does not have access to changesets, the logic has to
moved at another level, in localrepo.
2012-04-29 22:25:55 +02:00
Patrick Mezard
cc838630b9 commit: abort on merge with missing files
Here is a script illustrating the previous behaviour:

The merge brings a new file 'b' from remote
  $ hg merge 1 --debug
    searching for copies back to rev 1
    unmatched files in other:
     b
  resolving manifests
   overwrite: False, partial: False
   ancestor: 07f494440405, local: 540395c44225+, remote: 102a90ea7b4a
   b: remote created -> g
  updating: b 1/1 files (100.00%)
  getting b
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)

Delete but do not remove b
  $ rm b
  $ hg st
  ! b

The commit succeeds
  $ hg commit -m merge
  $ hg parents --template "{rev} {desc|firstline} files: {files}\n"
  3 merge files:
  $ hg st
  ! b

b changes were ignored, but even b existence was ignored
  $ hg manifest
  a

This happens because localrepo.commitctx() checks the input ctx.files(), which
is empty for workingctx.files() only returns added, modified or removed
entries, and bypass files/manifest updates completely. So the committed
revision manifest is the same as its first parent one, not containing the 'b'
file.

This patch forces the commit to abort in presence of a merge and missing files.
test-merge4.t is modified accordingly as it was introduced to check hg was not
just terminating with a traceback (5cc0d3ba11f9).
2012-04-28 15:01:57 +02:00
Matt Mackall
6cebf7e4fb journal: use tryread helper to backup files (issue3375) 2012-04-17 11:13:38 -05:00
Alain Leufroy
10dafa190b localrepo: do not complain about missing journal files 2012-04-16 10:56:37 +02:00
Matt Mackall
e80599976d changegroupsubset: optimize function lookup in prune 2012-04-13 22:55:46 -05:00
Matt Mackall
736fde9c03 changegroup: optimize gennodelist 2012-04-13 22:55:46 -05:00
Matt Mackall
2bbef572af changegroupsubset: avoid setdefault in inner loop 2012-04-13 22:55:46 -05:00
Matt Mackall
03f2c727d0 changegroupsubset: drop repeated len() calls 2012-04-13 22:55:40 -05:00
Matt Mackall
5f0c1a6b8d changegroup: reduce progress overhead 2012-04-13 22:27:29 -05:00
Matt Mackall
4a60e2504d changegroupsubset: renest inner loop
The mdata list should generally be shorter than changedfiles
2012-04-13 22:23:45 -05:00
Matt Mackall
dec2ae41f4 stream_in: avoid debug calls when debug is disabled 2012-04-12 20:22:18 -05:00
Matt Mackall
53ccbcba3d localrepo: lookup now goes through context 2012-04-08 12:38:10 -05:00
Matt Mackall
567d3a0049 tags: defer tag validation until repo.tags() is called
Before, we were validating all tags for any tag operation, which meant
building a (nearly) full node->tag lookup tree for most operations.
2012-04-06 15:16:30 -05:00
Benoit Allard
ed90b14694 protocol: Add the stream-preferred capability
This makes the client use the uncompressed protocol.
2012-04-04 00:00:47 +02:00
Matt Mackall
87d3671dbf merge with stable 2012-03-12 17:05:42 -05:00
Michael Bacarella
565727ef7b localrepo: fix unpushable repos when using bookmarks (issue3317)
bookmarks is copied to journal.bookmarks differently from how dirstate is
copied to journal.dirstate.  The different way is less robust, which can render
the repo unpushable by other users if the first pushing user aborts their
transaction.

The underlying cause is that the copyfile method attempts an unnecessary chmod,
which fails if the user is not the owner of the journal.bookmarks file.

This patch makes the bookmarks journaling more consistent with the rest of the
journaling, and will allow users to update lingering journal.bookmarks files
that they're not the owners of.
2012-03-09 15:34:21 -05:00
Idan Kamara
8fa8539f01 dirstate: add filecache support 2012-03-01 17:39:58 +02:00
Idan Kamara
58bc817cd0 filecache: refactor path join logic to a function
New users of filecache use different names for the function used to compute
the runtime path of the cached file.

Users should subclass filecache and provide their own version of this
function to call the appropriate join function on 'obj' (an instance
of the class that its member function was decorated).
2012-03-01 17:39:58 +02:00
FUJIWARA Katsunori
4798ea4198 localrepository: use 'changectx.dirs()' in 'status()' for directory patterns
when pattern which does not match against any files in working context
is specified, current implementation of 'localrepository.status()'
decides whether warning message about it should be shown or not by
'f not in context'

this works correctly for 'file pattern', but not for 'directory
pattern', because 'f not in context' always returns True for
directories, even if they are related to the context.

this patch uses 'changectx.dirs()' to examine whether specified
pattern is related to the context as a directory or not.
2012-02-23 00:07:54 +09:00
Idan Kamara
8431edb46a localrepo: refactor retrieving of journal/undo files paths
We'd like to remove undo files after stripping
2012-03-06 18:42:52 +02:00
Thomas Arendsen Hein
0f80b37090 merge with stable 2012-03-02 09:57:09 +01:00
Matt Mackall
72210502d5 merge with stable 2012-02-22 17:36:33 -06:00
Idan Kamara
1e4d0cc218 localrepo: clear _filecache on rollback (issue3261)
Files are being replaced by rollback but the corresponding data in localrepo
isn't actually updated for things like bookmarks, phases, etc. Then when
rollback is done, the cache is updated thinking it has the most up-to-date
data, where in fact it is still pre-rollback.

We clear _filecache to force everything to be recreated.
2012-02-16 01:21:34 +02:00
Idan Kamara
11836c52b3 localrepo: reset _phasesdirty flag after writing 2012-02-15 23:49:15 +02:00
Pierre-Yves David
ad2799644a phases: allow phase name in phases.new-commit settings
Before this commit only phase index where accepted
2012-01-30 17:46:15 +01:00
Mads Kiilerich
93c3b99c27 tag: run commit hook when lock is released (issue3344) 2012-05-12 20:06:02 +02:00
Bryan O'Sullivan
3fbc354649 parsers: strictly check for 20-byte hashes where they're required 2012-05-12 20:25:33 +02:00
Matt Mackall
2157179ce3 push: return 1 if no changes found (issue3228)
Currently we have the following return codes if nothing is found:

                commit   incoming    outgoing      pull     push
intended           1        1           1            1       1
documented         1        1           1            0       1
actual             1        1           1            0       0

This fixes the lower-right entry.
2012-01-30 11:32:09 -06:00
Matt Mackall
bf7a89f81c push: fix coding errors in unused branch
This branch will get re-enabled in a subsequent fix
2012-01-30 11:15:34 -06:00
Matt Mackall
684f6eea71 phases: fix verify with secret csets
Verify uses repo.cancopy() to detect whether a repo is a plain old
local repo, so it was giving a confusing error message when secret
changesets were present.
2012-01-29 13:36:10 -06:00
Matt Mackall
e4d11ad28c scmutil: unify some 'no changes found' messages
This keeps the wording more consistent for secret csets
2012-01-25 17:14:08 -06:00
Idan Kamara
e23559bcc5 localrepo: delete _phaserev when invalidating caches 2012-01-26 00:21:54 +02:00
Idan Kamara
450a4ebd58 localrepo: fix phaseroots filecache definition
it's in .hg/store
2012-01-26 00:21:53 +02:00
Pierre-Yves David
6671f18b78 discovery: fix regression when checking heads for pre 1.4 client (issue3218)
This code is not run by the test suite and silly name error were lurking here.
2012-01-24 19:49:30 +01:00
Matt Mackall
ee1d294b90 merge with stable 2012-02-16 16:40:29 -06:00
Matt Mackall
a17b10a14b subrepo: rewrite handling of subrepo state at commit (issue2403)
When the contents of .hgsubstate are stale (either because they've
manually been tweaked or partial updates have confused it), we get
confused about whether it actually needs committing.

So instead, we actively consult the parent's substate and compare it
the actual current state when deciding whether it needs committing.

Side effect: lots of "committing subrepo" messages that didn't
correspond with real commits disappear.

This change is fairly invasive for a fairly obscure condition, so it's
kept on the default branch.
2012-02-06 15:10:01 -06:00
Pierre-Yves David
7b8b0389cd push: prevent moving phases outside of the pushed subset 2012-01-20 21:21:13 +01:00
Pierre-Yves David
f813e53446 mq-safety: don't apply safety on non-outgoing changeset
When mq changeset are secret, they don't appear in outgoing and won't be
pushed. So it's not necessary to abort the push.

The checkpush call is protected by lock to prevent race on phase.
2012-01-20 18:45:29 +01:00
Pierre-Yves David
78c5d64e2e phases: only synchronize on common changeset when push fails
If push failed we should not expect the pushed changeset to exist on remote.
The common set before the push is used for phase related operation instead of
common + missing.

Note:
  * We still pull phase data even if push fails
  * We still try to push data even if push fails (same than bookmark)
2012-01-19 16:09:43 +01:00
Pierre-Yves David
a445988112 discovery: diet discovery.prepush from non-discovery code
The ``discovery.prepush`` function was doing multiple things not related to
discovery. This changeset move some code into the ``localrepo.push`` method. The
old ``discovery.prepush`` function jobs is now restricted to checking for
multple head creation. It was then renamed ``discovery.checkheads``.

This new ``discovery.checkheads`` function may receive several other changes in
the future but we are a bit too much near the freeze for a wider refactoring.
2012-01-19 15:50:55 +01:00
Mads Kiilerich
dbffdfd960 tag: invalidate tag cache immediately after adding new tag (issue3210)
New tags were written to .hgtags / .hglocaltags without updating or
invalidating the localrepo cache.

Before 462e6cfb1bac a lock was acquired soon after the new tags had been
written, and that invalidated the cache so the new tags for example could be
seen in pretxncommit hooks. With 462e6cfb1bac the lock had already been
acquired at this point and the missing cache invalidation was exposed.

The tag caches will now explicitly and immediately be invalidated when new tags
are added.
2012-01-19 02:14:06 +01:00
Pierre-Yves David
7448ca3281 phases: mechanism to allow extension to alter initial computation of phase
This commit add a whennodata list where extension can register a callback to be
called if no phase related data are found in the repository.

The goal is to ensure the existing extension that move phase data in 2.1 can
compute consistent phase boundary for existing repo.
2012-01-18 17:23:54 +01:00
Pierre-Yves David
387f9b40ba phases: simplify phase exchange and movement over pushkey
The code now only exchange draft root and only care about movement related to
public//draft boundary.

There is multiple reason to simplify this code:
    * Secret are never discovered anymore
    * We decided to not support more the three existing phase

Removing phase index from pushkey (if ever decided) will be made in another commit.
2012-01-13 02:04:16 +01:00
Pierre-Yves David
913d4ce095 phases: move phase according what was pushed not only what was added added
This fix the lack phase movement when a locally secret changeset without added
children was pushed to the repository. In such case, this changeset would be
present in the bundle source, but not in the ``added`` variable.
2012-01-13 01:42:47 +01:00
Pierre-Yves David
15ab7ccd15 revlog: make addgroup returns a list of node contained in the added source
This list will contains any node see in the source, not only the added one.
This is intended to allow phase to be move according what was pushed by client
not only what was added.
2012-01-13 01:29:03 +01:00
Pierre-Yves David
2b8de7b6ac phases: make secret changeset undiscoverable in all case
This apply the redefined stronger semantic of secret.

Secret changeset can still leak in various way. Those leak will need to be fixed individualy
2012-01-12 01:25:57 +01:00
Pierre-Yves David
a04b3a6ec3 phases: exclude secret when doing a local clone
This is achieved by denying copy clone when any secret changeset exist.
2012-01-11 17:26:27 +01:00
Mads Kiilerich
460db57ad0 localrepo: update branchcache in a more reliable way
test-mq-cache.t did apparently look at stale cache content.

Testing with different locking mechanism happened to update the cache more
frequently and thus caused a test failure.
2012-01-13 02:29:38 +01:00
Mads Kiilerich
59e986bbed localrepo: remove spurious updatebranchcache return value
- it was left over from the refactoring in 670bb7b1924a.
2012-01-13 01:19:08 +01:00
Pierre-Yves David
e929cd5e49 discovery: introduce outgoing object for result of findcommonoutgoing
Simplifies client logic in multiple places since it encapsulates the
computation of the common and, more importantly, the missing node lists.

This also allows an upcomping patch to communicate precomputed versions of
these lists to clients.
2012-01-09 03:47:16 +01:00
Pierre-Yves David
074b67eb86 phases: fix phase synchronization on push
The bugs seemed to show up when element not in future common changeset should
hold new hold phase data.

The whole phase push machinery was rewritten in the process.
2012-01-04 01:12:31 +01:00
Pierre-Yves David
5262f88500 phases: store phase values in constant instead of using raw integer
Phases constant are named after the phase name. Usage of integer have been
replaced by proper constant.
2012-01-06 09:51:35 +01:00
Matt Mackall
dc09090fed merge with stable 2011-12-26 18:08:20 -06:00
FUJIWARA Katsunori
be239ba6ee windows: use normalized path to check repository nesting
current "localrepository._checknested()" uses specified path itself to
compare against subrepo pathes.

it is invoked from "hgsubrepo.subrepo()" or pathauditor (as callback),
and both use "os.sep" as separator.

this causes unexpected nesting check result, if subrepo configuration
uses "/" as path separator for sub repo path.

this path uses "/" to join path components (or apply "util.pconvert()"
on path) to normalize.
2011-12-24 19:05:25 +09:00
Greg Ward
d364c25d5a rollback: always call destroyed() (regression from 1.9)
The contract for repo.destroyed() is that it is called whenever
changesets are destroyed, either by strip or by rollback. That
contract was inadvertently broken in 6c30b131b2ae, when we made a
chunk of code conditional on destroying one of the working dir's
parents. Oops: it doesn't matter *which* changesets are destroyed or
what their relationship is to the working dir, we should call
repo.destroyed() whenever we destroy changesets.
2011-12-01 17:39:30 -05:00
Matt Mackall
b066b57e3c backout 17bc9a6bb165 (issue3077) (issue3071)
Using util.realpath turns out to create complex issues on both Mac and
Windows. Back this change out for the release.
2011-10-29 11:02:23 -05:00
Thomas Arendsen Hein
51c498ead0 consistency: use util.realpath instead of os.path.realpath where useful
exceptions:
  hg: os.path.realpath used before util can be imported
  tests/run-tests.py: may not import mercurial modules
2011-10-24 13:51:24 +02:00
Matt Mackall
788df2a72b windows: sanity-check symlink placeholders
On Windows, we store symlinks as plain files with the link contents.
Via user error or NFS/Samba assistance, these files often end up with
'normal' file contents. Committing these changes thus gives an
invalid symlink that can't be checked out on Unix.

Here we filter out any modified symlink placeholders that look
suspicious when computing status:

- more than 1K (looks more like a normal file)
- contain NULs (not allowed on Unix, probably a binary)
- contains \n (filenames can't contain \n, very unusual for symlinks,
  very common for files)
2011-10-23 16:32:27 -05:00
Martin Geisler
acfa971cf1 subrepos: abort commit by default if a subrepo is dirty (BC)
This changeset flips the default value of ui.commitsubrepos setting
from True to False and adds a --subrepos flag to commit.

The commit, status, and diff commands behave like this with regard to
recusion and the ui.commitsubrepos setting:

          | recurses      | recurses
          | by default    | with --subrepos
  --------+---------------+----------------
  commit: | commitsubrepo | True
  status: | False         | True
  diff:   | False         | True

By changing the default from True to False, the table becomes
consistent in the two columns:

* without --subrepos on the command line, commit will abort if a
  subrepo is dirty and status/diff wont show changes inside subrepos.

* with --subrepos, all three commands will recurse.

A --subrepos flag on the command line overrides the config settin.g
2011-10-21 00:33:08 +02:00
Pierre-Yves David
78429733cd Add a phases.new-commit option to control minimal phase of new commit
this option is both intended for human and internal code usage.
2011-12-20 01:31:25 +01:00
Pierre-Yves David
f9b3764a1f phases: change publish behavior to only alter behavior when server.
Older publish=True was:

  1) Content of Publishing server are seen as public by client.
  2) Any changegroup *added* to a publish=True server is public.

New definition are:

  1) Content of Publishing server are seen as public by client.
  2) Any changegroup *pushed* to a publish=True server is public.

See mercurial/phase.py documentation for exact final behavior
2011-12-15 23:08:09 +01:00
Pierre-Yves David
0d9927b223 phases: exchange phase boundaries on push
For now phase sync is tried even if push fails with some know pathological
case. The exact behavior is to be discussed and implemented later.
2011-12-15 11:45:01 +01:00
Pierre-Yves David
c8f1983f55 phases: exchange phase boundaries on pull
Add an extra argument to addchangegroup to all phase code to execute before the
lock is released.
2011-12-15 11:28:42 +01:00
Pierre-Yves David
ca1e55e405 phases: add a phases.publish option
What is a "publishing repository"?
==================================

Setting a repository as "publishing" alter its behavior **when used as a
server**: all changesets are **seen** as public changesets by clients.

So, pushing to a "publishing" repository is the most common way to make
changesets public: pushed changesets are seen as public on the remote side and
marked as such on local side.

Note: the "publishing" property have no effects for local operations.

Old repository are publishing
=============================

Phase is the first step of a series of features aiming at handling mutable
history within mercurial. Old client do not support such feature and are unable
to hold phase data. The safest solution is to consider as public any changeset
going through an old client.

Moreover, most hosting solution will not support phase from the beginning.
Having old clients seen as public repositories will not change their usage:
public repositories where you push *immutable* public changesets *shared* with
others.

Why is "publishing" the default?
================================

We discussed above that any changeset from a non-phase aware repository should
be seen as public.  This means that in the following scenario, X is pulled as
public::

  ~/A$ old-hg init
  ~/A$ echo 'babar' > jungle
  ~/A$ old-hg commit -mA 'X'
  ~/A$ cd ../B
  ~/B$ new-hg pull ../A # let's pretend A is served by old-hg
  ~/B$ new-hg log -r tip
     summary:     X
     phase:       public

We want to keep this behavior while creating/serving the A repository with
``new-hg``. Although committing with any ``new-hg`` creates a draft changeset.
To stay backward compatible, the pull must see the new commit as public.
Non-publishing server will advertise them as draft. Having publishing repository
the default is thus necessary to ensure this backward compatibility.

This default value can also be expressed with the following sentence: "By
default, without any configuration, everything you exchange with the outside is
immutable.". This behaviour seems sane.

Why allow draft changeset in publishing repository
=====================================================

Note: The publish option is aimed at controlling the behavior of *server*.
Changeset in any state on a publishing server will **always*** be seen as public
by other client. "Passive" repository which are only used as server for pull and
push operation are not "affected" by this section.

As in the choice for default, the main reason to allow draft changeset in
publishing server is backward compatibility. With an old client, the following
scenario is valid::

  ~/A$ old-hg init
  ~/A$ echo 'babar' > jungle
  ~/A$ old-hg commit -mA 'X'
  ~/A$ old-hg qimport -r . # or any other mutable operation on X

If the default is publishing and new commits in such repository are "public" The
following operation will be denied as X will be an **immutable** public
changeset. However as other clients see X as public, any pull//push (or event
pull//pull) will mark X as public in repo A.

Allowing enforcement of public changeset only repository through config is
probably something to do. This could be done with another "strict" option or a
third value config for phase related option (mode=public, publishing(default),
mutable)
2011-12-15 11:57:33 +01:00
Matt Mackall
e82c2e671f merge with stable 2011-12-05 17:48:40 -06:00
Matt Mackall
2e8aaf75f9 lock: change name of release chain 2011-11-30 16:53:44 -06:00
Matt Mackall
0a7c1f46a7 localrepo: remove asserts in _afterlock 2011-11-30 16:20:07 -06:00
Matt Mackall
9606772122 localrepo: rename _postrelease to _afterlock 2011-11-30 15:36:55 -06:00
Matt Mackall
5fbe95bf65 addchangegroup: ony queue hooks when we have changesets 2011-11-30 15:33:44 -06:00
Pierre-Yves David
5ac8c7b10a addchangegroup: remove the lock argument on the addchangegroup methods
This argument is no longer require. post lock release code is now handled with
dedicated post release callback code in lock itself.
2011-11-28 01:32:13 +01:00
Pierre-Yves David
3e4593fedf addchangegroup: use a postrelease callback to call changegroup hook
This is will allow addchangegroup to drop lock related code.
2011-11-28 01:18:15 +01:00
Pierre-Yves David
a72322069e lock: add mechanism to register post release callback 2011-11-28 15:05:26 +01:00
Pierre-Yves David
e719727169 phases: set common changeset to public on pull 2011-11-11 00:22:02 +01:00
Pierre-Yves David
bf6f3ef1a7 phases: mark content pushed as public in local repo on push 2011-11-11 00:21:17 +01:00
Pierre-Yves David
493771f789 phases: marked content of a changegroup as published 2011-11-11 00:19:00 +01:00
Pierre-Yves David
0f1186823a phases: set new commit in 1-phase 2011-11-11 00:15:22 +01:00
Pierre-Yves David
e62e01ae47 phases: handle unknown nodes in boundary
We filter unknown node out of the boundary. No data is lost. A
filtering is explicitly done after strip too
2011-11-07 13:20:22 +01:00
Pierre-Yves David
75d76cce5b phases: add rollback support 2011-11-07 12:27:25 +01:00
Pierre-Yves David
7ab6d68a9a phases: add a moveboundary function to move phases boundaries
Also include logic to detect when to write phases data.
2011-11-07 14:11:01 +01:00
Pierre-Yves David
abd6a568e7 phases: add a cache allowing to know in which phase a changeset is 2011-11-04 00:20:20 +01:00
Pierre-Yves David
ff2323c4af phases: basic I/O logic
Add function to read and write phase roots. Add a _phaseroots filecache on
localrepo class to access the phaseroots data.
2011-11-04 00:16:24 +01:00
Matt Mackall
e8067d2be1 localrepo: add revs helper method 2011-11-02 13:37:34 -05:00
Augie Fackler
6d4a8aa3a9 bookmarks: delegate writing to the repo just like reading
This makes it easier for alternate storage backends to not use flat
files for bookmarks storage.
2011-10-12 11:09:57 -05:00
Matt Mackall
9b00238567 rollback: use a hint for force 2011-10-01 16:18:51 -05:00
Greg Ward
3e3c1d99c8 rollback: avoid unsafe rollback when not at tip (issue2998)
You can get into trouble if you commit, update back to an older
changeset, and then rollback. The update removes your valuable changes
from the working dir, then rollback removes them history. Oops: you've
just irretrievably lost data running nothing but core Mercurial
commands. (More subtly: rollback from a shared clone that was already
at an older changeset -- no update required, just rollback from the
wrong directory.)

The fix assumes that only "commit" transactions have irreplaceable
data, and allows rolling back non-commit transactions as always. But
when rolling back a commit, check that the working dir is checked out
to tip, i.e. the changeset we're about to destroy. If not, abort. You
can get back the old (dangerous) behaviour with --force.
2011-09-30 21:58:54 -04:00
Greg Ward
cf0ea44613 rollback: only restore dirstate and branch when appropriate.
If the working dir parent was destroyed by rollback, then the old
behaviour is perfectly reasonable: restore dirstate, branch, and
bookmarks. That way the working dir moves back to an existing
changeset rather than becoming an orphan.

But if the working dir parent was unaffected -- say, you updated to an
older changeset and then did rollback -- then it's silly to restore
dirstate and branch. So don't do that. Leave the status of the working
dir alone. (But always restore bookmarks, because that file refers to
changeset IDs that may have been destroyed.)
2011-09-18 19:59:33 -04:00
Greg Ward
50490dab06 rollback: refactor for readability; cosmetics.
- clarify how we parse undo.desc
- fix bad grammar in an error message
- factor out ui local
- rename some local variables
- standardize string quoting
2011-09-16 21:38:06 -04:00
Greg Ward
5dc38028a3 share: allow trailing newline on .hg/sharedpath.
This is extremely handy for those occasional circumstances where you
need to edit .hg/sharedpath manually, since modern Unix text editors
make it surprisingly difficult to create a text file with no trailing
newline.
2011-09-14 22:28:27 -04:00
Greg Ward
897039c55d rollback: improve readability; clarify that the return value is an int. 2011-09-11 21:21:58 -04:00
Greg Ward
bc1dfb1ac9 atomictempfile: make close() consistent with other file-like objects.
The usual contract is that close() makes your writes permanent, so
atomictempfile's use of close() to *discard* writes (and rename() to
keep them) is rather unexpected. Thus, change it so close() makes
things permanent and add a new discard() method to throw them away.
discard() is only used internally, in __del__(), to ensure that writes
are discarded when an atomictempfile object goes out of scope.

I audited mercurial.*, hgext.*, and ~80 third-party extensions, and
found no one using the existing semantics of close() to discard
writes, so this should be safe.
2011-08-25 20:21:04 -04:00
Idan Kamara
e37d7b9cbe localrepo: unify tag related info into a tagscache class 2011-07-25 15:08:57 +03:00
Idan Kamara
00456bfe26 localrepo: make invalidate() walk _filecache 2011-07-25 15:08:37 +03:00
Idan Kamara
a2947574cb localrepo: decorate manifest() with filecache 2011-07-25 15:08:37 +03:00
Idan Kamara
91c5accca8 localrepo: decorate _bookmarks/current with filecache
nodebookmarks() can be cached as well, leaving for later
2011-07-25 15:08:37 +03:00