Mercurial > hgsubversion
annotate hgsubversion/replay.py @ 650:685f91015ed6
replay: always fetch the entire first revision
The entire revision is fetched using the just-added get_revision()
wrapper.
Essentially, this allows us to begin a conversion with a non-zero
start revision. As an extra safety feature, this mode is *always* used
for the very first revision, even if no start revision is
specified. For most repositories, this shouldn't matter; the entire
revision will be fetched regardless. However, there are repositories
that currently `confuse' us, such as bzr-svn conversions, and where
this is an improvement.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Tue, 20 Jul 2010 11:55:07 +0200 |
parents | e2c3349b2cca |
children | b3128fec5d54 |
rev | line source |
---|---|
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
528
diff
changeset
|
1 import errno |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
2 import traceback |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
3 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
4 from mercurial import revlog |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
5 from mercurial import node |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
6 from mercurial import context |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
7 from mercurial import util as hgutil |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
8 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
9 import svnexternals |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
10 import util |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
11 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
12 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
13 class MissingPlainTextError(Exception): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
14 """Exception raised when the repo lacks a source file required for replaying |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
15 a txdelta. |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
16 """ |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
17 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
18 class ReplayException(Exception): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
19 """Exception raised when you try and commit but the replay encountered an |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
20 exception. |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
21 """ |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
22 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
23 def convert_rev(ui, meta, svn, r, tbdelta): |
437
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
24 |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
25 editor = meta.editor |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
26 editor.current.clear() |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
27 editor.current.rev = r |
650
685f91015ed6
replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
28 |
685f91015ed6
replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
29 if meta.revmap.oldest <= 0: |
685f91015ed6
replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
30 # no prior revisions are known, so fetch the entire revision contents |
685f91015ed6
replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
31 svn.get_revision(r.revnum, editor) |
685f91015ed6
replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
32 else: |
685f91015ed6
replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
33 svn.get_replay(r.revnum, editor, meta.revmap.oldest) |
685f91015ed6
replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
635
diff
changeset
|
34 |
437
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
35 current = editor.current |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
36 current.findmissing(svn) |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
37 |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
38 # update externals |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
498
diff
changeset
|
39 # TODO fix and re-enable externals for single-directory clones |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
498
diff
changeset
|
40 if current.externals and not meta.layout == 'single': |
437
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
41 |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
42 # accumulate externals records for all branches |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
43 revnum = current.rev.revnum |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
44 branches = {} |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
45 for path, entry in current.externals.iteritems(): |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
46 if not meta.is_path_valid(path): |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
47 ui.warn('WARNING: Invalid path %s in externals\n' % path) |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
48 continue |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
49 |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
50 p, b, bp = meta.split_branch_path(path) |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
51 if bp not in branches: |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
52 external = svnexternals.externalsfile() |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
53 parent = meta.get_parent_revision(revnum, b) |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
54 pctx = meta.repo[parent] |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
55 if '.hgsvnexternals' in pctx: |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
56 external.read(pctx['.hgsvnexternals'].data()) |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
57 branches[bp] = external |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
58 else: |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
59 external = branches[bp] |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
60 |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
61 external[p] = entry |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
62 |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
63 # register externals file changes |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
64 for bp, external in branches.iteritems(): |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
498
diff
changeset
|
65 if bp and bp[-1] != '/': |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
498
diff
changeset
|
66 bp += '/' |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
498
diff
changeset
|
67 path = (bp and bp + '.hgsvnexternals') or '.hgsvnexternals' |
437
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
68 if external: |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
69 current.set(path, external.write(), False, False) |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
70 else: |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
71 current.delete(path) |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
72 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
73 if current.exception is not None: #pragma: no cover |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
74 traceback.print_exception(*current.exception) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
75 raise ReplayException() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
76 if current.missing: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
77 raise MissingPlainTextError() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
78 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
79 # paranoidly generate the list of files to commit |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
80 files_to_commit = set(current.files.keys()) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
81 files_to_commit.update(current.symlinks.keys()) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
82 files_to_commit.update(current.execfiles.keys()) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
83 files_to_commit.update(current.deleted.keys()) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
84 # back to a list and sort so we get sane behavior |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
85 files_to_commit = list(files_to_commit) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
86 files_to_commit.sort() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
87 branch_batches = {} |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
88 rev = current.rev |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
89 date = meta.fixdate(rev.date) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
90 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
91 # build up the branches that have files on them |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
92 for f in files_to_commit: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
93 if not meta.is_path_valid(f): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
94 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
95 p, b = meta.split_branch_path(f)[:2] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
96 if b not in branch_batches: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
97 branch_batches[b] = [] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
98 branch_batches[b].append((p, f)) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
99 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
100 closebranches = {} |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
101 for branch in tbdelta['branches'][1]: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
102 branchedits = meta.revmap.branchedits(branch, rev) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
103 if len(branchedits) < 1: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
104 # can't close a branch that never existed |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
105 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
106 ha = branchedits[0][1] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
107 closebranches[branch] = ha |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
108 |
551
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
109 extraempty = (set(tbdelta['branches'][0]) - |
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
110 (set(current.emptybranches) | set(branch_batches.keys()))) |
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
111 current.emptybranches.update([(x, False) for x in extraempty]) |
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
112 |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
113 # 1. handle normal commits |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
114 closedrevs = closebranches.values() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
115 for branch, files in branch_batches.iteritems(): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
116 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
117 if branch in current.emptybranches and files: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
118 del current.emptybranches[branch] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
119 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
120 files = dict(files) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
121 parents = meta.get_parent_revision(rev.revnum, branch), revlog.nullid |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
122 if parents[0] in closedrevs and branch in meta.closebranches: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
123 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
124 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
125 extra = meta.genextra(rev.revnum, branch) |
517
ef288fb7f2fe
svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents:
499
diff
changeset
|
126 tag = None |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
127 if branch is not None: |
517
ef288fb7f2fe
svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents:
499
diff
changeset
|
128 # New regular tag without modifications, it will be committed by |
ef288fb7f2fe
svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents:
499
diff
changeset
|
129 # svnmeta.committag(), we can skip the whole branch for now |
ef288fb7f2fe
svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents:
499
diff
changeset
|
130 tag = meta.get_path_tag(meta.remotename(branch)) |
547
9e6499c415a9
tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents:
531
diff
changeset
|
131 if (tag and tag not in meta.tags |
9e6499c415a9
tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents:
531
diff
changeset
|
132 and branch not in meta.branches |
9e6499c415a9
tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents:
531
diff
changeset
|
133 and branch not in meta.repo.branchtags() |
9e6499c415a9
tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents:
531
diff
changeset
|
134 and not files): |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
135 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
136 |
447
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
137 parentctx = meta.repo.changectx(parents[0]) |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
138 if tag: |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
139 if parentctx.node() == node.nullid: |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
140 continue |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
141 extra.update({'branch': parentctx.extra().get('branch', None), |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
142 'close': 1}) |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
143 |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
144 if '.hgsvnexternals' not in parentctx and '.hgsvnexternals' in files: |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
145 # Do not register empty externals files |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
146 if (files['.hgsvnexternals'] in current.files |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
147 and not current.files[files['.hgsvnexternals']]): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
148 del files['.hgsvnexternals'] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
149 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
150 def filectxfn(repo, memctx, path): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
151 current_file = files[path] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
152 if current_file in current.deleted: |
557
d74bf020a61c
replay/stupid: raise the correct errno in IOError to fix hg >= e553a425751d
Augie Fackler <durin42@gmail.com>
parents:
551
diff
changeset
|
153 raise IOError(errno.ENOENT, '%s is deleted' % path) |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
154 copied = current.copies.get(current_file) |
447
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
155 flags = parentctx.flags(path) |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
156 is_exec = current.execfiles.get(current_file, 'x' in flags) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
157 is_link = current.symlinks.get(current_file, 'l' in flags) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
158 if current_file in current.files: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
159 data = current.files[current_file] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
160 if is_link and data.startswith('link '): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
161 data = data[len('link '):] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
162 elif is_link: |
437
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
163 ui.warn('file marked as link, but contains data: ' |
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
164 '%s (%r)\n' % (current_file, flags)) |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
165 else: |
447
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
166 data = parentctx.filectx(path).data() |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
167 return context.memfilectx(path=path, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
168 data=data, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
169 islink=is_link, isexec=is_exec, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
170 copied=copied) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
171 |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
557
diff
changeset
|
172 meta.mapbranch(extra) |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
173 current_ctx = context.memctx(meta.repo, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
174 parents, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
175 rev.message or '...', |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
176 files.keys(), |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
177 filectxfn, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
178 meta.authors[rev.author], |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
179 date, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
180 extra) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
181 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
182 new_hash = meta.repo.commitctx(current_ctx) |
437
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
183 util.describe_commit(ui, new_hash, branch) |
447
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
184 if (rev.revnum, branch) not in meta.revmap and not tag: |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
185 meta.revmap[rev.revnum, branch] = new_hash |
447
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
444
diff
changeset
|
186 if tag: |
634
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
574
diff
changeset
|
187 meta.movetag(tag, new_hash, rev, date) |
547
9e6499c415a9
tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents:
531
diff
changeset
|
188 meta.addedtags.pop(tag, None) |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
189 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
190 # 2. handle branches that need to be committed without any files |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
191 for branch in current.emptybranches: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
192 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
193 ha = meta.get_parent_revision(rev.revnum, branch) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
194 if ha == node.nullid: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
195 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
196 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
197 parent_ctx = meta.repo.changectx(ha) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
198 def del_all_files(*args): |
557
d74bf020a61c
replay/stupid: raise the correct errno in IOError to fix hg >= e553a425751d
Augie Fackler <durin42@gmail.com>
parents:
551
diff
changeset
|
199 raise IOError(errno.ENOENT, 'deleting all files') |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
200 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
201 # True here meant nuke all files, shouldn't happen with branch closing |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
202 if current.emptybranches[branch]: #pragma: no cover |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
203 raise hgutil.Abort('Empty commit to an open branch attempted. ' |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
204 'Please report this issue.') |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
205 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
206 extra = meta.genextra(rev.revnum, branch) |
635
e2c3349b2cca
branchmap: map empty commits in replay mode.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
634
diff
changeset
|
207 meta.mapbranch(extra) |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
208 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
209 current_ctx = context.memctx(meta.repo, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
210 (ha, node.nullid), |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
211 rev.message or ' ', |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
212 [], |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
213 del_all_files, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
214 meta.authors[rev.author], |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
215 date, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
216 extra) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
217 new_hash = meta.repo.commitctx(current_ctx) |
437
45ce07a4807f
replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
436
diff
changeset
|
218 util.describe_commit(ui, new_hash, branch) |
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
219 if (rev.revnum, branch) not in meta.revmap: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
220 meta.revmap[rev.revnum, branch] = new_hash |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
221 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
222 return closebranches |