equal
deleted
inserted
replaced
13 import re |
13 import re |
14 |
14 |
15 from .i18n import _ |
15 from .i18n import _ |
16 from .node import ( |
16 from .node import ( |
17 hex, |
17 hex, |
18 nullid, |
|
19 nullrev, |
18 nullrev, |
20 short, |
19 short, |
21 ) |
20 ) |
22 from .pycompat import ( |
21 from .pycompat import ( |
23 getattr, |
22 getattr, |
1095 ignored (such as when 'update --check' runs). |
1094 ignored (such as when 'update --check' runs). |
1096 |
1095 |
1097 'hint' is the usual hint given to Abort exception. |
1096 'hint' is the usual hint given to Abort exception. |
1098 """ |
1097 """ |
1099 |
1098 |
1100 if merge and repo.dirstate.p2() != nullid: |
1099 if merge and repo.dirstate.p2() != repo.nullid: |
1101 raise error.StateError(_(b'outstanding uncommitted merge'), hint=hint) |
1100 raise error.StateError(_(b'outstanding uncommitted merge'), hint=hint) |
1102 st = repo.status() |
1101 st = repo.status() |
1103 if st.modified or st.added or st.removed or st.deleted: |
1102 if st.modified or st.added or st.removed or st.deleted: |
1104 raise error.StateError(_(b'uncommitted changes'), hint=hint) |
1103 raise error.StateError(_(b'uncommitted changes'), hint=hint) |
1105 ctx = repo[None] |
1104 ctx = repo[None] |
2102 parents.reverse() |
2101 parents.reverse() |
2103 |
2102 |
2104 if parents: |
2103 if parents: |
2105 prev = parents[0] |
2104 prev = parents[0] |
2106 else: |
2105 else: |
2107 prev = nullid |
2106 prev = repo.nullid |
2108 |
2107 |
2109 fm.context(ctx=ctx) |
2108 fm.context(ctx=ctx) |
2110 fm.plain(b'# HG changeset patch\n') |
2109 fm.plain(b'# HG changeset patch\n') |
2111 fm.write(b'user', b'# User %s\n', ctx.user()) |
2110 fm.write(b'user', b'# User %s\n', ctx.user()) |
2112 fm.plain(b'# Date %d %d\n' % ctx.date()) |
2111 fm.plain(b'# Date %d %d\n' % ctx.date()) |
2965 commitphase = phases.secret |
2964 commitphase = phases.secret |
2966 newid = repo.commitctx(new) |
2965 newid = repo.commitctx(new) |
2967 ms.reset() |
2966 ms.reset() |
2968 |
2967 |
2969 # Reroute the working copy parent to the new changeset |
2968 # Reroute the working copy parent to the new changeset |
2970 repo.setparents(newid, nullid) |
2969 repo.setparents(newid, repo.nullid) |
2971 |
2970 |
2972 # Fixing the dirstate because localrepo.commitctx does not update |
2971 # Fixing the dirstate because localrepo.commitctx does not update |
2973 # it. This is rather convenient because we did not need to update |
2972 # it. This is rather convenient because we did not need to update |
2974 # the dirstate for all the files in the new commit which commitctx |
2973 # the dirstate for all the files in the new commit which commitctx |
2975 # could have done if it updated the dirstate. Now, we can |
2974 # could have done if it updated the dirstate. Now, we can |
3320 # that purpose. |
3319 # that purpose. |
3321 dsadded = added |
3320 dsadded = added |
3322 |
3321 |
3323 # in case of merge, files that are actually added can be reported as |
3322 # in case of merge, files that are actually added can be reported as |
3324 # modified, we need to post process the result |
3323 # modified, we need to post process the result |
3325 if p2 != nullid: |
3324 if p2 != repo.nullid: |
3326 mergeadd = set(dsmodified) |
3325 mergeadd = set(dsmodified) |
3327 for path in dsmodified: |
3326 for path in dsmodified: |
3328 if path in mf: |
3327 if path in mf: |
3329 mergeadd.remove(path) |
3328 mergeadd.remove(path) |
3330 dsadded |= mergeadd |
3329 dsadded |= mergeadd |
3591 normal = None |
3590 normal = None |
3592 if node == parent: |
3591 if node == parent: |
3593 # We're reverting to our parent. If possible, we'd like status |
3592 # We're reverting to our parent. If possible, we'd like status |
3594 # to report the file as clean. We have to use normallookup for |
3593 # to report the file as clean. We have to use normallookup for |
3595 # merges to avoid losing information about merged/dirty files. |
3594 # merges to avoid losing information about merged/dirty files. |
3596 if p2 != nullid: |
3595 if p2 != repo.nullid: |
3597 normal = repo.dirstate.normallookup |
3596 normal = repo.dirstate.normallookup |
3598 else: |
3597 else: |
3599 normal = repo.dirstate.normal |
3598 normal = repo.dirstate.normal |
3600 |
3599 |
3601 newlyaddedandmodifiedfiles = set() |
3600 newlyaddedandmodifiedfiles = set() |
3688 prntstatusmsg(b'add', f) |
3687 prntstatusmsg(b'add', f) |
3689 checkout(f) |
3688 checkout(f) |
3690 repo.dirstate.add(f) |
3689 repo.dirstate.add(f) |
3691 |
3690 |
3692 normal = repo.dirstate.normallookup |
3691 normal = repo.dirstate.normallookup |
3693 if node == parent and p2 == nullid: |
3692 if node == parent and p2 == repo.nullid: |
3694 normal = repo.dirstate.normal |
3693 normal = repo.dirstate.normal |
3695 for f in actions[b'undelete'][0]: |
3694 for f in actions[b'undelete'][0]: |
3696 if interactive: |
3695 if interactive: |
3697 choice = repo.ui.promptchoice( |
3696 choice = repo.ui.promptchoice( |
3698 _(b"add back removed file %s (Yn)?$$ &Yes $$ &No") % f |
3697 _(b"add back removed file %s (Yn)?$$ &Yes $$ &No") % f |