author | Augie Fackler <augie@google.com> |
Mon, 06 Feb 2017 23:57:32 -0500 | |
changeset 30964 | b7e073ae44c4 |
parent 30781 | f2c069bf78ee |
child 30895 | 0b913e1e725b |
child 30995 | 22fbca1d11ed |
permissions | -rw-r--r-- |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 |
# repair.py - functions for repository repair for mercurial |
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 |
# |
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 |
# Copyright 2005, 2006 Chris Mason <mason@suse.com> |
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 |
# Copyright 2007 Matt Mackall |
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 |
# |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8073
diff
changeset
|
6 |
# This software may be used and distributed according to the terms of the |
10263 | 7 |
# GNU General Public License version 2 or any later version. |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
8 |
|
25970
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
9 |
from __future__ import absolute_import |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
10 |
|
16440
692bf06bb1af
repair: fix missing import
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
16388
diff
changeset
|
11 |
import errno |
29341
0d83ad967bf8
cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
Augie Fackler <raf@durin42.com>
parents:
29196
diff
changeset
|
12 |
import hashlib |
30780
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
13 |
import stat |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
14 |
import tempfile |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
15 |
import time |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
16 |
|
25970
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
17 |
from .i18n import _ |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
18 |
from .node import short |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
19 |
from . import ( |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
20 |
bundle2, |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
21 |
changegroup, |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
22 |
changelog, |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26425
diff
changeset
|
23 |
error, |
25970
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
24 |
exchange, |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
25 |
manifest, |
28868
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
26 |
obsolete, |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
27 |
revlog, |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
28 |
scmutil, |
25970
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
29 |
util, |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
30 |
) |
d1419cfbd4f4
repair: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25874
diff
changeset
|
31 |
|
15386
6051d8e7e133
strip: backout 73307643a09f (issue3077)
Matt Mackall <mpm@selenic.com>
parents:
15068
diff
changeset
|
32 |
def _bundle(repo, bases, heads, node, suffix, compress=True): |
5905
3afbd82a6c82
repair.py: don't use nested functions.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5904
diff
changeset
|
33 |
"""create a bundle with the specified revisions as a backup""" |
27930
7cbb3a01fa38
repair: use cg3 for treemanifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
27875
diff
changeset
|
34 |
cgversion = changegroup.safeversion(repo) |
23898
b21c2e0ee8a3
repair: add experimental option to write bundle2 files
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
35 |
|
b21c2e0ee8a3
repair: add experimental option to write bundle2 files
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
36 |
cg = changegroup.changegroupsubset(repo, bases, heads, 'strip', |
b21c2e0ee8a3
repair: add experimental option to write bundle2 files
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
37 |
version=cgversion) |
20977
a57dcd11be34
repair: make paths in "_bundle()" relative to ".hg"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20975
diff
changeset
|
38 |
backupdir = "strip-backup" |
a57dcd11be34
repair: make paths in "_bundle()" relative to ".hg"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20975
diff
changeset
|
39 |
vfs = repo.vfs |
a57dcd11be34
repair: make paths in "_bundle()" relative to ".hg"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20975
diff
changeset
|
40 |
if not vfs.isdir(backupdir): |
a57dcd11be34
repair: make paths in "_bundle()" relative to ".hg"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20975
diff
changeset
|
41 |
vfs.mkdir(backupdir) |
23835
aa4a1672583e
bundles: do not overwrite existing backup bundles (BC)
Durham Goode <durham@fb.com>
parents:
22818
diff
changeset
|
42 |
|
aa4a1672583e
bundles: do not overwrite existing backup bundles (BC)
Durham Goode <durham@fb.com>
parents:
22818
diff
changeset
|
43 |
# Include a hash of all the nodes in the filename for uniqueness |
25340
28800ab40395
repair: use _hexlist() to build revset expression from binary nodes
Yuya Nishihara <yuya@tcha.org>
parents:
25300
diff
changeset
|
44 |
allcommits = repo.set('%ln::%ln', bases, heads) |
23835
aa4a1672583e
bundles: do not overwrite existing backup bundles (BC)
Durham Goode <durham@fb.com>
parents:
22818
diff
changeset
|
45 |
allhashes = sorted(c.hex() for c in allcommits) |
29341
0d83ad967bf8
cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
Augie Fackler <raf@durin42.com>
parents:
29196
diff
changeset
|
46 |
totalhash = hashlib.sha1(''.join(allhashes)).hexdigest() |
23835
aa4a1672583e
bundles: do not overwrite existing backup bundles (BC)
Durham Goode <durham@fb.com>
parents:
22818
diff
changeset
|
47 |
name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix) |
aa4a1672583e
bundles: do not overwrite existing backup bundles (BC)
Durham Goode <durham@fb.com>
parents:
22818
diff
changeset
|
48 |
|
26425
eb21b6679dc6
strip: compress bundle2 backup using BZ
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26423
diff
changeset
|
49 |
comp = None |
26423
c93f91c1db1c
strip: use bundle2 + cg2 by default when repository use general delta
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26014
diff
changeset
|
50 |
if cgversion != '01': |
24686
e0e28e910fa3
bundle2: rename format, parts and config to final names
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24252
diff
changeset
|
51 |
bundletype = "HG20" |
26425
eb21b6679dc6
strip: compress bundle2 backup using BZ
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26423
diff
changeset
|
52 |
if compress: |
eb21b6679dc6
strip: compress bundle2 backup using BZ
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26423
diff
changeset
|
53 |
comp = 'BZ' |
23898
b21c2e0ee8a3
repair: add experimental option to write bundle2 files
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
54 |
elif compress: |
11791
00cde9bddbe4
repair: do not compress partial bundle if we do not keep it on disk
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11600
diff
changeset
|
55 |
bundletype = "HG10BZ" |
00cde9bddbe4
repair: do not compress partial bundle if we do not keep it on disk
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11600
diff
changeset
|
56 |
else: |
00cde9bddbe4
repair: do not compress partial bundle if we do not keep it on disk
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11600
diff
changeset
|
57 |
bundletype = "HG10UN" |
28666
ae53ecc47414
bundle: move writebundle() from changegroup.py to bundle2.py (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
28466
diff
changeset
|
58 |
return bundle2.writebundle(repo.ui, cg, name, bundletype, vfs, |
26425
eb21b6679dc6
strip: compress bundle2 backup using BZ
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26423
diff
changeset
|
59 |
compression=comp) |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
60 |
|
5910
b9a830fa10f6
simplify revlog.strip interface and callers; add docstring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5909
diff
changeset
|
61 |
def _collectfiles(repo, striprev): |
b9a830fa10f6
simplify revlog.strip interface and callers; add docstring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5909
diff
changeset
|
62 |
"""find out the filelogs affected by the strip""" |
8462
e7e4e41b3bbc
repair: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8363
diff
changeset
|
63 |
files = set() |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
64 |
|
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6747
diff
changeset
|
65 |
for x in xrange(striprev, len(repo)): |
8479
3e16c0fc2241
repair: bulk update sets
Martin Geisler <mg@lazybytes.net>
parents:
8462
diff
changeset
|
66 |
files.update(repo[x].files()) |
5902
98f8dec8f437
repair.py: split stripall into two functions; clean it up a bit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5901
diff
changeset
|
67 |
|
8462
e7e4e41b3bbc
repair: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8363
diff
changeset
|
68 |
return sorted(files) |
5902
98f8dec8f437
repair.py: split stripall into two functions; clean it up a bit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5901
diff
changeset
|
69 |
|
13702
ffd370aa050b
strip: remove usage of extranodes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13362
diff
changeset
|
70 |
def _collectbrokencsets(repo, files, striprev): |
ffd370aa050b
strip: remove usage of extranodes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13362
diff
changeset
|
71 |
"""return the changesets which will be broken by the truncation""" |
13705
73cfb7a5aa56
strip: simplify collectone
Matt Mackall <mpm@selenic.com>
parents:
13702
diff
changeset
|
72 |
s = set() |
13702
ffd370aa050b
strip: remove usage of extranodes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13362
diff
changeset
|
73 |
def collectone(revlog): |
20074
5fc2ae1c631b
strip: add faster revlog strip computation
Durham Goode <durham@fb.com>
parents:
18766
diff
changeset
|
74 |
_, brokenset = revlog.getstrippoint(striprev) |
5fc2ae1c631b
strip: add faster revlog strip computation
Durham Goode <durham@fb.com>
parents:
18766
diff
changeset
|
75 |
s.update([revlog.linkrev(r) for r in brokenset]) |
5909
f45f7390c1c5
strip: calculate list of extra nodes to save and pass it to changegroupsubset
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5905
diff
changeset
|
76 |
|
30385
11b8b740d54a
manifest: remove last uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30381
diff
changeset
|
77 |
collectone(repo.manifestlog._revlog) |
13705
73cfb7a5aa56
strip: simplify collectone
Matt Mackall <mpm@selenic.com>
parents:
13702
diff
changeset
|
78 |
for fname in files: |
73cfb7a5aa56
strip: simplify collectone
Matt Mackall <mpm@selenic.com>
parents:
13702
diff
changeset
|
79 |
collectone(repo.file(fname)) |
5909
f45f7390c1c5
strip: calculate list of extra nodes to save and pass it to changegroupsubset
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5905
diff
changeset
|
80 |
|
13705
73cfb7a5aa56
strip: simplify collectone
Matt Mackall <mpm@selenic.com>
parents:
13702
diff
changeset
|
81 |
return s |
5909
f45f7390c1c5
strip: calculate list of extra nodes to save and pass it to changegroupsubset
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5905
diff
changeset
|
82 |
|
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21064
diff
changeset
|
83 |
def strip(ui, repo, nodelist, backup=True, topic='backup'): |
27553
56caab876bd8
repair: improves documentation of strip regarding locks
Laurent Charignon <lcharignon@fb.com>
parents:
27157
diff
changeset
|
84 |
# This function operates within a transaction of its own, but does |
56caab876bd8
repair: improves documentation of strip regarding locks
Laurent Charignon <lcharignon@fb.com>
parents:
27157
diff
changeset
|
85 |
# not take any lock on the repo. |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21064
diff
changeset
|
86 |
# Simple way to maintain backwards compatibility for this |
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21064
diff
changeset
|
87 |
# argument. |
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21064
diff
changeset
|
88 |
if backup in ['none', 'strip']: |
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21064
diff
changeset
|
89 |
backup = False |
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21064
diff
changeset
|
90 |
|
18004
747a2f43d5d9
clfilter: strip logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17922
diff
changeset
|
91 |
repo = repo.unfiltered() |
18310
4499ba5ac35c
localrepo: introduce destroying function
Idan Kamara <idankk86@gmail.com>
parents:
18121
diff
changeset
|
92 |
repo.destroying() |
17013
c8eda7bbdcab
strip: incrementally update the branchheads cache after a strip
Joshua Redstone <joshua.redstone@fb.com>
parents:
16867
diff
changeset
|
93 |
|
5901
16f4129c19ac
repair.py: rename chlog to cl
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5900
diff
changeset
|
94 |
cl = repo.changelog |
16237
b5c0c7d0f83f
repair: remove undo files after strip
Idan Kamara <idankk86@gmail.com>
parents:
15901
diff
changeset
|
95 |
# TODO handle undo of merge sets |
16252
cf17e76be4dd
strip: enhance repair.strip to receive a list of nodes (issue3299)
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
15901
diff
changeset
|
96 |
if isinstance(nodelist, str): |
cf17e76be4dd
strip: enhance repair.strip to receive a list of nodes (issue3299)
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
15901
diff
changeset
|
97 |
nodelist = [nodelist] |
cf17e76be4dd
strip: enhance repair.strip to receive a list of nodes (issue3299)
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
15901
diff
changeset
|
98 |
striplist = [cl.rev(node) for node in nodelist] |
cf17e76be4dd
strip: enhance repair.strip to receive a list of nodes (issue3299)
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
15901
diff
changeset
|
99 |
striprev = min(striplist) |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
100 |
|
30707
987dbe87aad6
repair: combine two loops over changelog revisions
Martin von Zweigbergk <martinvonz@google.com>
parents:
30706
diff
changeset
|
101 |
files = _collectfiles(repo, striprev) |
987dbe87aad6
repair: combine two loops over changelog revisions
Martin von Zweigbergk <martinvonz@google.com>
parents:
30706
diff
changeset
|
102 |
saverevs = _collectbrokencsets(repo, files, striprev) |
987dbe87aad6
repair: combine two loops over changelog revisions
Martin von Zweigbergk <martinvonz@google.com>
parents:
30706
diff
changeset
|
103 |
|
6147
53ae5af55db3
repair.py: rewrite a loop, making it cleaner and faster
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5910
diff
changeset
|
104 |
# Some revisions with rev > striprev may not be descendants of striprev. |
53ae5af55db3
repair.py: rewrite a loop, making it cleaner and faster
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5910
diff
changeset
|
105 |
# We have to find these revisions and put them in a bundle, so that |
53ae5af55db3
repair.py: rewrite a loop, making it cleaner and faster
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5910
diff
changeset
|
106 |
# we can restore them after the truncations. |
53ae5af55db3
repair.py: rewrite a loop, making it cleaner and faster
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5910
diff
changeset
|
107 |
# To create the bundle we use repo.changegroupsubset which requires |
53ae5af55db3
repair.py: rewrite a loop, making it cleaner and faster
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5910
diff
changeset
|
108 |
# the list of heads and bases of the set of interesting revisions. |
53ae5af55db3
repair.py: rewrite a loop, making it cleaner and faster
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5910
diff
changeset
|
109 |
# (head = revision in the set that has no descendant in the set; |
53ae5af55db3
repair.py: rewrite a loop, making it cleaner and faster
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5910
diff
changeset
|
110 |
# base = revision in the set that has no ancestor in the set) |
16252
cf17e76be4dd
strip: enhance repair.strip to receive a list of nodes (issue3299)
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
15901
diff
changeset
|
111 |
tostrip = set(striplist) |
30707
987dbe87aad6
repair: combine two loops over changelog revisions
Martin von Zweigbergk <martinvonz@google.com>
parents:
30706
diff
changeset
|
112 |
saveheads = set(saverevs) |
30706
2e4862646f02
repair: speed up stripping of many roots
Martin von Zweigbergk <martinvonz@google.com>
parents:
30385
diff
changeset
|
113 |
for r in cl.revs(start=striprev + 1): |
2e4862646f02
repair: speed up stripping of many roots
Martin von Zweigbergk <martinvonz@google.com>
parents:
30385
diff
changeset
|
114 |
if any(p in tostrip for p in cl.parentrevs(r)): |
2e4862646f02
repair: speed up stripping of many roots
Martin von Zweigbergk <martinvonz@google.com>
parents:
30385
diff
changeset
|
115 |
tostrip.add(r) |
13702
ffd370aa050b
strip: remove usage of extranodes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13362
diff
changeset
|
116 |
|
ffd370aa050b
strip: remove usage of extranodes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13362
diff
changeset
|
117 |
if r not in tostrip: |
ffd370aa050b
strip: remove usage of extranodes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13362
diff
changeset
|
118 |
saverevs.add(r) |
ffd370aa050b
strip: remove usage of extranodes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13362
diff
changeset
|
119 |
saveheads.difference_update(cl.parentrevs(r)) |
ffd370aa050b
strip: remove usage of extranodes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13362
diff
changeset
|
120 |
saveheads.add(r) |
ffd370aa050b
strip: remove usage of extranodes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
13362
diff
changeset
|
121 |
saveheads = [cl.node(r) for r in saveheads] |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
122 |
|
15386
6051d8e7e133
strip: backout 73307643a09f (issue3077)
Matt Mackall <mpm@selenic.com>
parents:
15068
diff
changeset
|
123 |
# compute base nodes |
6051d8e7e133
strip: backout 73307643a09f (issue3077)
Matt Mackall <mpm@selenic.com>
parents:
15068
diff
changeset
|
124 |
if saverevs: |
16867
1093ad1e8903
revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16745
diff
changeset
|
125 |
descendants = set(cl.descendants(saverevs)) |
15386
6051d8e7e133
strip: backout 73307643a09f (issue3077)
Matt Mackall <mpm@selenic.com>
parents:
15068
diff
changeset
|
126 |
saverevs.difference_update(descendants) |
6051d8e7e133
strip: backout 73307643a09f (issue3077)
Matt Mackall <mpm@selenic.com>
parents:
15068
diff
changeset
|
127 |
savebases = [cl.node(r) for r in saverevs] |
16252
cf17e76be4dd
strip: enhance repair.strip to receive a list of nodes (issue3299)
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
15901
diff
changeset
|
128 |
stripbases = [cl.node(r) for r in tostrip] |
18040
fe8caf28d580
strip: make query to get new bookmark target cheaper
Siddharth Agarwal <sid0@fb.com>
parents:
18004
diff
changeset
|
129 |
|
fe8caf28d580
strip: make query to get new bookmark target cheaper
Siddharth Agarwal <sid0@fb.com>
parents:
18004
diff
changeset
|
130 |
# For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but |
fe8caf28d580
strip: make query to get new bookmark target cheaper
Siddharth Agarwal <sid0@fb.com>
parents:
18004
diff
changeset
|
131 |
# is much faster |
fe8caf28d580
strip: make query to get new bookmark target cheaper
Siddharth Agarwal <sid0@fb.com>
parents:
18004
diff
changeset
|
132 |
newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip) |
17264
ec7b9bec19c9
strip: move bookmarks to nearest ancestor rather than '.'
Augie Fackler <raf@durin42.com>
parents:
17013
diff
changeset
|
133 |
if newbmtarget: |
22818
d7b114493315
repair: use `first` instead of direct indexing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22057
diff
changeset
|
134 |
newbmtarget = repo[newbmtarget.first()].node() |
17264
ec7b9bec19c9
strip: move bookmarks to nearest ancestor rather than '.'
Augie Fackler <raf@durin42.com>
parents:
17013
diff
changeset
|
135 |
else: |
ec7b9bec19c9
strip: move bookmarks to nearest ancestor rather than '.'
Augie Fackler <raf@durin42.com>
parents:
17013
diff
changeset
|
136 |
newbmtarget = '.' |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
137 |
|
13362
ee01d9d84115
bookmarks: move strip support to repair
Matt Mackall <mpm@selenic.com>
parents:
12057
diff
changeset
|
138 |
bm = repo._bookmarks |
ee01d9d84115
bookmarks: move strip support to repair
Matt Mackall <mpm@selenic.com>
parents:
12057
diff
changeset
|
139 |
updatebm = [] |
ee01d9d84115
bookmarks: move strip support to repair
Matt Mackall <mpm@selenic.com>
parents:
12057
diff
changeset
|
140 |
for m in bm: |
ee01d9d84115
bookmarks: move strip support to repair
Matt Mackall <mpm@selenic.com>
parents:
12057
diff
changeset
|
141 |
rev = repo[bm[m]].rev() |
ee01d9d84115
bookmarks: move strip support to repair
Matt Mackall <mpm@selenic.com>
parents:
12057
diff
changeset
|
142 |
if rev in tostrip: |
ee01d9d84115
bookmarks: move strip support to repair
Matt Mackall <mpm@selenic.com>
parents:
12057
diff
changeset
|
143 |
updatebm.append(m) |
ee01d9d84115
bookmarks: move strip support to repair
Matt Mackall <mpm@selenic.com>
parents:
12057
diff
changeset
|
144 |
|
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
145 |
# create a changegroup for all the branches we need to keep |
11197
4bb4895e1693
strip: be quiet about temporary internal bundle
Matt Mackall <mpm@selenic.com>
parents:
10881
diff
changeset
|
146 |
backupfile = None |
20979
ad5b61370514
repair: make "strip()" treat bundle files via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20977
diff
changeset
|
147 |
vfs = repo.vfs |
24252
f962692853c0
repair: define explicit local variable, don't reuse a comprehension variable
Mike Edgar <adgar@google.com>
parents:
24170
diff
changeset
|
148 |
node = nodelist[-1] |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21064
diff
changeset
|
149 |
if backup: |
16388
e03d8a40521f
repair: allow giving strip backup a different name
Idan Kamara <idankk86@gmail.com>
parents:
16253
diff
changeset
|
150 |
backupfile = _bundle(repo, stripbases, cl.heads(), node, topic) |
20979
ad5b61370514
repair: make "strip()" treat bundle files via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20977
diff
changeset
|
151 |
repo.ui.status(_("saved backup bundle to %s\n") % |
ad5b61370514
repair: make "strip()" treat bundle files via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20977
diff
changeset
|
152 |
vfs.join(backupfile)) |
ad5b61370514
repair: make "strip()" treat bundle files via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20977
diff
changeset
|
153 |
repo.ui.log("backupbundle", "saved backup bundle to %s\n", |
ad5b61370514
repair: make "strip()" treat bundle files via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20977
diff
changeset
|
154 |
vfs.join(backupfile)) |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
155 |
tmpbundlefile = None |
29955
e7acbe538baf
strip: simplify some repeated conditions
Martin von Zweigbergk <martinvonz@google.com>
parents:
29721
diff
changeset
|
156 |
if saveheads: |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
157 |
# do not compress temporary bundle if we remove it from disk later |
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
158 |
tmpbundlefile = _bundle(repo, savebases, saveheads, node, 'temp', |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21064
diff
changeset
|
159 |
compress=False) |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
160 |
|
30385
11b8b740d54a
manifest: remove last uses of repo.manifest
Durham Goode <durham@fb.com>
parents:
30381
diff
changeset
|
161 |
mfst = repo.manifestlog._revlog |
8073
e8a28556a0a8
strip: make repair.strip transactional to avoid repository corruption
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7361
diff
changeset
|
162 |
|
25300
678d0bfdd31a
repair: forbid strip from inside a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24863
diff
changeset
|
163 |
curtr = repo.currenttransaction() |
678d0bfdd31a
repair: forbid strip from inside a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24863
diff
changeset
|
164 |
if curtr is not None: |
678d0bfdd31a
repair: forbid strip from inside a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24863
diff
changeset
|
165 |
del curtr # avoid carrying reference to transaction for nothing |
678d0bfdd31a
repair: forbid strip from inside a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24863
diff
changeset
|
166 |
msg = _('programming error: cannot strip from inside a transaction') |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26425
diff
changeset
|
167 |
raise error.Abort(msg, hint=_('contact your extension maintainer')) |
25300
678d0bfdd31a
repair: forbid strip from inside a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24863
diff
changeset
|
168 |
|
27873
60ea60fea5f3
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27871
diff
changeset
|
169 |
try: |
60ea60fea5f3
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27871
diff
changeset
|
170 |
with repo.transaction("strip") as tr: |
60ea60fea5f3
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27871
diff
changeset
|
171 |
offset = len(tr.entries) |
8073
e8a28556a0a8
strip: make repair.strip transactional to avoid repository corruption
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7361
diff
changeset
|
172 |
|
27873
60ea60fea5f3
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27871
diff
changeset
|
173 |
tr.startgroup() |
60ea60fea5f3
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27871
diff
changeset
|
174 |
cl.strip(striprev, tr) |
60ea60fea5f3
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27871
diff
changeset
|
175 |
mfst.strip(striprev, tr) |
29464
87c184c9bfef
treemanifests: actually strip directory manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
29341
diff
changeset
|
176 |
if 'treemanifest' in repo.requirements: # safe but unnecessary |
87c184c9bfef
treemanifests: actually strip directory manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
29341
diff
changeset
|
177 |
# otherwise |
87c184c9bfef
treemanifests: actually strip directory manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
29341
diff
changeset
|
178 |
for unencoded, encoded, size in repo.store.datafiles(): |
87c184c9bfef
treemanifests: actually strip directory manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
29341
diff
changeset
|
179 |
if (unencoded.startswith('meta/') and |
87c184c9bfef
treemanifests: actually strip directory manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
29341
diff
changeset
|
180 |
unencoded.endswith('00manifest.i')): |
87c184c9bfef
treemanifests: actually strip directory manifests
Martin von Zweigbergk <martinvonz@google.com>
parents:
29341
diff
changeset
|
181 |
dir = unencoded[5:-12] |
30381
fccc3eea2ddb
manifest: delete unused dirlog and _newmanifest functions
Durham Goode <durham@fb.com>
parents:
30288
diff
changeset
|
182 |
repo.manifestlog._revlog.dirlog(dir).strip(striprev, tr) |
27873
60ea60fea5f3
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27871
diff
changeset
|
183 |
for fn in files: |
60ea60fea5f3
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27871
diff
changeset
|
184 |
repo.file(fn).strip(striprev, tr) |
60ea60fea5f3
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27871
diff
changeset
|
185 |
tr.endgroup() |
8073
e8a28556a0a8
strip: make repair.strip transactional to avoid repository corruption
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7361
diff
changeset
|
186 |
|
11197
4bb4895e1693
strip: be quiet about temporary internal bundle
Matt Mackall <mpm@selenic.com>
parents:
10881
diff
changeset
|
187 |
for i in xrange(offset, len(tr.entries)): |
4bb4895e1693
strip: be quiet about temporary internal bundle
Matt Mackall <mpm@selenic.com>
parents:
10881
diff
changeset
|
188 |
file, troffset, ignore = tr.entries[i] |
30005
e38d85be978f
repair: open a file with checkambig=True to avoid file stat ambiguity
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29958
diff
changeset
|
189 |
with repo.svfs(file, 'a', checkambig=True) as fp: |
e38d85be978f
repair: open a file with checkambig=True to avoid file stat ambiguity
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29958
diff
changeset
|
190 |
fp.truncate(troffset) |
20885
f49d60fa40a5
fncache: clean up fncache during strips
Durham Goode <durham@fb.com>
parents:
20074
diff
changeset
|
191 |
if troffset == 0: |
f49d60fa40a5
fncache: clean up fncache during strips
Durham Goode <durham@fb.com>
parents:
20074
diff
changeset
|
192 |
repo.store.markremoved(file) |
11197
4bb4895e1693
strip: be quiet about temporary internal bundle
Matt Mackall <mpm@selenic.com>
parents:
10881
diff
changeset
|
193 |
|
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
194 |
if tmpbundlefile: |
11202
f974fe896921
strip: hide unbundle messages by default
Matt Mackall <mpm@selenic.com>
parents:
11200
diff
changeset
|
195 |
ui.note(_("adding branch\n")) |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
196 |
f = vfs.open(tmpbundlefile, "rb") |
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
197 |
gen = exchange.readbundle(ui, f, tmpbundlefile, vfs) |
11202
f974fe896921
strip: hide unbundle messages by default
Matt Mackall <mpm@selenic.com>
parents:
11200
diff
changeset
|
198 |
if not repo.ui.verbose: |
f974fe896921
strip: hide unbundle messages by default
Matt Mackall <mpm@selenic.com>
parents:
11200
diff
changeset
|
199 |
# silence internal shuffling chatter |
f974fe896921
strip: hide unbundle messages by default
Matt Mackall <mpm@selenic.com>
parents:
11200
diff
changeset
|
200 |
repo.ui.pushbuffer() |
23898
b21c2e0ee8a3
repair: add experimental option to write bundle2 files
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
201 |
if isinstance(gen, bundle2.unbundle20): |
27875
add2ba16430e
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27873
diff
changeset
|
202 |
with repo.transaction('strip') as tr: |
add2ba16430e
with: use context manager for transaction in strip
Bryan O'Sullivan <bryano@fb.com>
parents:
27873
diff
changeset
|
203 |
tr.hookargs = {'source': 'strip', |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
204 |
'url': 'bundle:' + vfs.join(tmpbundlefile)} |
26797
75d550b7d8f5
strip: pass source and url to bundle2 processing
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26701
diff
changeset
|
205 |
bundle2.applybundle(repo, gen, tr, source='strip', |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
206 |
url='bundle:' + vfs.join(tmpbundlefile)) |
23898
b21c2e0ee8a3
repair: add experimental option to write bundle2 files
Eric Sumner <ericsumner@fb.com>
parents:
23895
diff
changeset
|
207 |
else: |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
208 |
gen.apply(repo, 'strip', 'bundle:' + vfs.join(tmpbundlefile), |
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
209 |
True) |
11202
f974fe896921
strip: hide unbundle messages by default
Matt Mackall <mpm@selenic.com>
parents:
11200
diff
changeset
|
210 |
if not repo.ui.verbose: |
f974fe896921
strip: hide unbundle messages by default
Matt Mackall <mpm@selenic.com>
parents:
11200
diff
changeset
|
211 |
repo.ui.popbuffer() |
11197
4bb4895e1693
strip: be quiet about temporary internal bundle
Matt Mackall <mpm@selenic.com>
parents:
10881
diff
changeset
|
212 |
f.close() |
29196
bf7b8157c483
strip: invalidate phase cache after stripping changeset (issue5235)
Laurent Charignon <lcharignon@fb.com>
parents:
28868
diff
changeset
|
213 |
repo._phasecache.invalidate() |
13362
ee01d9d84115
bookmarks: move strip support to repair
Matt Mackall <mpm@selenic.com>
parents:
12057
diff
changeset
|
214 |
|
27157
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
215 |
for m in updatebm: |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
216 |
bm[m] = repo[newbmtarget].node() |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
217 |
lock = tr = None |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
218 |
try: |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
219 |
lock = repo.lock() |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
220 |
tr = repo.transaction('repair') |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
221 |
bm.recordchange(tr) |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
222 |
tr.close() |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
223 |
finally: |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
224 |
tr.release() |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
225 |
lock.release() |
5f2e4eb08e41
repair: use bookmarks.recordchange instead of bookmarks.write
Laurent Charignon <lcharignon@fb.com>
parents:
26797
diff
changeset
|
226 |
|
16237
b5c0c7d0f83f
repair: remove undo files after strip
Idan Kamara <idankk86@gmail.com>
parents:
15901
diff
changeset
|
227 |
# remove undo files |
20975
37cdf1fca1b2
localrepo: make "undofiles()" return list of tuples "(vfs, relative filename)"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20933
diff
changeset
|
228 |
for undovfs, undofile in repo.undofiles(): |
16237
b5c0c7d0f83f
repair: remove undo files after strip
Idan Kamara <idankk86@gmail.com>
parents:
15901
diff
changeset
|
229 |
try: |
20975
37cdf1fca1b2
localrepo: make "undofiles()" return list of tuples "(vfs, relative filename)"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20933
diff
changeset
|
230 |
undovfs.unlink(undofile) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25652
diff
changeset
|
231 |
except OSError as e: |
16237
b5c0c7d0f83f
repair: remove undo files after strip
Idan Kamara <idankk86@gmail.com>
parents:
15901
diff
changeset
|
232 |
if e.errno != errno.ENOENT: |
20975
37cdf1fca1b2
localrepo: make "undofiles()" return list of tuples "(vfs, relative filename)"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20933
diff
changeset
|
233 |
ui.warn(_('error removing %s: %s\n') % |
37cdf1fca1b2
localrepo: make "undofiles()" return list of tuples "(vfs, relative filename)"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20933
diff
changeset
|
234 |
(undovfs.join(undofile), str(e))) |
16237
b5c0c7d0f83f
repair: remove undo files after strip
Idan Kamara <idankk86@gmail.com>
parents:
15901
diff
changeset
|
235 |
|
16705
c2d9ef43ff6c
check-code: ignore naked excepts with a "re-raise" comment
Brodie Rao <brodie@sf.io>
parents:
16628
diff
changeset
|
236 |
except: # re-raises |
11197
4bb4895e1693
strip: be quiet about temporary internal bundle
Matt Mackall <mpm@selenic.com>
parents:
10881
diff
changeset
|
237 |
if backupfile: |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
238 |
ui.warn(_("strip failed, backup bundle stored in '%s'\n") |
20979
ad5b61370514
repair: make "strip()" treat bundle files via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20977
diff
changeset
|
239 |
% vfs.join(backupfile)) |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
240 |
if tmpbundlefile: |
29957
94ebf56db04e
strip: clarify that user action is required to recover temp bundle
Martin von Zweigbergk <martinvonz@google.com>
parents:
29956
diff
changeset
|
241 |
ui.warn(_("strip failed, unrecovered changes stored in '%s'\n") |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
242 |
% vfs.join(tmpbundlefile)) |
29957
94ebf56db04e
strip: clarify that user action is required to recover temp bundle
Martin von Zweigbergk <martinvonz@google.com>
parents:
29956
diff
changeset
|
243 |
ui.warn(_("(fix the problem, then recover the changesets with " |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
244 |
"\"hg unbundle '%s'\")\n") % vfs.join(tmpbundlefile)) |
8073
e8a28556a0a8
strip: make repair.strip transactional to avoid repository corruption
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
7361
diff
changeset
|
245 |
raise |
22057
445472225ccd
strip: remove -b/--backup codepaths
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
21064
diff
changeset
|
246 |
else: |
29958
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
247 |
if tmpbundlefile: |
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
248 |
# Remove temporary bundle only if there were no exceptions |
769aee32fae0
strip: don't use "full" and "partial" to describe bundles
Martin von Zweigbergk <martinvonz@google.com>
parents:
29957
diff
changeset
|
249 |
vfs.unlink(tmpbundlefile) |
4702
18e91c9def0c
strip: move strip code to a new repair module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
250 |
|
18395
904b7109938e
destroyed: drop complex branchcache rebuilt logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18311
diff
changeset
|
251 |
repo.destroyed() |
30288
c1345969f6c5
repair: make strip() return backup file path
Martin von Zweigbergk <martinvonz@google.com>
parents:
30005
diff
changeset
|
252 |
# return the backup file path (or None if 'backup' was False) so |
c1345969f6c5
repair: make strip() return backup file path
Martin von Zweigbergk <martinvonz@google.com>
parents:
30005
diff
changeset
|
253 |
# extensions can use it |
c1345969f6c5
repair: make strip() return backup file path
Martin von Zweigbergk <martinvonz@google.com>
parents:
30005
diff
changeset
|
254 |
return backupfile |
25652
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
255 |
|
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
256 |
def rebuildfncache(ui, repo): |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
257 |
"""Rebuilds the fncache file from repo history. |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
258 |
|
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
259 |
Missing entries will be added. Extra entries will be removed. |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
260 |
""" |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
261 |
repo = repo.unfiltered() |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
262 |
|
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
263 |
if 'fncache' not in repo.requirements: |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
264 |
ui.warn(_('(not rebuilding fncache because repository does not ' |
25874
3e84f40232c7
repair: fix typo in warning message
Wagner Bruna <wbruna@yahoo.com>
parents:
25845
diff
changeset
|
265 |
'support fncache)\n')) |
25652
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
266 |
return |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
267 |
|
27860
0da102e4f203
with: use context manager in rebuildfncache again
Bryan O'Sullivan <bryano@fb.com>
parents:
27553
diff
changeset
|
268 |
with repo.lock(): |
25652
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
269 |
fnc = repo.store.fncache |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
270 |
# Trigger load of fncache. |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
271 |
if 'irrelevant' in fnc: |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
272 |
pass |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
273 |
|
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
274 |
oldentries = set(fnc.entries) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
275 |
newentries = set() |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
276 |
seenfiles = set() |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
277 |
|
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
278 |
repolen = len(repo) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
279 |
for rev in repo: |
28466
c7d45c5a8cea
repair: specify unit for ui.progress in rebuildfncache()
Anton Shestakov <av6@dwimlabs.net>
parents:
28465
diff
changeset
|
280 |
ui.progress(_('rebuilding'), rev, total=repolen, |
c7d45c5a8cea
repair: specify unit for ui.progress in rebuildfncache()
Anton Shestakov <av6@dwimlabs.net>
parents:
28465
diff
changeset
|
281 |
unit=_('changesets')) |
25652
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
282 |
|
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
283 |
ctx = repo[rev] |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
284 |
for f in ctx.files(): |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
285 |
# This is to minimize I/O. |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
286 |
if f in seenfiles: |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
287 |
continue |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
288 |
seenfiles.add(f) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
289 |
|
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
290 |
i = 'data/%s.i' % f |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
291 |
d = 'data/%s.d' % f |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
292 |
|
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
293 |
if repo.store._exists(i): |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
294 |
newentries.add(i) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
295 |
if repo.store._exists(d): |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
296 |
newentries.add(d) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
297 |
|
28465
43eb31ea2dcb
repair: use 'rebuilding' progress topic in rebuildfncache()
Anton Shestakov <av6@dwimlabs.net>
parents:
28031
diff
changeset
|
298 |
ui.progress(_('rebuilding'), None) |
25652
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
299 |
|
28031
6f248ba85309
treemanifest: fix debugrebuildfncache
Martin von Zweigbergk <martinvonz@google.com>
parents:
28007
diff
changeset
|
300 |
if 'treemanifest' in repo.requirements: # safe but unnecessary otherwise |
28007
fb92927f9775
treemanifests: fix streaming clone
Martin von Zweigbergk <martinvonz@google.com>
parents:
27930
diff
changeset
|
301 |
for dir in util.dirs(seenfiles): |
fb92927f9775
treemanifests: fix streaming clone
Martin von Zweigbergk <martinvonz@google.com>
parents:
27930
diff
changeset
|
302 |
i = 'meta/%s/00manifest.i' % dir |
fb92927f9775
treemanifests: fix streaming clone
Martin von Zweigbergk <martinvonz@google.com>
parents:
27930
diff
changeset
|
303 |
d = 'meta/%s/00manifest.d' % dir |
fb92927f9775
treemanifests: fix streaming clone
Martin von Zweigbergk <martinvonz@google.com>
parents:
27930
diff
changeset
|
304 |
|
fb92927f9775
treemanifests: fix streaming clone
Martin von Zweigbergk <martinvonz@google.com>
parents:
27930
diff
changeset
|
305 |
if repo.store._exists(i): |
fb92927f9775
treemanifests: fix streaming clone
Martin von Zweigbergk <martinvonz@google.com>
parents:
27930
diff
changeset
|
306 |
newentries.add(i) |
fb92927f9775
treemanifests: fix streaming clone
Martin von Zweigbergk <martinvonz@google.com>
parents:
27930
diff
changeset
|
307 |
if repo.store._exists(d): |
fb92927f9775
treemanifests: fix streaming clone
Martin von Zweigbergk <martinvonz@google.com>
parents:
27930
diff
changeset
|
308 |
newentries.add(d) |
fb92927f9775
treemanifests: fix streaming clone
Martin von Zweigbergk <martinvonz@google.com>
parents:
27930
diff
changeset
|
309 |
|
25652
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
310 |
addcount = len(newentries - oldentries) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
311 |
removecount = len(oldentries - newentries) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
312 |
for p in sorted(oldentries - newentries): |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
313 |
ui.write(_('removing %s\n') % p) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
314 |
for p in sorted(newentries - oldentries): |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
315 |
ui.write(_('adding %s\n') % p) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
316 |
|
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
317 |
if addcount or removecount: |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
318 |
ui.write(_('%d items added, %d removed from fncache\n') % |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
319 |
(addcount, removecount)) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
320 |
fnc.entries = newentries |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
321 |
fnc._dirty = True |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
322 |
|
27871
f1c316fd91f9
with: use context manager in rebuildfncache
Bryan O'Sullivan <bryano@fb.com>
parents:
27860
diff
changeset
|
323 |
with repo.transaction('fncache') as tr: |
25652
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
324 |
fnc.write(tr) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
325 |
else: |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
326 |
ui.write(_('fncache already up to date\n')) |
2882d6886919
repair: add functionality to rebuild fncache
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25404
diff
changeset
|
327 |
|
26624
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
328 |
def stripbmrevset(repo, mark): |
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
329 |
""" |
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
330 |
The revset to strip when strip is called with -B mark |
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
331 |
|
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
332 |
Needs to live here so extensions can use it and wrap it even when strip is |
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
333 |
not enabled or not present on a box. |
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
334 |
""" |
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
335 |
return repo.revs("ancestors(bookmark(%s)) - " |
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
336 |
"ancestors(head() and not bookmark(%s)) - " |
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
337 |
"ancestors(bookmark() and not bookmark(%s))", |
bcace0fbb4c8
strip: factor out revset calculation for strip -B
Ryan McElroy <rmcelroy@fb.com>
parents:
26587
diff
changeset
|
338 |
mark, mark, mark) |
28868
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
339 |
|
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
340 |
def deleteobsmarkers(obsstore, indices): |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
341 |
"""Delete some obsmarkers from obsstore and return how many were deleted |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
342 |
|
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
343 |
'indices' is a list of ints which are the indices |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
344 |
of the markers to be deleted. |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
345 |
|
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
346 |
Every invocation of this function completely rewrites the obsstore file, |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
347 |
skipping the markers we want to be removed. The new temporary file is |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
348 |
created, remaining markers are written there and on .close() this file |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
349 |
gets atomically renamed to obsstore, thus guaranteeing consistency.""" |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
350 |
if not indices: |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
351 |
# we don't want to rewrite the obsstore with the same content |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
352 |
return |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
353 |
|
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
354 |
left = [] |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
355 |
current = obsstore._all |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
356 |
n = 0 |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
357 |
for i, m in enumerate(current): |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
358 |
if i in indices: |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
359 |
n += 1 |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
360 |
continue |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
361 |
left.append(m) |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
362 |
|
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
363 |
newobsstorefile = obsstore.svfs('obsstore', 'w', atomictemp=True) |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
364 |
for bytes in obsolete.encodemarkers(left, True, obsstore._version): |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
365 |
newobsstorefile.write(bytes) |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
366 |
newobsstorefile.close() |
445a25bb70be
obsstore: move delete function from obsstore class to repair module
Kostia Balytskyi <ikostia@fb.com>
parents:
28666
diff
changeset
|
367 |
return n |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
368 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
369 |
def upgraderequiredsourcerequirements(repo): |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
370 |
"""Obtain requirements required to be present to upgrade a repo. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
371 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
372 |
An upgrade will not be allowed if the repository doesn't have the |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
373 |
requirements returned by this function. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
374 |
""" |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
375 |
return set([ |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
376 |
# Introduced in Mercurial 0.9.2. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
377 |
'revlogv1', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
378 |
# Introduced in Mercurial 0.9.2. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
379 |
'store', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
380 |
]) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
381 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
382 |
def upgradeblocksourcerequirements(repo): |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
383 |
"""Obtain requirements that will prevent an upgrade from occurring. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
384 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
385 |
An upgrade cannot be performed if the source repository contains a |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
386 |
requirements in the returned set. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
387 |
""" |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
388 |
return set([ |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
389 |
# The upgrade code does not yet support these experimental features. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
390 |
# This is an artificial limitation. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
391 |
'manifestv2', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
392 |
'treemanifest', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
393 |
# This was a precursor to generaldelta and was never enabled by default. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
394 |
# It should (hopefully) not exist in the wild. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
395 |
'parentdelta', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
396 |
# Upgrade should operate on the actual store, not the shared link. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
397 |
'shared', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
398 |
]) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
399 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
400 |
def upgradesupportremovedrequirements(repo): |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
401 |
"""Obtain requirements that can be removed during an upgrade. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
402 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
403 |
If an upgrade were to create a repository that dropped a requirement, |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
404 |
the dropped requirement must appear in the returned set for the upgrade |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
405 |
to be allowed. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
406 |
""" |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
407 |
return set() |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
408 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
409 |
def upgradesupporteddestrequirements(repo): |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
410 |
"""Obtain requirements that upgrade supports in the destination. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
411 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
412 |
If the result of the upgrade would create requirements not in this set, |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
413 |
the upgrade is disallowed. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
414 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
415 |
Extensions should monkeypatch this to add their custom requirements. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
416 |
""" |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
417 |
return set([ |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
418 |
'dotencode', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
419 |
'fncache', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
420 |
'generaldelta', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
421 |
'revlogv1', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
422 |
'store', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
423 |
]) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
424 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
425 |
def upgradeallowednewrequirements(repo): |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
426 |
"""Obtain requirements that can be added to a repository during upgrade. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
427 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
428 |
This is used to disallow proposed requirements from being added when |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
429 |
they weren't present before. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
430 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
431 |
We use a list of allowed requirement additions instead of a list of known |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
432 |
bad additions because the whitelist approach is safer and will prevent |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
433 |
future, unknown requirements from accidentally being added. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
434 |
""" |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
435 |
return set([ |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
436 |
'dotencode', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
437 |
'fncache', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
438 |
'generaldelta', |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
439 |
]) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
440 |
|
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
441 |
deficiency = 'deficiency' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
442 |
optimisation = 'optimization' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
443 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
444 |
class upgradeimprovement(object): |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
445 |
"""Represents an improvement that can be made as part of an upgrade. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
446 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
447 |
The following attributes are defined on each instance: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
448 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
449 |
name |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
450 |
Machine-readable string uniquely identifying this improvement. It |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
451 |
will be mapped to an action later in the upgrade process. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
452 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
453 |
type |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
454 |
Either ``deficiency`` or ``optimisation``. A deficiency is an obvious |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
455 |
problem. An optimization is an action (sometimes optional) that |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
456 |
can be taken to further improve the state of the repository. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
457 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
458 |
description |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
459 |
Message intended for humans explaining the improvement in more detail, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
460 |
including the implications of it. For ``deficiency`` types, should be |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
461 |
worded in the present tense. For ``optimisation`` types, should be |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
462 |
worded in the future tense. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
463 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
464 |
upgrademessage |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
465 |
Message intended for humans explaining what an upgrade addressing this |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
466 |
issue will do. Should be worded in the future tense. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
467 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
468 |
fromdefault (``deficiency`` types only) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
469 |
Boolean indicating whether the current (deficient) state deviates |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
470 |
from Mercurial's default configuration. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
471 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
472 |
fromconfig (``deficiency`` types only) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
473 |
Boolean indicating whether the current (deficient) state deviates |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
474 |
from the current Mercurial configuration. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
475 |
""" |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
476 |
def __init__(self, name, type, description, upgrademessage, **kwargs): |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
477 |
self.name = name |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
478 |
self.type = type |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
479 |
self.description = description |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
480 |
self.upgrademessage = upgrademessage |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
481 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
482 |
for k, v in kwargs.items(): |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
483 |
setattr(self, k, v) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
484 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
485 |
def upgradefindimprovements(repo): |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
486 |
"""Determine improvements that can be made to the repo during upgrade. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
487 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
488 |
Returns a list of ``upgradeimprovement`` describing repository deficiencies |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
489 |
and optimizations. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
490 |
""" |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
491 |
# Avoid cycle: cmdutil -> repair -> localrepo -> cmdutil |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
492 |
from . import localrepo |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
493 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
494 |
newreporeqs = localrepo.newreporequirements(repo) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
495 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
496 |
improvements = [] |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
497 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
498 |
# We could detect lack of revlogv1 and store here, but they were added |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
499 |
# in 0.9.2 and we don't support upgrading repos without these |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
500 |
# requirements, so let's not bother. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
501 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
502 |
if 'fncache' not in repo.requirements: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
503 |
improvements.append(upgradeimprovement( |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
504 |
name='fncache', |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
505 |
type=deficiency, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
506 |
description=_('long and reserved filenames may not work correctly; ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
507 |
'repository performance is sub-optimal'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
508 |
upgrademessage=_('repository will be more resilient to storing ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
509 |
'certain paths and performance of certain ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
510 |
'operations should be improved'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
511 |
fromdefault=True, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
512 |
fromconfig='fncache' in newreporeqs)) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
513 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
514 |
if 'dotencode' not in repo.requirements: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
515 |
improvements.append(upgradeimprovement( |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
516 |
name='dotencode', |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
517 |
type=deficiency, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
518 |
description=_('storage of filenames beginning with a period or ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
519 |
'space may not work correctly'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
520 |
upgrademessage=_('repository will be better able to store files ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
521 |
'beginning with a space or period'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
522 |
fromdefault=True, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
523 |
fromconfig='dotencode' in newreporeqs)) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
524 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
525 |
if 'generaldelta' not in repo.requirements: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
526 |
improvements.append(upgradeimprovement( |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
527 |
name='generaldelta', |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
528 |
type=deficiency, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
529 |
description=_('deltas within internal storage are unable to ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
530 |
'choose optimal revisions; repository is larger and ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
531 |
'slower than it could be; interaction with other ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
532 |
'repositories may require extra network and CPU ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
533 |
'resources, making "hg push" and "hg pull" slower'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
534 |
upgrademessage=_('repository storage will be able to create ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
535 |
'optimal deltas; new repository data will be ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
536 |
'smaller and read times should decrease; ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
537 |
'interacting with other repositories using this ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
538 |
'storage model should require less network and ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
539 |
'CPU resources, making "hg push" and "hg pull" ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
540 |
'faster'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
541 |
fromdefault=True, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
542 |
fromconfig='generaldelta' in newreporeqs)) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
543 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
544 |
# Mercurial 4.0 changed changelogs to not use delta chains. Search for |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
545 |
# changelogs with deltas. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
546 |
cl = repo.changelog |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
547 |
for rev in cl: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
548 |
chainbase = cl.chainbase(rev) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
549 |
if chainbase != rev: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
550 |
improvements.append(upgradeimprovement( |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
551 |
name='removecldeltachain', |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
552 |
type=deficiency, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
553 |
description=_('changelog storage is using deltas instead of ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
554 |
'raw entries; changelog reading and any ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
555 |
'operation relying on changelog data are slower ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
556 |
'than they could be'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
557 |
upgrademessage=_('changelog storage will be reformated to ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
558 |
'store raw entries; changelog reading will be ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
559 |
'faster; changelog size may be reduced'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
560 |
fromdefault=True, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
561 |
fromconfig=True)) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
562 |
break |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
563 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
564 |
# Now for the optimizations. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
565 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
566 |
# These are unconditionally added. There is logic later that figures out |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
567 |
# which ones to apply. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
568 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
569 |
improvements.append(upgradeimprovement( |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
570 |
name='redeltaparent', |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
571 |
type=optimisation, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
572 |
description=_('deltas within internal storage will be recalculated to ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
573 |
'choose an optimal base revision where this was not ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
574 |
'already done; the size of the repository may shrink and ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
575 |
'various operations may become faster; the first time ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
576 |
'this optimization is performed could slow down upgrade ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
577 |
'execution considerably; subsequent invocations should ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
578 |
'not run noticeably slower'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
579 |
upgrademessage=_('deltas within internal storage will choose a new ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
580 |
'base revision if needed'))) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
581 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
582 |
improvements.append(upgradeimprovement( |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
583 |
name='redeltamultibase', |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
584 |
type=optimisation, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
585 |
description=_('deltas within internal storage will be recalculated ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
586 |
'against multiple base revision and the smallest ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
587 |
'difference will be used; the size of the repository may ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
588 |
'shrink significantly when there are many merges; this ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
589 |
'optimization will slow down execution in proportion to ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
590 |
'the number of merges in the repository and the amount ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
591 |
'of files in the repository; this slow down should not ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
592 |
'be significant unless there are tens of thousands of ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
593 |
'files and thousands of merges'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
594 |
upgrademessage=_('deltas within internal storage will choose an ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
595 |
'optimal delta by computing deltas against multiple ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
596 |
'parents; may slow down execution time ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
597 |
'significantly'))) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
598 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
599 |
improvements.append(upgradeimprovement( |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
600 |
name='redeltaall', |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
601 |
type=optimisation, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
602 |
description=_('deltas within internal storage will always be ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
603 |
'recalculated without reusing prior deltas; this will ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
604 |
'likely make execution run several times slower; this ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
605 |
'optimization is typically not needed'), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
606 |
upgrademessage=_('deltas within internal storage will be fully ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
607 |
'recomputed; this will likely drastically slow down ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
608 |
'execution time'))) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
609 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
610 |
return improvements |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
611 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
612 |
def upgradedetermineactions(repo, improvements, sourcereqs, destreqs, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
613 |
optimize): |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
614 |
"""Determine upgrade actions that will be performed. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
615 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
616 |
Given a list of improvements as returned by ``upgradefindimprovements``, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
617 |
determine the list of upgrade actions that will be performed. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
618 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
619 |
The role of this function is to filter improvements if needed, apply |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
620 |
recommended optimizations from the improvements list that make sense, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
621 |
etc. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
622 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
623 |
Returns a list of action names. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
624 |
""" |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
625 |
newactions = [] |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
626 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
627 |
knownreqs = upgradesupporteddestrequirements(repo) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
628 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
629 |
for i in improvements: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
630 |
name = i.name |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
631 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
632 |
# If the action is a requirement that doesn't show up in the |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
633 |
# destination requirements, prune the action. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
634 |
if name in knownreqs and name not in destreqs: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
635 |
continue |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
636 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
637 |
if i.type == deficiency: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
638 |
newactions.append(name) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
639 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
640 |
newactions.extend(o for o in sorted(optimize) if o not in newactions) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
641 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
642 |
# FUTURE consider adding some optimizations here for certain transitions. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
643 |
# e.g. adding generaldelta could schedule parent redeltas. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
644 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
645 |
return newactions |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
646 |
|
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
647 |
def _revlogfrompath(repo, path): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
648 |
"""Obtain a revlog from a repo path. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
649 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
650 |
An instance of the appropriate class is returned. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
651 |
""" |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
652 |
if path == '00changelog.i': |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
653 |
return changelog.changelog(repo.svfs) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
654 |
elif path.endswith('00manifest.i'): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
655 |
mandir = path[:-len('00manifest.i')] |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
656 |
return manifest.manifestrevlog(repo.svfs, dir=mandir) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
657 |
else: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
658 |
# Filelogs don't do anything special with settings. So we can use a |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
659 |
# vanilla revlog. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
660 |
return revlog.revlog(repo.svfs, path) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
661 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
662 |
def _copyrevlogs(ui, srcrepo, dstrepo, tr, deltareuse, aggressivemergedeltas): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
663 |
"""Copy revlogs between 2 repos.""" |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
664 |
revcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
665 |
srcsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
666 |
srcrawsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
667 |
dstsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
668 |
fcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
669 |
frevcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
670 |
fsrcsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
671 |
frawsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
672 |
fdstsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
673 |
mcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
674 |
mrevcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
675 |
msrcsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
676 |
mrawsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
677 |
mdstsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
678 |
crevcount = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
679 |
csrcsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
680 |
crawsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
681 |
cdstsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
682 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
683 |
# Perform a pass to collect metadata. This validates we can open all |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
684 |
# source files and allows a unified progress bar to be displayed. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
685 |
for unencoded, encoded, size in srcrepo.store.walk(): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
686 |
if unencoded.endswith('.d'): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
687 |
continue |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
688 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
689 |
rl = _revlogfrompath(srcrepo, unencoded) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
690 |
revcount += len(rl) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
691 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
692 |
datasize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
693 |
rawsize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
694 |
idx = rl.index |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
695 |
for rev in rl: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
696 |
e = idx[rev] |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
697 |
datasize += e[1] |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
698 |
rawsize += e[2] |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
699 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
700 |
srcsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
701 |
srcrawsize += rawsize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
702 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
703 |
# This is for the separate progress bars. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
704 |
if isinstance(rl, changelog.changelog): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
705 |
crevcount += len(rl) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
706 |
csrcsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
707 |
crawsize += rawsize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
708 |
elif isinstance(rl, manifest.manifestrevlog): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
709 |
mcount += 1 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
710 |
mrevcount += len(rl) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
711 |
msrcsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
712 |
mrawsize += rawsize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
713 |
elif isinstance(rl, revlog.revlog): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
714 |
fcount += 1 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
715 |
frevcount += len(rl) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
716 |
fsrcsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
717 |
frawsize += rawsize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
718 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
719 |
if not revcount: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
720 |
return |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
721 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
722 |
ui.write(_('migrating %d total revisions (%d in filelogs, %d in manifests, ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
723 |
'%d in changelog)\n') % |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
724 |
(revcount, frevcount, mrevcount, crevcount)) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
725 |
ui.write(_('migrating %s in store; %s tracked data\n') % ( |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
726 |
(util.bytecount(srcsize), util.bytecount(srcrawsize)))) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
727 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
728 |
# Used to keep track of progress. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
729 |
progress = [] |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
730 |
def oncopiedrevision(rl, rev, node): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
731 |
progress[1] += 1 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
732 |
srcrepo.ui.progress(progress[0], progress[1], total=progress[2]) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
733 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
734 |
# Do the actual copying. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
735 |
# FUTURE this operation can be farmed off to worker processes. |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
736 |
seen = set() |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
737 |
for unencoded, encoded, size in srcrepo.store.walk(): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
738 |
if unencoded.endswith('.d'): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
739 |
continue |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
740 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
741 |
oldrl = _revlogfrompath(srcrepo, unencoded) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
742 |
newrl = _revlogfrompath(dstrepo, unencoded) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
743 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
744 |
if isinstance(oldrl, changelog.changelog) and 'c' not in seen: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
745 |
ui.write(_('finished migrating %d manifest revisions across %d ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
746 |
'manifests; change in size: %s\n') % |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
747 |
(mrevcount, mcount, util.bytecount(mdstsize - msrcsize))) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
748 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
749 |
ui.write(_('migrating changelog containing %d revisions ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
750 |
'(%s in store; %s tracked data)\n') % |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
751 |
(crevcount, util.bytecount(csrcsize), |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
752 |
util.bytecount(crawsize))) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
753 |
seen.add('c') |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
754 |
progress[:] = [_('changelog revisions'), 0, crevcount] |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
755 |
elif isinstance(oldrl, manifest.manifestrevlog) and 'm' not in seen: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
756 |
ui.write(_('finished migrating %d filelog revisions across %d ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
757 |
'filelogs; change in size: %s\n') % |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
758 |
(frevcount, fcount, util.bytecount(fdstsize - fsrcsize))) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
759 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
760 |
ui.write(_('migrating %d manifests containing %d revisions ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
761 |
'(%s in store; %s tracked data)\n') % |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
762 |
(mcount, mrevcount, util.bytecount(msrcsize), |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
763 |
util.bytecount(mrawsize))) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
764 |
seen.add('m') |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
765 |
progress[:] = [_('manifest revisions'), 0, mrevcount] |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
766 |
elif 'f' not in seen: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
767 |
ui.write(_('migrating %d filelogs containing %d revisions ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
768 |
'(%s in store; %s tracked data)\n') % |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
769 |
(fcount, frevcount, util.bytecount(fsrcsize), |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
770 |
util.bytecount(frawsize))) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
771 |
seen.add('f') |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
772 |
progress[:] = [_('file revisions'), 0, frevcount] |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
773 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
774 |
ui.progress(progress[0], progress[1], total=progress[2]) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
775 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
776 |
ui.note(_('cloning %d revisions from %s\n') % (len(oldrl), unencoded)) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
777 |
oldrl.clone(tr, newrl, addrevisioncb=oncopiedrevision, |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
778 |
deltareuse=deltareuse, |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
779 |
aggressivemergedeltas=aggressivemergedeltas) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
780 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
781 |
datasize = 0 |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
782 |
idx = newrl.index |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
783 |
for rev in newrl: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
784 |
datasize += idx[rev][1] |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
785 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
786 |
dstsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
787 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
788 |
if isinstance(newrl, changelog.changelog): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
789 |
cdstsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
790 |
elif isinstance(newrl, manifest.manifestrevlog): |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
791 |
mdstsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
792 |
else: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
793 |
fdstsize += datasize |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
794 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
795 |
ui.progress(progress[0], None) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
796 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
797 |
ui.write(_('finished migrating %d changelog revisions; change in size: ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
798 |
'%s\n') % (crevcount, util.bytecount(cdstsize - csrcsize))) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
799 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
800 |
ui.write(_('finished migrating %d total revisions; total change in store ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
801 |
'size: %s\n') % (revcount, util.bytecount(dstsize - srcsize))) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
802 |
|
30780
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
803 |
def _upgradefilterstorefile(srcrepo, dstrepo, requirements, path, mode, st): |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
804 |
"""Determine whether to copy a store file during upgrade. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
805 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
806 |
This function is called when migrating store files from ``srcrepo`` to |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
807 |
``dstrepo`` as part of upgrading a repository. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
808 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
809 |
Args: |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
810 |
srcrepo: repo we are copying from |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
811 |
dstrepo: repo we are copying to |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
812 |
requirements: set of requirements for ``dstrepo`` |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
813 |
path: store file being examined |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
814 |
mode: the ``ST_MODE`` file type of ``path`` |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
815 |
st: ``stat`` data structure for ``path`` |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
816 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
817 |
Function should return ``True`` if the file is to be copied. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
818 |
""" |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
819 |
# Skip revlogs. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
820 |
if path.endswith(('.i', '.d')): |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
821 |
return False |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
822 |
# Skip transaction related files. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
823 |
if path.startswith('undo'): |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
824 |
return False |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
825 |
# Only copy regular files. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
826 |
if mode != stat.S_IFREG: |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
827 |
return False |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
828 |
# Skip other skipped files. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
829 |
if path in ('lock', 'fncache'): |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
830 |
return False |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
831 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
832 |
return True |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
833 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
834 |
def _upgradefinishdatamigration(ui, srcrepo, dstrepo, requirements): |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
835 |
"""Hook point for extensions to perform additional actions during upgrade. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
836 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
837 |
This function is called after revlogs and store files have been copied but |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
838 |
before the new store is swapped into the original location. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
839 |
""" |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
840 |
|
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
841 |
def _upgraderepo(ui, srcrepo, dstrepo, requirements, actions): |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
842 |
"""Do the low-level work of upgrading a repository. |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
843 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
844 |
The upgrade is effectively performed as a copy between a source |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
845 |
repository and a temporary destination repository. |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
846 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
847 |
The source repository is unmodified for as long as possible so the |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
848 |
upgrade can abort at any time without causing loss of service for |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
849 |
readers and without corrupting the source repository. |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
850 |
""" |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
851 |
assert srcrepo.currentwlock() |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
852 |
assert dstrepo.currentwlock() |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
853 |
|
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
854 |
ui.write(_('(it is safe to interrupt this process any time before ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
855 |
'data migration completes)\n')) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
856 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
857 |
if 'redeltaall' in actions: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
858 |
deltareuse = revlog.revlog.DELTAREUSENEVER |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
859 |
elif 'redeltaparent' in actions: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
860 |
deltareuse = revlog.revlog.DELTAREUSESAMEREVS |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
861 |
elif 'redeltamultibase' in actions: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
862 |
deltareuse = revlog.revlog.DELTAREUSESAMEREVS |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
863 |
else: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
864 |
deltareuse = revlog.revlog.DELTAREUSEALWAYS |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
865 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
866 |
with dstrepo.transaction('upgrade') as tr: |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
867 |
_copyrevlogs(ui, srcrepo, dstrepo, tr, deltareuse, |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
868 |
'redeltamultibase' in actions) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
869 |
|
30780
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
870 |
# Now copy other files in the store directory. |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
871 |
for p, kind, st in srcrepo.store.vfs.readdir('', stat=True): |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
872 |
if not _upgradefilterstorefile(srcrepo, dstrepo, requirements, |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
873 |
p, kind, st): |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
874 |
continue |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
875 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
876 |
srcrepo.ui.write(_('copying %s\n') % p) |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
877 |
src = srcrepo.store.vfs.join(p) |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
878 |
dst = dstrepo.store.vfs.join(p) |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
879 |
util.copyfile(src, dst, copystat=True) |
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
880 |
|
2603d04889e1
repair: copy non-revlog store files during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30779
diff
changeset
|
881 |
_upgradefinishdatamigration(ui, srcrepo, dstrepo, requirements) |
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
882 |
|
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
883 |
ui.write(_('data fully migrated to temporary repository\n')) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
884 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
885 |
backuppath = tempfile.mkdtemp(prefix='upgradebackup.', dir=srcrepo.path) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
886 |
backupvfs = scmutil.vfs(backuppath) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
887 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
888 |
# Make a backup of requires file first, as it is the first to be modified. |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
889 |
util.copyfile(srcrepo.join('requires'), backupvfs.join('requires')) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
890 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
891 |
# We install an arbitrary requirement that clients must not support |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
892 |
# as a mechanism to lock out new clients during the data swap. This is |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
893 |
# better than allowing a client to continue while the repository is in |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
894 |
# an inconsistent state. |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
895 |
ui.write(_('marking source repository as being upgraded; clients will be ' |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
896 |
'unable to read from repository\n')) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
897 |
scmutil.writerequires(srcrepo.vfs, |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
898 |
srcrepo.requirements | set(['upgradeinprogress'])) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
899 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
900 |
ui.write(_('starting in-place swap of repository data\n')) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
901 |
ui.write(_('replaced files will be backed up at %s\n') % |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
902 |
backuppath) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
903 |
|
30779
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
904 |
# Now swap in the new store directory. Doing it as a rename should make |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
905 |
# the operation nearly instantaneous and atomic (at least in well-behaved |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
906 |
# environments). |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
907 |
ui.write(_('replacing store...\n')) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
908 |
tstart = time.time() |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
909 |
util.rename(srcrepo.spath, backupvfs.join('store')) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
910 |
util.rename(dstrepo.spath, srcrepo.spath) |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
911 |
elapsed = time.time() - tstart |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
912 |
ui.write(_('store replacement complete; repository was inconsistent for ' |
38aa1ca97b6a
repair: migrate revlogs during upgrade
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30777
diff
changeset
|
913 |
'%0.1fs\n') % elapsed) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
914 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
915 |
# We first write the requirements file. Any new requirements will lock |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
916 |
# out legacy clients. |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
917 |
ui.write(_('finalizing requirements file and making repository readable ' |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
918 |
'again\n')) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
919 |
scmutil.writerequires(srcrepo.vfs, requirements) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
920 |
|
30781
f2c069bf78ee
repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30780
diff
changeset
|
921 |
# The lock file from the old store won't be removed because nothing has a |
f2c069bf78ee
repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30780
diff
changeset
|
922 |
# reference to its new location. So clean it up manually. Alternatively, we |
f2c069bf78ee
repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30780
diff
changeset
|
923 |
# could update srcrepo.svfs and other variables to point to the new |
f2c069bf78ee
repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30780
diff
changeset
|
924 |
# location. This is simpler. |
f2c069bf78ee
repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30780
diff
changeset
|
925 |
backupvfs.unlink('store/lock') |
f2c069bf78ee
repair: clean up stale lock file from store backup
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30780
diff
changeset
|
926 |
|
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
927 |
return backuppath |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
928 |
|
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
929 |
def upgraderepo(ui, repo, run=False, optimize=None): |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
930 |
"""Upgrade a repository in place.""" |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
931 |
# Avoid cycle: cmdutil -> repair -> localrepo -> cmdutil |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
932 |
from . import localrepo |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
933 |
|
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
934 |
optimize = set(optimize or []) |
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
935 |
repo = repo.unfiltered() |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
936 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
937 |
# Ensure the repository can be upgraded. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
938 |
missingreqs = upgraderequiredsourcerequirements(repo) - repo.requirements |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
939 |
if missingreqs: |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
940 |
raise error.Abort(_('cannot upgrade repository; requirement ' |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
941 |
'missing: %s') % _(', ').join(sorted(missingreqs))) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
942 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
943 |
blockedreqs = upgradeblocksourcerequirements(repo) & repo.requirements |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
944 |
if blockedreqs: |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
945 |
raise error.Abort(_('cannot upgrade repository; unsupported source ' |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
946 |
'requirement: %s') % |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
947 |
_(', ').join(sorted(blockedreqs))) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
948 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
949 |
# FUTURE there is potentially a need to control the wanted requirements via |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
950 |
# command arguments or via an extension hook point. |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
951 |
newreqs = localrepo.newreporequirements(repo) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
952 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
953 |
noremovereqs = (repo.requirements - newreqs - |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
954 |
upgradesupportremovedrequirements(repo)) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
955 |
if noremovereqs: |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
956 |
raise error.Abort(_('cannot upgrade repository; requirement would be ' |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
957 |
'removed: %s') % _(', ').join(sorted(noremovereqs))) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
958 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
959 |
noaddreqs = (newreqs - repo.requirements - |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
960 |
upgradeallowednewrequirements(repo)) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
961 |
if noaddreqs: |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
962 |
raise error.Abort(_('cannot upgrade repository; do not support adding ' |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
963 |
'requirement: %s') % |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
964 |
_(', ').join(sorted(noaddreqs))) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
965 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
966 |
unsupportedreqs = newreqs - upgradesupporteddestrequirements(repo) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
967 |
if unsupportedreqs: |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
968 |
raise error.Abort(_('cannot upgrade repository; do not support ' |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
969 |
'destination requirement: %s') % |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
970 |
_(', ').join(sorted(unsupportedreqs))) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
971 |
|
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
972 |
# Find and validate all improvements that can be made. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
973 |
improvements = upgradefindimprovements(repo) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
974 |
for i in improvements: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
975 |
if i.type not in (deficiency, optimisation): |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
976 |
raise error.Abort(_('unexpected improvement type %s for %s') % ( |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
977 |
i.type, i.name)) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
978 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
979 |
# Validate arguments. |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
980 |
unknownoptimize = optimize - set(i.name for i in improvements |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
981 |
if i.type == optimisation) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
982 |
if unknownoptimize: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
983 |
raise error.Abort(_('unknown optimization action requested: %s') % |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
984 |
', '.join(sorted(unknownoptimize)), |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
985 |
hint=_('run without arguments to see valid ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
986 |
'optimizations')) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
987 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
988 |
actions = upgradedetermineactions(repo, improvements, repo.requirements, |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
989 |
newreqs, optimize) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
990 |
|
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
991 |
def printrequirements(): |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
992 |
ui.write(_('requirements\n')) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
993 |
ui.write(_(' preserved: %s\n') % |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
994 |
_(', ').join(sorted(newreqs & repo.requirements))) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
995 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
996 |
if repo.requirements - newreqs: |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
997 |
ui.write(_(' removed: %s\n') % |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
998 |
_(', ').join(sorted(repo.requirements - newreqs))) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
999 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1000 |
if newreqs - repo.requirements: |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1001 |
ui.write(_(' added: %s\n') % |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1002 |
_(', ').join(sorted(newreqs - repo.requirements))) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1003 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1004 |
ui.write('\n') |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1005 |
|
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1006 |
def printupgradeactions(): |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1007 |
for action in actions: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1008 |
for i in improvements: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1009 |
if i.name == action: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1010 |
ui.write('%s\n %s\n\n' % |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1011 |
(i.name, i.upgrademessage)) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1012 |
|
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1013 |
if not run: |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1014 |
fromdefault = [] |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1015 |
fromconfig = [] |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1016 |
optimizations = [] |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1017 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1018 |
for i in improvements: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1019 |
assert i.type in (deficiency, optimisation) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1020 |
if i.type == deficiency: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1021 |
if i.fromdefault: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1022 |
fromdefault.append(i) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1023 |
if i.fromconfig: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1024 |
fromconfig.append(i) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1025 |
else: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1026 |
optimizations.append(i) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1027 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1028 |
if fromdefault or fromconfig: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1029 |
fromconfignames = set(x.name for x in fromconfig) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1030 |
onlydefault = [i for i in fromdefault |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1031 |
if i.name not in fromconfignames] |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1032 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1033 |
if fromconfig: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1034 |
ui.write(_('repository lacks features recommended by ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1035 |
'current config options:\n\n')) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1036 |
for i in fromconfig: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1037 |
ui.write('%s\n %s\n\n' % (i.name, i.description)) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1038 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1039 |
if onlydefault: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1040 |
ui.write(_('repository lacks features used by the default ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1041 |
'config options:\n\n')) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1042 |
for i in onlydefault: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1043 |
ui.write('%s\n %s\n\n' % (i.name, i.description)) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1044 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1045 |
ui.write('\n') |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1046 |
else: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1047 |
ui.write(_('(no feature deficiencies found in existing ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1048 |
'repository)\n')) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1049 |
|
30775
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1050 |
ui.write(_('performing an upgrade with "--run" will make the following ' |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1051 |
'changes:\n\n')) |
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1052 |
|
513d68a90398
repair: implement requirements checking for upgrades
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30707
diff
changeset
|
1053 |
printrequirements() |
30776
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1054 |
printupgradeactions() |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1055 |
|
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1056 |
unusedoptimize = [i for i in improvements |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1057 |
if i.name not in actions and i.type == optimisation] |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1058 |
if unusedoptimize: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1059 |
ui.write(_('additional optimizations are available by specifying ' |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1060 |
'"--optimize <name>":\n\n')) |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1061 |
for i in unusedoptimize: |
3997edc4a86d
repair: determine what upgrade will do
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30775
diff
changeset
|
1062 |
ui.write(_('%s\n %s\n\n') % (i.name, i.description)) |
30777
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1063 |
return |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1064 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1065 |
# Else we're in the run=true case. |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1066 |
ui.write(_('upgrade will perform the following actions:\n\n')) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1067 |
printrequirements() |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1068 |
printupgradeactions() |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1069 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1070 |
ui.write(_('beginning upgrade...\n')) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1071 |
with repo.wlock(): |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1072 |
with repo.lock(): |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1073 |
ui.write(_('repository locked and read-only\n')) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1074 |
# Our strategy for upgrading the repository is to create a new, |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1075 |
# temporary repository, write data to it, then do a swap of the |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1076 |
# data. There are less heavyweight ways to do this, but it is easier |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1077 |
# to create a new repo object than to instantiate all the components |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1078 |
# (like the store) separately. |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1079 |
tmppath = tempfile.mkdtemp(prefix='upgrade.', dir=repo.path) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1080 |
backuppath = None |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1081 |
try: |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1082 |
ui.write(_('creating temporary repository to stage migrated ' |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1083 |
'data: %s\n') % tmppath) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1084 |
dstrepo = localrepo.localrepository(repo.baseui, |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1085 |
path=tmppath, |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1086 |
create=True) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1087 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1088 |
with dstrepo.wlock(): |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1089 |
with dstrepo.lock(): |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1090 |
backuppath = _upgraderepo(ui, repo, dstrepo, newreqs, |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1091 |
actions) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1092 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1093 |
finally: |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1094 |
ui.write(_('removing temporary repository %s\n') % tmppath) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1095 |
repo.vfs.rmtree(tmppath, forcibly=True) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1096 |
|
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1097 |
if backuppath: |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1098 |
ui.warn(_('copy of old repository backed up at %s\n') % |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1099 |
backuppath) |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1100 |
ui.warn(_('the old repository will not be deleted; remove ' |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1101 |
'it to free up disk space once the upgraded ' |
7de7afd8bdd9
repair: begin implementation of in-place upgrading
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30776
diff
changeset
|
1102 |
'repository is verified\n')) |