Commit Graph

80 Commits

Author SHA1 Message Date
Pierre-Yves David
bbcfd63a3a repair: use first instead of direct indexing
This makes it compatible with all smartset classes.
2014-10-07 00:09:50 -07:00
Jordi Gutiérrez Hermoso
465e05be10 strip: remove -b/--backup codepaths
cset 21b4faf3787e has removed this option. This commit just tidies the
code that was associated to it. It also fixes the internal calls to
the strip() function.

Before this change, any function that thought it would want as a final
safety to keep a partial backup bundle (bundling changes not linearly
related to the current change being stripped), had to explicitly pass
a backup="strip" option. With this change, these backups are always
kept in case of an exception and always removed if there is no
exception. Only full backups can be specified with backup=True or no
full backups with backup=False.
2014-07-24 15:06:08 -04:00
Pierre-Yves David
c9703fe999 bundle2: add a ui argument to readbundle
The bundle2 unbundler needs a ui argument. We are now passing this information
to `readbundle`.
2014-04-14 15:45:30 -04:00
Pierre-Yves David
009e9f6c33 bundle2: move readbundle into the exchange module
The `readbundle` function is going to understand the bundle2 header. We move the
function to a more suitable place before making any other changes.
2014-04-14 15:33:50 -04:00
FUJIWARA Katsunori
1a5bc49ece repair: make "strip()" treat bundle files via vfs
This patch makes "repair.strip()" treat bundle files via vfs.

This patch also avoids applying "vfs.join()" on the value returned by
"changegroup.writebundle()", to get relative path from "_bundle()".
2014-03-09 01:03:28 +09:00
FUJIWARA Katsunori
e26cca0dd1 repair: make paths in "_bundle()" relative to ".hg"
This patch makes paths below in "_bundle()" relative to ".hg":

  - backup directory ("strip-backup"), and
  - bundle file under backup directory

"vfs" is passed to "changegroup.writebundle()" to use relative path
directly.

This patch applies "vfs.join()" on the value returned by "_bundle()",
because the caller expect it to return absolute path.

This will be changed by succeeding patch changing the caller side.
2014-03-09 01:03:28 +09:00
FUJIWARA Katsunori
836e13a2f2 localrepo: make "undofiles()" return list of tuples "(vfs, relative filename)"
Before this patch, "localrepository.undofiles()" returns list of
absolute filename of undo files.

This patch makes it return list of tuples "(vfs, relative filename)"
to access undo files via vfs.

This patch also changes "repair.strip()", which is the only user of
"localrepository.undofiles()".
2014-03-09 01:03:28 +09:00
Pierre-Yves David
6b9778c026 localrepo: move the addchangegroup method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.
2014-04-01 15:27:53 -07:00
Pierre-Yves David
f14b79a23f localrepo: move the changegroupsubset method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.

The method had few callers, not enough to be kept in local repo.

The peer API remains unchanged.
2014-04-01 14:25:03 -07:00
Durham Goode
3075ab82ec fncache: clean up fncache during strips
Previously the fncache was cleaned up at read time by noticing when it was out
of sync. This caused writes to happen outside the scope of transactions and
could have caused race conditions. With this change, we'll keep the fncache
up-to-date as we go by removing old entries during repair.strip.
2014-03-24 15:43:15 -07:00
Durham Goode
d8c96277e4 strip: add faster revlog strip computation
The previous revlog strip computation would walk every rev in the revlog, from
the bottom to the top.  Since we're usually stripping only the top few revs of
the revlog, this was needlessly expensive on large repos.

The new algorithm walks the exact number of revs that will be stripped, thus
making the operation not dependent on the number of revs in the repo.

This makes amend on a large repo go from 8.7 seconds to 6 seconds.
2013-11-11 16:42:49 -08:00
Durham Goode
3b156f49f8 blackbox: add backup bundle paths to blackbox logs
Writes the backup bundle paths to the blackbox so it's easy to see which
backup bundle is associated with which command when you are debugging an
issue.

Example output:

2013/03/13 10:39:56 durham> strip tip
2013/03/13 10:39:59 durham> saved backup bundle to /data/users/durham/www-hg/.hg/strip-backup/e5fac262363a-backup.hg
2013/03/13 10:40:03 durham> strip tip exited 0 after 7.97 seconds
2013-03-13 10:43:51 -07: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
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
Pierre-Yves David
dc5b484bd1 branchmap: extract updatebranchcache from repo 2012-12-20 14:45:17 +01:00
Siddharth Agarwal
e9b46fad5b strip: make query to get new bookmark target cheaper
The current query to get the new bookmark target for stripped revisions
involves multiple walks up the DAG, and is really expensive, taking over 2.5
seconds on a repository with over 400,000 changesets even if just one
changeset is being stripped.

A slightly simplified version of the current query is

max(heads(::<tostrip> - <tostrip>))

We make two observations here.

1. For any set s, max(heads(s)) == max(s). That is because revision numbers
   define a topological order, so that the element with the highest revision
   number in s will not have any children in s.

2. For any set s, max(::s - s) == max(parents(s) - s). In other words, the
   ancestor of s with the highest revision number not in s is a parent of one
   of the revs in s. Why? Because if it were an ancestor but not a parent of s,
   it would have a descendant that would be a parent of s. This descendant
   would have a higher revision number, leading to a contradiction.

Combining these two observations, we rewrite the revset query as

max(parents(<tostrip>) - <tostrip>)

The time complexity is now linear in the number of changesets being stripped.
For the above repository, the query now takes 0.1 seconds when one changeset
is stripped. This speeds up operations that use repair.strip, like the rebase
and strip commands.
2012-12-05 14:33:15 -08:00
Pierre-Yves David
d646efae02 clfilter: strip logic should be unfiltered
Strip is a "write" operation that needs to be aware of the whole repo's
content before destroying changesets.

