##// END OF EJS Templates
commit: warn the user when a commit already exists...
Dan Villiom Podlaski Christiansen -
r46392:103929c2 stable draft
parent child Browse files
Show More
@@ -3089,13 +3089,18 b' def buildcommittext(repo, ctx, subs, ext'
3089 3089 return b"\n".join(edittext)
3090 3090
3091 3091
3092 def commitstatus(repo, node, branch, bheads=None, opts=None):
3092 def commitstatus(repo, node, branch, bheads=None, tip=None, opts=None):
3093 3093 if opts is None:
3094 3094 opts = {}
3095 3095 ctx = repo[node]
3096 3096 parents = ctx.parents()
3097 3097
3098 if (
3098 if tip is not None and repo.changelog.tip() == tip:
3099 # avoid reporting something like "committed new head" when
3100 # recommitting old changesets, and issue a helpful warning
3101 # for most instances
3102 repo.ui.warn(_("warning: commit already existed in the repository!\n"))
3103 elif (
3099 3104 not opts.get(b'amend')
3100 3105 and bheads
3101 3106 and node not in bheads
@@ -850,11 +850,14 b' def _dobackout(ui, repo, node=None, rev='
850 850 message, opts.get(b'user'), opts.get(b'date'), match, editor=e
851 851 )
852 852
853 # save to detect changes
854 tip = repo.changelog.tip()
855
853 856 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
854 857 if not newnode:
855 858 ui.status(_(b"nothing changed\n"))
856 859 return 1
857 cmdutil.commitstatus(repo, newnode, branch, bheads)
860 cmdutil.commitstatus(repo, newnode, branch, bheads, tip)
858 861
859 862 def nice(node):
860 863 return b'%d:%s' % (repo.changelog.rev(node), short(node))
@@ -2022,6 +2025,7 b' def _docommit(ui, repo, *pats, **opts):'
2022 2025
2023 2026 branch = repo[None].branch()
2024 2027 bheads = repo.branchheads(branch)
2028 tip = repo.changelog.tip()
2025 2029
2026 2030 extra = {}
2027 2031 if opts.get(b'close_branch') or opts.get(b'force_close_branch'):
@@ -2111,7 +2115,7 b' def _docommit(ui, repo, *pats, **opts):'
2111 2115 ui.status(_(b"nothing changed\n"))
2112 2116 return 1
2113 2117
2114 cmdutil.commitstatus(repo, node, branch, bheads, opts)
2118 cmdutil.commitstatus(repo, node, branch, bheads, tip, opts)
2115 2119
2116 2120 if not ui.quiet and ui.configbool(b'commands', b'commit.post-status'):
2117 2121 status(
@@ -819,5 +819,5 b' Ensure that backout out the same changes'
819 819 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
820 820 $ hg backout 2
821 821 removing 3
822 created new head
822 warning: commit already existed in the repository!
823 823 changeset 3:8f188de730d9 backs out changeset 2:cccc23d9d68f
@@ -1868,6 +1868,7 b' Verify naming of temporary files and tha'
1868 1868 $ hg update -q -C 1
1869 1869 $ hg mv f f.txt
1870 1870 $ hg ci -qm "f.txt"
1871 warning: commit already existed in the repository!
1871 1872 $ hg update -q -C 2
1872 1873 $ hg merge -y -r tip --tool echo \
1873 1874 > --config merge-tools.echo.args='$base $local $other $output' \
@@ -1010,7 +1010,7 b' draft:'
1010 1010 $ hg up -C 1
1011 1011 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
1012 1012 $ mkcommit C
1013 created new head
1013 warning: commit already existed in the repository!
1014 1014 $ hg phase -r 2
1015 1015 2: public
1016 1016
@@ -1027,6 +1027,7 b' Same, but for secret:'
1027 1027 7: draft
1028 1028 $ mkcommit F
1029 1029 test-debug-phase: new rev 8: x -> 2
1030 warning: commit already existed in the repository!
1030 1031 test-hook-close-phase: de414268ec5ce2330c590b942fbb5ff0b0ca1a0a: -> secret
1031 1032 $ hg phase -r tip
1032 1033 8: secret
@@ -1037,7 +1038,7 b' But what about obsoleted changesets?'
1037 1038 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1038 1039 $ mkcommit H
1039 1040 test-debug-phase: new rev 5: x -> 2
1040 created new head
1041 warning: commit already existed in the repository!
1041 1042 test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: -> secret
1042 1043 $ hg phase -r 5
1043 1044 5: secret
@@ -204,5 +204,6 b''
204 204 $ hg update -r '.^' -q
205 205 $ echo 1 > A
206 206 $ hg commit -m foo -A A
207 warning: commit already existed in the repository!
207 208 $ hg log -r . -T '{node}\n'
208 209 383ce605500277f879b7460a16ba620eb6930b7f
@@ -405,8 +405,10 b' Rename a->b, then amend b->c, and workin'
405 405 $ hg co -q 0
406 406 $ hg mv a b
407 407 $ hg ci -qm 'move to a b'
408 warning: commit already existed in the repository!
408 409 $ hg mv b c
409 410 $ hg amend
411 warning: commit already existed in the repository!
410 412 $ hg mv c d
411 413 $ hg unamend
412 414 $ hg st --copies --change .
General Comments 0
You need to be logged in to leave comments. Login now