annotate hgsubversion/replay.py @ 1555:cff81f35b31e

cleanup: reference Abort from mercurial.error instead of mercurial.util It's been there since hg 1.7 or so, which lets us avoid any need for compat shims.
author Augie Fackler <raf@durin42.com>
date Sat, 24 Mar 2018 16:39:30 -0400
parents 8410a978c650
children ae572c9be4e6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1555
cff81f35b31e cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
4 from mercurial import error as hgerror
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
5 from mercurial import revlog
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
6 from mercurial import node
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
7 from mercurial import context
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
8 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
9
1103
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1099
diff changeset
10 import compathacks
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
11 import svnexternals
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
12 import util
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
13
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
14
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
15 class MissingPlainTextError(Exception):
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
16 """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
17 a txdelta.
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
18 """
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
19
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
20 class ReplayException(Exception):
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
21 """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
22 exception.
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
23 """
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
24
756
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
25 def updateexternals(ui, meta, current):
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
26 # TODO fix and re-enable externals for single-directory clones
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
27 if not current.externals or meta.layout == 'single':
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
28 return
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
29
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
30 # accumulate externals records for all branches
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
31 revnum = current.rev.revnum
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
32 branches = {}
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
33 for path, entry in current.externals.iteritems():
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
34 if not meta.is_path_valid(path):
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
35 continue
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
36
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
37 p, b, bp = meta.split_branch_path(path)
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
38 if bp not in branches:
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
39 parent = meta.get_parent_revision(revnum, b)
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
40 pctx = meta.repo[parent]
762
c31a1f92e1c6 svnexternals: preliminary support for subrepos based externals
Patrick Mezard <pmezard@gmail.com>
parents: 758
diff changeset
41 branches[bp] = (svnexternals.parse(ui, pctx), pctx)
758
76ebfc41f490 svnexternals: hide .hgsvnexternals parsing in parse()
Patrick Mezard <pmezard@gmail.com>
parents: 757
diff changeset
42 branches[bp][0][p] = entry
756
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
43
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
44 # register externals file changes
757
6e18d9ab6557 pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents: 756
diff changeset
45 for bp, (external, pctx) in branches.iteritems():
756
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
46 if bp and bp[-1] != '/':
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
47 bp += '/'
757
6e18d9ab6557 pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents: 756
diff changeset
48 updates = svnexternals.getchanges(ui, meta.repo, pctx, external)
6e18d9ab6557 pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents: 756
diff changeset
49 for fn, data in updates.iteritems():
6e18d9ab6557 pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents: 756
diff changeset
50 path = (bp and bp + fn) or fn
6e18d9ab6557 pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents: 756
diff changeset
51 if data is not None:
6e18d9ab6557 pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents: 756
diff changeset
52 current.set(path, data, False, False)
6e18d9ab6557 pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents: 756
diff changeset
53 else:
6e18d9ab6557 pull: stop handling .hgsvnexternals explicitely in memctx
Patrick Mezard <pmezard@gmail.com>
parents: 756
diff changeset
54 current.delete(path)
756
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
55
787
4bbc6bf947f5 replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents: 786
diff changeset
56 def convert_rev(ui, meta, svn, r, tbdelta, firstrun):
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
57 try:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
58 return _convert_rev(ui, meta, svn, r, tbdelta, firstrun)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
59 finally:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
60 meta.editor.current.close()
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
61
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
62 def _convert_rev(ui, meta, svn, r, tbdelta, firstrun):
437
45ce07a4807f replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 436
diff changeset
63
45ce07a4807f replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 436
diff changeset
64 editor = meta.editor
45ce07a4807f replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 436
diff changeset
65 editor.current.clear()
45ce07a4807f replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 436
diff changeset
66 editor.current.rev = r
962
8648ccfb8325 editor: process missing files with regular files
Patrick Mezard <patrick@mezard.eu>
parents: 960
diff changeset
67 editor.setsvn(svn)
650
685f91015ed6 replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 635
diff changeset
68
1434
0a6b3da6d34c RevMap: move lastpulled from SVNMeta down into RevMap
Augie Fackler <raf@durin42.com>
parents: 1356
diff changeset
69 if firstrun and meta.revmap.firstpulled <= 0:
787
4bbc6bf947f5 replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents: 786
diff changeset
70 # We know nothing about this project, so fetch everything before
4bbc6bf947f5 replay: fetch full revision at most once per run (issue252)
Patrick Mezard <pmezard@gmail.com>
parents: 786
diff changeset
71 # trying to apply deltas.
786
607f43a0f09c replay: make --debug trace full fetches
Patrick Mezard <pmezard@gmail.com>
parents: 769
diff changeset
72 ui.debug('replay: fetching full revision\n')
650
685f91015ed6 replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 635
diff changeset
73 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
74 else:
1434
0a6b3da6d34c RevMap: move lastpulled from SVNMeta down into RevMap
Augie Fackler <raf@durin42.com>
parents: 1356
diff changeset
75 svn.get_replay(r.revnum, editor, meta.revmap.firstpulled)
938
f9014e28721b editor: start separating svn copies from open files
Patrick Mezard <patrick@mezard.eu>
parents: 910
diff changeset
76 editor.close()
650
685f91015ed6 replay: always fetch the entire first revision
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 635
diff changeset
77
437
45ce07a4807f replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 436
diff changeset
78 current = editor.current
45ce07a4807f replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 436
diff changeset
79
756
379c7837222f replay: extract externals updating from convert_rev()
Patrick Mezard <pmezard@gmail.com>
parents: 741
diff changeset
80 updateexternals(ui, meta, current)
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
81
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 831
diff changeset
82 if current.exception is not None: # pragma: no cover
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
83 traceback.print_exception(*current.exception)
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
84 raise ReplayException()
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
85
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
86 files_to_commit = current.files()
435
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
960
502613f6b583 editor: ignore added or copied files excluded by a filemap
Patrick Mezard <patrick@mezard.eu>
parents: 955
diff changeset
92 failoninvalid = ui.configbool('hgsubversion',
502613f6b583 editor: ignore added or copied files excluded by a filemap
Patrick Mezard <patrick@mezard.eu>
parents: 955
diff changeset
93 'failoninvalidreplayfile', False)
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
94 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
95 if not meta.is_path_valid(f):
960
502613f6b583 editor: ignore added or copied files excluded by a filemap
Patrick Mezard <patrick@mezard.eu>
parents: 955
diff changeset
96 if failoninvalid:
1555
cff81f35b31e cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1549
diff changeset
97 raise hgerror.Abort('file %s should not be in commit list' % f)
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
98 continue
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
99 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
100 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
101 branch_batches[b] = []
1099
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1045
diff changeset
102 if p:
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1045
diff changeset
103 branch_batches[b].append((p, f))
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
104
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
105 closebranches = {}
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
106 for branch in tbdelta['branches'][1]:
1472
cf79525f507c maps: change branchedits to accept revnum directly
Jun Wu <quark@fb.com>
parents: 1434
diff changeset
107 branchedits = meta.revmap.branchedits(branch, rev.revnum)
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
108 if len(branchedits) < 1:
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
109 # 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
110 continue
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
111 ha = branchedits[0][1]
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
112 closebranches[branch] = ha
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
113
551
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
114 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
115 (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
116 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
117
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
118 # 1. handle normal commits
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
119 closedrevs = closebranches.values()
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
120 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
121
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
122 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
123 del current.emptybranches[branch]
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
124
1356
57d65269d30c maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents: 1285
diff changeset
125 if meta.skipbranch(branch):
57d65269d30c maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents: 1285
diff changeset
126 # make sure we also get rid of it from emptybranches
57d65269d30c maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents: 1285
diff changeset
127 if branch in current.emptybranches:
57d65269d30c maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents: 1285
diff changeset
128 del current.emptybranches[branch]
57d65269d30c maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents: 1285
diff changeset
129 continue
57d65269d30c maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents: 1285
diff changeset
130
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
131 files = dict(files)
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
132 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
133 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
134 continue
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
135
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
136 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
137 tag = None
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
138 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
139 # 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
140 # 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
141 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
142 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
143 and branch not in meta.branches
1103
6e1dbf6cbc92 compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents: 1099
diff changeset
144 and branch not in compathacks.branchset(meta.repo)
547
9e6499c415a9 tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents: 531
diff changeset
145 and not files):
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
146 continue
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
147
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 444
diff changeset
148 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
149 if tag:
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 444
diff changeset
150 if parentctx.node() == node.nullid:
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 444
diff changeset
151 continue
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 444
diff changeset
152 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
153 'close': 1})
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 444
diff changeset
154
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
155 def filectxfn(repo, memctx, path):
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
156 current_file = files[path]
1242
df6cb54604eb replay: use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
157 try:
df6cb54604eb replay: use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
158 data, isexec, islink, copied = current.pop(current_file)
df6cb54604eb replay: use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
159 except IOError:
df6cb54604eb replay: use compat hack for filectxfn for deleted files
Siddharth Agarwal <sid0@fb.com>
parents: 1228
diff changeset
160 return compathacks.filectxfn_deleted_reraise(memctx)
943
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
161 if isexec is None or islink is None:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
162 flags = parentctx.flags(path)
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
163 if isexec is None:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
164 isexec = 'x' in flags
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
165 if islink is None:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
166 islink = 'l' in flags
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
167
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
168 if data is not None:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
169 if islink:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
170 if data.startswith('link '):
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
171 data = data[len('link '):]
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
172 else:
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
173 ui.debug('file marked as link, but may contain data: '
c49c3c418f9d editor: move RevisionData on the filesystem over a given threshold
Patrick Mezard <patrick@mezard.eu>
parents: 938
diff changeset
174 '%s\n' % current_file)
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
175 else:
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 444
diff changeset
176 data = parentctx.filectx(path).data()
1220
02f886e59ae6 replay: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
177 return compathacks.makememfilectx(repo,
1549
8410a978c650 compathacks: be compatible with upstream 8a0cac20a1ad memfilectx change
Jun Wu <quark@fb.com>
parents: 1527
diff changeset
178 memctx=memctx,
1220
02f886e59ae6 replay: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
179 path=path,
02f886e59ae6 replay: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
180 data=data,
02f886e59ae6 replay: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
181 islink=islink,
02f886e59ae6 replay: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
182 isexec=isexec,
02f886e59ae6 replay: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1103
diff changeset
183 copied=copied)
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
184
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 557
diff changeset
185 meta.mapbranch(extra)
1511
cb29f4bffcc7 replay: fix tests
Stanislau Hlebik <stash@fb.com>
parents: 1472
diff changeset
186 if 'branch' not in extra:
cb29f4bffcc7 replay: fix tests
Stanislau Hlebik <stash@fb.com>
parents: 1472
diff changeset
187 extra['branch'] = 'default'
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
188 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
189 parents,
1527
d03995e69785 meta: force user and message to be bytes
Augie Fackler <raf@durin42.com>
parents: 1526
diff changeset
190 util.forceutf8(meta.getmessage(rev)),
1526
5adfb81c4680 util: add method for forcing unicode objects back to utf8 bytes
Augie Fackler <raf@durin42.com>
parents: 1511
diff changeset
191 [util.forceutf8(f) for f in files.keys()],
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
192 filectxfn,
1527
d03995e69785 meta: force user and message to be bytes
Augie Fackler <raf@durin42.com>
parents: 1526
diff changeset
193 util.forceutf8(meta.authors[rev.author]),
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
194 date,
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
195 extra)
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
196
831
be5bbb2f2d68 svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents: 787
diff changeset
197 new_hash = meta.repo.svn_commitctx(current_ctx)
437
45ce07a4807f replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 436
diff changeset
198 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
199 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
200 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
201 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
202 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
203 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
204
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
205 # 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
206 for branch in current.emptybranches:
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
207
1356
57d65269d30c maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents: 1285
diff changeset
208 if meta.skipbranch(branch):
57d65269d30c maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents: 1285
diff changeset
209 continue
57d65269d30c maps: allow an empty map to not convert specific branches
Sean Farley <sean@farley.io>
parents: 1285
diff changeset
210
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
211 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
212 if ha == node.nullid:
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
213 continue
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
214
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
215 parent_ctx = meta.repo.changectx(ha)
1099
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1045
diff changeset
216 files = []
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
217 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
218 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
219
1099
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1045
diff changeset
220 # True here means nuke all files. This happens when you
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1045
diff changeset
221 # replace a branch root with an empty directory
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1045
diff changeset
222 if current.emptybranches[branch]:
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1045
diff changeset
223 files = meta.repo[ha].files()
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
224
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
225 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
226 meta.mapbranch(extra)
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
227
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
228 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
229 (ha, node.nullid),
1527
d03995e69785 meta: force user and message to be bytes
Augie Fackler <raf@durin42.com>
parents: 1526
diff changeset
230 util.forceutf8(meta.getmessage(rev)),
1526
5adfb81c4680 util: add method for forcing unicode objects back to utf8 bytes
Augie Fackler <raf@durin42.com>
parents: 1511
diff changeset
231 [util.forceutf8(f) for f in files],
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
232 del_all_files,
1527
d03995e69785 meta: force user and message to be bytes
Augie Fackler <raf@durin42.com>
parents: 1526
diff changeset
233 util.forceutf8(meta.authors[rev.author]),
435
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
234 date,
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
235 extra)
831
be5bbb2f2d68 svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents: 787
diff changeset
236 new_hash = meta.repo.svn_commitctx(current_ctx)
437
45ce07a4807f replay: merge functions into a single function
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 436
diff changeset
237 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
238 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
239 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
240
7c576ae19d80 replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
241 return closebranches