Only the low level function is altered. The top level command will still
process its argument filtered (if any filtering is in place).
2012-10-08 17:12:09 +02: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
Matt Mackall
b170ca8911 repair: use node to track post-strip bookmark target
Revision numbers are unstable when non-consecutive revs are stripped.
2012-10-17 15:37:25 -05:00
Pierre-Yves David
f74fef3b80 strip: fix revset usage (issue3604)
The `repair` code builds a giant revset query instead of using the "%lr" idiom.
It is inefficient and crash when the number of stripped changeset is too big.

This changeset replaces the bad code by a better revset usage.
2012-08-31 23:27:26 +02:00
Augie Fackler
d7b1ad91f4 strip: move bookmarks to nearest ancestor rather than '.'
If you've got this graph:

0-1-2
   \
    3

and 3 is checked out, 2 is bookmarked with "broken", and you do "hg
strip 2", the bookmark will move to 3, not 1. That's always struck me
as a bug.

This change makes bookmarks move to the tipmost ancestor of
the stripped set rather than the currently-checked-out revision, which
is what I always expected should happen.
2012-07-26 16:57:50 -05: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
Bryan O'Sullivan
141bd09daa revlog: descendants(*revs) becomes descendants(revs) (API)
Once again making the API more rational, as with ancestors.
2012-06-01 12:45:16 -07:00
Matt Mackall
7e8d9b6e6f branchcache: backout 29529231e17d 2012-05-17 15:34:59 -05: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
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
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
2940b01bad repair: no need to call filterunknown() in strip()
Calling strip() will eventually trigger localrepo.destroyed() which will
invalidate _parseroots. It will call filterunknown() upon reload.

Changes to test-keyword.t are related to commit --debug running after
either qpop or rollback.
2012-05-10 18:21:15 +02:00
Alain Leufroy
01eed330fd repair: fix missing import
introduced by: 1792c24f759cbee608767738104810158188a0e4
2012-04-16 10:33:18 +02:00
Idan Kamara
6a237ec01a repair: allow giving strip backup a different name
So the user can differentiate amend backups from the rest.
2012-04-06 16:18:33 +03:00
Matt Mackall
87d3671dbf merge with stable 2012-03-12 17:05:42 -05:00
Wagner Bruna
9653f097ec strip: enhance repair.strip to receive a list of nodes (issue3299)
Originally, mq.strip called repair.strip a single rev at a time.
repair.strip stores in a backup bundle any revision greater than
the revision being stripped, strips, then restores the backup with
repo.addchangegroup. So, when stripping revisions on more than one
topological branch, some could end up being restored from the backup
bundle, only to be later removed by a subsequent repair.strip call.

But repo.addchangegroup calls hooks for all those restore operations.
And 1671d21e8e41 changed it to delay all hook calls until the
repository lock were released - by mq.strip, after stripping all
revisions. Thus, the hooks could be called over revisions already
removed from the repository at that point.

By generating the revision lists at once inside repo.strip, we avoid
calling addchangegroup for temporary restores. Incidentally, this
also avoids creating many backup files for a single strip command.
2012-03-12 17:02:45 -03:00
Idan Kamara
3d63e7c8f4 repair: remove undo files after strip 2012-03-06 18:43:05 +02:00
Henrik Stuart
1b54292744 repair: move phases code after invalidation code 2012-01-18 14:50:17 +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
Matt Mackall
7215130ac4 strip: backout 9aac86f54486 (issue3077) 2011-10-30 12:10:09 -05:00
Peter Arrenbrecht
e10442fbcb repair: switch from changegroupsubset to getbundle
This is in preparation of deprecating changegroupsubset.
2011-09-01 12:29:24 +02:00
Alexander Solovyov
0eb3836642 remove unused imports and variables 2011-04-30 13:59:14 +02:00
Patrick Mezard
4e7e0fa921 code indentation fixes 2011-03-23 23:33:14 +01:00
Matt Mackall
00a0332ced repair: revlog has an iterator 2011-03-20 20:21:19 -05:00
Matt Mackall
920f4c5db4 strip: simplify collectone 2011-03-20 19:43:28 -05:00
Benoit Boissinot
66804f4889 strip: remove usage of extranodes
Instead of computing the exact set of missing revlog revisions, we only
compute the set of missing/broken changesets. The resulting bundle can be
slightly bigger but we will be able to get rid of the ugly extranodes handling
in changegroupsubset.
2011-03-20 00:50:22 +01:00
Matt Mackall
d3d3054cf5 bookmarks: move strip support to repair 2011-02-10 13:46:28 -06:00
Patrick Mezard
0e57a866c2 repair: pass variable explicitely to nested function 2010-08-26 23:38:13 +02:00
Nicolas Dumazet
96827d742a repair: do not compress partial bundle if we do not keep it on disk
A partial bundle is created to temporarily save revisions > rev but
not descending from the node to strip, to be able to restore the
changesets after stripping the changelog.
Since this bundle is not kept after the strip operation, and is not
user-visible, it is not necessary and should be faster to avoid
compression.
2010-08-12 16:53:23 +09:00
Martin Geisler
8f362a460f mark ui.warn strings for translation 2010-07-16 14:44:30 +02:00
Matt Mackall
251885d01b strip: backup bundles should use the .hg extension 2010-06-10 15:23:31 -05:00
Matt Mackall
46429c0cb8 strip: hide unbundle messages by default
Unbundling is an internal implementation detail for strip, only show
them with --verbose.
2010-05-20 13:27:28 -05:00
Matt Mackall
a386dc3529 strip: improve full backup message 2010-05-20 12:15:44 -05:00