Mercurial > hgsubversion
annotate hgsubversion/replay.py @ 435:7c576ae19d80
replay: start new replay module that has the relevant functions
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Tue, 16 Jun 2009 08:43:12 +0200 |
parents | |
children | 404162e4bb53 |
rev | line source |
---|---|
435
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
1 import traceback |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
2 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
3 from mercurial import revlog |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
4 from mercurial import node |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
5 from mercurial import context |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
6 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
|
7 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
8 import svnexternals |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
9 import util |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
10 |
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 class MissingPlainTextError(Exception): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
13 """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
|
14 a txdelta. |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
15 """ |
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 class ReplayException(Exception): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
18 """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
|
19 exception. |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
20 """ |
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 def convert_rev(ui, meta, svn, r, tbdelta): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
23 # ui is only passed in for similarity with stupid.convert_rev() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
24 hg_editor = meta.editor |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
25 hg_editor.current.clear() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
26 hg_editor.current.rev = r |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
27 meta.save_tbdelta(tbdelta) # needed by get_replay() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
28 svn.get_replay(r.revnum, meta.editor) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
29 i = 1 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
30 if hg_editor.current.missing: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
31 meta.ui.debug('Fetching %s files that could not use replay.\n' % |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
32 len(hg_editor.current.missing)) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
33 files_to_grab = set() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
34 rootpath = svn.subdir and svn.subdir[1:] or '' |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
35 for p in hg_editor.current.missing: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
36 meta.ui.note('.') |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
37 meta.ui.flush() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
38 if p[-1] == '/': |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
39 dirpath = p[len(rootpath):] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
40 files_to_grab.update([dirpath + f for f,k in |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
41 svn.list_files(dirpath, r.revnum) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
42 if k == 'f']) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
43 else: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
44 files_to_grab.add(p[len(rootpath):]) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
45 meta.ui.note('\nFetching files...\n') |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
46 for p in files_to_grab: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
47 meta.ui.note('.') |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
48 meta.ui.flush() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
49 if i % 50 == 0: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
50 svn.init_ra_and_client() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
51 i += 1 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
52 data, mode = svn.get_file(p, r.revnum) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
53 hg_editor.current.set(p, data, 'x' in mode, 'l' in mode) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
54 hg_editor.current.missing = set() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
55 meta.ui.note('\n') |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
56 _updateexternals(meta, hg_editor.current) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
57 return commit_current_delta(meta, tbdelta, hg_editor.current) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
58 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
59 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
60 def _updateexternals(meta, current): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
61 if not current.externals: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
62 return |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
63 # Accumulate externals records for all branches |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
64 revnum = current.rev.revnum |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
65 branches = {} |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
66 for path, entry in current.externals.iteritems(): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
67 if not meta.is_path_valid(path): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
68 meta.ui.warn('WARNING: Invalid path %s in externals\n' % path) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
69 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
70 p, b, bp = meta.split_branch_path(path) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
71 if bp not in branches: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
72 external = svnexternals.externalsfile() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
73 parent = meta.get_parent_revision(revnum, b) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
74 pctx = meta.repo[parent] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
75 if '.hgsvnexternals' in pctx: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
76 external.read(pctx['.hgsvnexternals'].data()) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
77 branches[bp] = external |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
78 else: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
79 external = branches[bp] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
80 external[p] = entry |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
81 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
82 # Register the file changes |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
83 for bp, external in branches.iteritems(): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
84 path = bp + '/.hgsvnexternals' |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
85 if external: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
86 current.set(path, external.write(), False, False) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
87 else: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
88 current.delete(path) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
89 |
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 def commit_current_delta(meta, tbdelta, current): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
92 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
93 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
|
94 traceback.print_exception(*current.exception) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
95 raise ReplayException() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
96 if current.missing: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
97 raise MissingPlainTextError() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
98 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
99 # 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 # 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
|
105 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
|
106 files_to_commit.sort() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
107 branch_batches = {} |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
108 rev = current.rev |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
109 date = meta.fixdate(rev.date) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
110 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
111 # 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
|
112 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
|
113 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
|
114 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
115 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
|
116 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
|
117 branch_batches[b] = [] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
118 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
|
119 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
120 closebranches = {} |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
121 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
|
122 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
|
123 if len(branchedits) < 1: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
124 # 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
|
125 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
126 ha = branchedits[0][1] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
127 closebranches[branch] = ha |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
128 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
129 # 1. handle normal commits |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
130 closedrevs = closebranches.values() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
131 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
|
132 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
133 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
|
134 del current.emptybranches[branch] |
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 files = dict(files) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
137 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
|
138 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
|
139 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
140 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
141 extra = meta.genextra(rev.revnum, branch) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
142 if branch is not None: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
143 if (branch not in meta.branches |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
144 and branch not in meta.repo.branchtags()): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
145 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
146 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
147 parent_ctx = meta.repo.changectx(parents[0]) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
148 if '.hgsvnexternals' not in parent_ctx and '.hgsvnexternals' in files: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
149 # 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
|
150 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
|
151 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
|
152 del files['.hgsvnexternals'] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
153 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
154 def filectxfn(repo, memctx, path): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
155 current_file = files[path] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
156 if current_file in current.deleted: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
157 raise IOError() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
158 copied = current.copies.get(current_file) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
159 flags = parent_ctx.flags(path) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
160 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
|
161 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
|
162 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
|
163 data = current.files[current_file] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
164 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
|
165 data = data[len('link '):] |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
166 elif is_link: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
167 meta.ui.warn('file marked as link, but contains data: ' |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
168 '%s (%r)\n' % (current_file, flags)) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
169 else: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
170 data = parent_ctx.filectx(path).data() |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
171 return context.memfilectx(path=path, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
172 data=data, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
173 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
|
174 copied=copied) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
175 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
176 if not meta.usebranchnames: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
177 extra.pop('branch', None) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
178 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
|
179 parents, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
180 rev.message or '...', |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
181 files.keys(), |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
182 filectxfn, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
183 meta.authors[rev.author], |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
184 date, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
185 extra) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
186 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
187 new_hash = meta.repo.commitctx(current_ctx) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
188 util.describe_commit(meta.ui, new_hash, branch) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
189 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
|
190 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
|
191 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
192 # 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
|
193 for branch in current.emptybranches: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
194 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
195 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
|
196 if ha == node.nullid: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
197 continue |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
198 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
199 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
|
200 def del_all_files(*args): |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
201 raise IOError |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
202 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
203 # 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
|
204 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
|
205 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
|
206 'Please report this issue.') |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
207 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
208 extra = meta.genextra(rev.revnum, branch) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
209 if not meta.usebranchnames: |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
210 extra.pop('branch', None) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
211 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
212 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
|
213 (ha, node.nullid), |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
214 rev.message or ' ', |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
215 [], |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
216 del_all_files, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
217 meta.authors[rev.author], |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
218 date, |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
219 extra) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
220 new_hash = meta.repo.commitctx(current_ctx) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
221 util.describe_commit(meta.ui, new_hash, branch) |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
222 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
|
223 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
|
224 |
7c576ae19d80
replay: start new replay module that has the relevant functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff
changeset
|
225 return closebranches |