62 |
62 |
63 p1, p2 = ctx.p1(), ctx.p2() |
63 p1, p2 = ctx.p1(), ctx.p2() |
64 user = ctx.user() |
64 user = ctx.user() |
65 |
65 |
66 with repo.lock(), repo.transaction(b"commit") as tr: |
66 with repo.lock(), repo.transaction(b"commit") as tr: |
67 writechangesetcopy, writefilecopymeta = _write_copy_meta(repo) |
67 r = _prepare_files(tr, ctx, error=error, origctx=origctx) |
68 |
68 mn, files, p1copies, p2copies, filesadded, filesremoved = r |
69 p1copies, p2copies = None, None |
|
70 if writechangesetcopy: |
|
71 p1copies = ctx.p1copies() |
|
72 p2copies = ctx.p2copies() |
|
73 filesadded, filesremoved = None, None |
|
74 if ctx.manifestnode(): |
|
75 # reuse an existing manifest revision |
|
76 repo.ui.debug(b'reusing known manifest\n') |
|
77 mn = ctx.manifestnode() |
|
78 files = ctx.files() |
|
79 if writechangesetcopy: |
|
80 filesadded = ctx.filesadded() |
|
81 filesremoved = ctx.filesremoved() |
|
82 elif not ctx.files(): |
|
83 repo.ui.debug(b'reusing manifest from p1 (no file change)\n') |
|
84 mn = p1.manifestnode() |
|
85 files = [] |
|
86 else: |
|
87 mn, files, added, removed = _process_files(tr, ctx, error=error) |
|
88 if writechangesetcopy: |
|
89 filesremoved = removed |
|
90 filesadded = added |
|
91 |
|
92 if origctx and origctx.manifestnode() == mn: |
|
93 files = origctx.files() |
|
94 |
|
95 if not writefilecopymeta: |
|
96 # If writing only to changeset extras, use None to indicate that |
|
97 # no entry should be written. If writing to both, write an empty |
|
98 # entry to prevent the reader from falling back to reading |
|
99 # filelogs. |
|
100 p1copies = p1copies or None |
|
101 p2copies = p2copies or None |
|
102 filesadded = filesadded or None |
|
103 filesremoved = filesremoved or None |
|
104 |
69 |
105 # update changelog |
70 # update changelog |
106 repo.ui.note(_(b"committing changelog\n")) |
71 repo.ui.note(_(b"committing changelog\n")) |
107 repo.changelog.delayupdate(tr) |
72 repo.changelog.delayupdate(tr) |
108 n = repo.changelog.add( |
73 n = repo.changelog.add( |
132 # be compliant anyway |
97 # be compliant anyway |
133 # |
98 # |
134 # if minimal phase was 0 we don't need to retract anything |
99 # if minimal phase was 0 we don't need to retract anything |
135 phases.registernew(repo, tr, targetphase, [n]) |
100 phases.registernew(repo, tr, targetphase, [n]) |
136 return n |
101 return n |
|
102 |
|
103 |
|
104 def _prepare_files(tr, ctx, error=False, origctx=None): |
|
105 repo = ctx.repo() |
|
106 p1 = ctx.p1() |
|
107 |
|
108 writechangesetcopy, writefilecopymeta = _write_copy_meta(repo) |
|
109 |
|
110 p1copies, p2copies = None, None |
|
111 if writechangesetcopy: |
|
112 p1copies = ctx.p1copies() |
|
113 p2copies = ctx.p2copies() |
|
114 filesadded, filesremoved = None, None |
|
115 if ctx.manifestnode(): |
|
116 # reuse an existing manifest revision |
|
117 repo.ui.debug(b'reusing known manifest\n') |
|
118 mn = ctx.manifestnode() |
|
119 files = ctx.files() |
|
120 if writechangesetcopy: |
|
121 filesadded = ctx.filesadded() |
|
122 filesremoved = ctx.filesremoved() |
|
123 elif not ctx.files(): |
|
124 repo.ui.debug(b'reusing manifest from p1 (no file change)\n') |
|
125 mn = p1.manifestnode() |
|
126 files = [] |
|
127 else: |
|
128 mn, files, added, removed = _process_files(tr, ctx, error=error) |
|
129 if writechangesetcopy: |
|
130 filesremoved = removed |
|
131 filesadded = added |
|
132 |
|
133 if origctx and origctx.manifestnode() == mn: |
|
134 files = origctx.files() |
|
135 |
|
136 if not writefilecopymeta: |
|
137 # If writing only to changeset extras, use None to indicate that |
|
138 # no entry should be written. If writing to both, write an empty |
|
139 # entry to prevent the reader from falling back to reading |
|
140 # filelogs. |
|
141 p1copies = p1copies or None |
|
142 p2copies = p2copies or None |
|
143 filesadded = filesadded or None |
|
144 filesremoved = filesremoved or None |
|
145 |
|
146 return mn, files, p1copies, p2copies, filesadded, filesremoved |
137 |
147 |
138 |
148 |
139 def _process_files(tr, ctx, error=False): |
149 def _process_files(tr, ctx, error=False): |
140 repo = ctx.repo() |
150 repo = ctx.repo() |
141 p1 = ctx.p1() |
151 p1 = ctx.p1() |