##// 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 return b"\n".join(edittext)
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 if opts is None:
3093 if opts is None:
3094 opts = {}
3094 opts = {}
3095 ctx = repo[node]
3095 ctx = repo[node]
3096 parents = ctx.parents()
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 not opts.get(b'amend')
3104 not opts.get(b'amend')
3100 and bheads
3105 and bheads
3101 and node not in bheads
3106 and node not in bheads
@@ -850,11 +850,14 b' def _dobackout(ui, repo, node=None, rev='
850 message, opts.get(b'user'), opts.get(b'date'), match, editor=e
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 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
856 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
854 if not newnode:
857 if not newnode:
855 ui.status(_(b"nothing changed\n"))
858 ui.status(_(b"nothing changed\n"))
856 return 1
859 return 1
857 cmdutil.commitstatus(repo, newnode, branch, bheads)
860 cmdutil.commitstatus(repo, newnode, branch, bheads, tip)
858
861
859 def nice(node):
862 def nice(node):
860 return b'%d:%s' % (repo.changelog.rev(node), short(node))
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 branch = repo[None].branch()
2026 branch = repo[None].branch()
2024 bheads = repo.branchheads(branch)
2027 bheads = repo.branchheads(branch)
2028 tip = repo.changelog.tip()
2025
2029
2026 extra = {}
2030 extra = {}
2027 if opts.get(b'close_branch') or opts.get(b'force_close_branch'):
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 ui.status(_(b"nothing changed\n"))
2115 ui.status(_(b"nothing changed\n"))
2112 return 1
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 if not ui.quiet and ui.configbool(b'commands', b'commit.post-status'):
2120 if not ui.quiet and ui.configbool(b'commands', b'commit.post-status'):
2117 status(
2121 status(
@@ -819,5 +819,5 b' Ensure that backout out the same changes'
819 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
819 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
820 $ hg backout 2
820 $ hg backout 2
821 removing 3
821 removing 3
822 created new head
822 warning: commit already existed in the repository!
823 changeset 3:8f188de730d9 backs out changeset 2:cccc23d9d68f
823 changeset 3:8f188de730d9 backs out changeset 2:cccc23d9d68f
@@ -1868,6 +1868,7 b' Verify naming of temporary files and tha'
1868 $ hg update -q -C 1
1868 $ hg update -q -C 1
1869 $ hg mv f f.txt
1869 $ hg mv f f.txt
1870 $ hg ci -qm "f.txt"
1870 $ hg ci -qm "f.txt"
1871 warning: commit already existed in the repository!
1871 $ hg update -q -C 2
1872 $ hg update -q -C 2
1872 $ hg merge -y -r tip --tool echo \
1873 $ hg merge -y -r tip --tool echo \
1873 > --config merge-tools.echo.args='$base $local $other $output' \
1874 > --config merge-tools.echo.args='$base $local $other $output' \
@@ -1010,7 +1010,7 b' draft:'
1010 $ hg up -C 1
1010 $ hg up -C 1
1011 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
1011 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
1012 $ mkcommit C
1012 $ mkcommit C
1013 created new head
1013 warning: commit already existed in the repository!
1014 $ hg phase -r 2
1014 $ hg phase -r 2
1015 2: public
1015 2: public
1016
1016
@@ -1027,6 +1027,7 b' Same, but for secret:'
1027 7: draft
1027 7: draft
1028 $ mkcommit F
1028 $ mkcommit F
1029 test-debug-phase: new rev 8: x -> 2
1029 test-debug-phase: new rev 8: x -> 2
1030 warning: commit already existed in the repository!
1030 test-hook-close-phase: de414268ec5ce2330c590b942fbb5ff0b0ca1a0a: -> secret
1031 test-hook-close-phase: de414268ec5ce2330c590b942fbb5ff0b0ca1a0a: -> secret
1031 $ hg phase -r tip
1032 $ hg phase -r tip
1032 8: secret
1033 8: secret
@@ -1037,7 +1038,7 b' But what about obsoleted changesets?'
1037 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1038 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1038 $ mkcommit H
1039 $ mkcommit H
1039 test-debug-phase: new rev 5: x -> 2
1040 test-debug-phase: new rev 5: x -> 2
1040 created new head
1041 warning: commit already existed in the repository!
1041 test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: -> secret
1042 test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: -> secret
1042 $ hg phase -r 5
1043 $ hg phase -r 5
1043 5: secret
1044 5: secret
@@ -204,5 +204,6 b''
204 $ hg update -r '.^' -q
204 $ hg update -r '.^' -q
205 $ echo 1 > A
205 $ echo 1 > A
206 $ hg commit -m foo -A A
206 $ hg commit -m foo -A A
207 warning: commit already existed in the repository!
207 $ hg log -r . -T '{node}\n'
208 $ hg log -r . -T '{node}\n'
208 383ce605500277f879b7460a16ba620eb6930b7f
209 383ce605500277f879b7460a16ba620eb6930b7f
@@ -405,8 +405,10 b' Rename a->b, then amend b->c, and workin'
405 $ hg co -q 0
405 $ hg co -q 0
406 $ hg mv a b
406 $ hg mv a b
407 $ hg ci -qm 'move to a b'
407 $ hg ci -qm 'move to a b'
408 warning: commit already existed in the repository!
408 $ hg mv b c
409 $ hg mv b c
409 $ hg amend
410 $ hg amend
411 warning: commit already existed in the repository!
410 $ hg mv c d
412 $ hg mv c d
411 $ hg unamend
413 $ hg unamend
412 $ hg st --copies --change .
414 $ hg st --copies --change .
General Comments 0
You need to be logged in to leave comments. Login now