# HG changeset patch # User Siddharth Agarwal # Date 2015-10-15 08:15:22 # Node ID c0aab596187643953016eba604b711e7984ab058 # Parent 50213e4d25bf25c55196f2f23fec60347e4e7897 commands.resolve: don't allow users to mark or unmark driver-resolved files Users will often be in the habit of running 'hg resolve --mark --all' after resolving merge conflicts in source files. We need to make sure this doesn't cause driver-resolved files to be marked. 'hg resolve --all' will resolve driver-resolved files, though. The weird conditional structure is to accommodate an upcoming patch. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5617,6 +5617,19 @@ def resolve(ui, repo, *pats, **opts): didwork = True + # don't let driver-resolved files be marked + if ms[f] == "d": + exact = m.exact(f) + if mark: + if exact: + ui.warn(_('not marking %s as it is driver-resolved\n') + % f) + elif unmark: + if exact: + ui.warn(_('not unmarking %s as it is driver-resolved\n') + % f) + continue + if mark: ms.mark(f, "r") elif unmark: diff --git a/tests/test-resolve.t b/tests/test-resolve.t --- a/tests/test-resolve.t +++ b/tests/test-resolve.t @@ -53,6 +53,58 @@ resolving an unknown path should emit a arguments do not match paths that need resolving $ hg resolve -l does-not-exist +don't allow marking or unmarking driver-resolved files + + $ cat > $TESTTMP/markdriver.py << EOF + > '''mark and unmark files as driver-resolved''' + > from mercurial import cmdutil, merge, scmutil + > cmdtable = {} + > command = cmdutil.command(cmdtable) + > @command('markdriver', + > [('u', 'unmark', None, '')], + > 'FILE...') + > def markdriver(ui, repo, *pats, **opts): + > wlock = repo.wlock() + > try: + > ms = merge.mergestate(repo) + > m = scmutil.match(repo[None], pats, opts) + > for f in ms: + > if not m(f): + > continue + > if not opts['unmark']: + > ms.mark(f, 'd') + > else: + > ms.mark(f, 'u') + > ms.commit() + > finally: + > wlock.release() + > EOF + $ hg --config extensions.markdriver=$TESTTMP/markdriver.py markdriver file1 + $ hg resolve --list + D file1 + U file2 + $ hg resolve --mark file1 + not marking file1 as it is driver-resolved +this should not print out file1 + $ hg resolve --mark --all + (no more unresolved files -- run "hg resolve --all" to conclude) + $ hg resolve --mark 'glob:file*' + (no more unresolved files -- run "hg resolve --all" to conclude) + $ hg resolve --list + D file1 + R file2 + $ hg resolve --unmark file1 + not unmarking file1 as it is driver-resolved + (no more unresolved files -- run "hg resolve --all" to conclude) + $ hg resolve --unmark --all + $ hg resolve --list + D file1 + U file2 + $ hg --config extensions.markdriver=$TESTTMP/markdriver.py markdriver --unmark file1 + $ hg resolve --list + U file1 + U file2 + resolve the failure $ echo resolved > file1