Patchwork [6,of,6] resolve: print message when no unresolved files remain (issue4214)

login
register
mail settings
Submitter Gregory Szorc
Date May 9, 2014, 1:46 a.m.
Message ID <f5ae4abe75a986e3d55b.1399599984@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4695/
State Accepted
Headers show

Comments

Gregory Szorc - May 9, 2014, 1:46 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397884765 25200
#      Fri Apr 18 22:19:25 2014 -0700
# Node ID f5ae4abe75a986e3d55bffd60673a3edc9d0e71d
# Parent  e2544ef43ea835a292df8544f5411fec8fff5a28
resolve: print message when no unresolved files remain (issue4214)

When using resolve, users often have to consult with the output of |hg
resolve -l| to see if any unresolved files remain. This step is tedious
and adds overhead to resolving.

This patch will notify a user if there are no unresolved files remaining
after executing |hg resolve|.

The patch stops short of telling the user exactly what command should be
executed to continue the unfinished operation. That is because this
information is not currently captured anywhere. This would make a
compelling follow-up feature.
Pierre-Yves David - May 9, 2014, 2:14 a.m.
On 05/08/2014 06:46 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1397884765 25200
> #      Fri Apr 18 22:19:25 2014 -0700
> # Node ID f5ae4abe75a986e3d55bffd60673a3edc9d0e71d
> # Parent  e2544ef43ea835a292df8544f5411fec8fff5a28
> resolve: print message when no unresolved files remain (issue4214)
>
> When using resolve, users often have to consult with the output of |hg
> resolve -l| to see if any unresolved files remain. This step is tedious
> and adds overhead to resolving.
>
> This patch will notify a user if there are no unresolved files remaining
> after executing |hg resolve|.
>
> The patch stops short of telling the user exactly what command should be
> executed to continue the unfinished operation. That is because this
> information is not currently captured anywhere. This would make a
> compelling follow-up feature.

Note that we usually try to included message example in changeset 
description.

I love this. Not super fan of the message either, but I'll let other 
bikeshed it.


I've queued this series to the clowncopter repo. I expect message fixup 
in follow up patches.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4976,8 +4976,15 @@  def resolve(ui, repo, *pats, **opts):
 
     if not didwork and pats:
         ui.warn(_("arguments do not match paths that need resolved\n"))
 
+    # Nudge users into finishing an unfinished operation. We don't print
+    # this with the list/show operation because we want list/show to remain
+    # machine readable.
+    if not list(ms.unresolved()) and not show:
+        ui.write(_('no unresolved files; '))
+        ui.write(_('you may continue your unfinished operation\n'))
+
     return ret
 
 @command('revert',
     [('a', 'all', None, _('revert all changes when no arguments given')),
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -260,8 +260,15 @@  class mergestate(object):
     def mark(self, dfile, state):
         self._state[dfile][0] = state
         self._dirty = True
 
+    def unresolved(self):
+        """Obtain the paths of unresolved files."""
+
+        for f, entry in self._state.items():
+            if entry[0] == 'u':
+                yield f
+
     def resolve(self, dfile, wctx):
         """rerun merge process for file path `dfile`"""
         if self[dfile] == 'r':
             return 0
diff --git a/tests/test-add.t b/tests/test-add.t
--- a/tests/test-add.t
+++ b/tests/test-add.t
@@ -106,8 +106,9 @@  should fail
   $ hg st
   M a
   ? a.orig
   $ hg resolve -m a
+  no unresolved files; you may continue your unfinished operation
   $ hg ci -m merge
 
 Issue683: peculiarity with hg revert of an removed then added file
 
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -489,8 +489,9 @@  Test usage of `hg resolve` in case of co
   picked tool 'internal:merge' for foo (binary False symlink False)
   merging foo
   my foo@b71750c4b0fd+ other foo@a30dd8addae3 ancestor foo@913609522437
    premerge successful
+  no unresolved files; you may continue your unfinished operation
   $ hg status
   M foo
   ? foo.orig
   $ hg resolve -l
diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -585,8 +585,9 @@  Amend a merge changeset (with renames an
   warning: conflicts during merge.
   merging cc incomplete! (edit conflicts, then use 'hg resolve --mark')
   [1]
   $ hg resolve -m cc
+  no unresolved files; you may continue your unfinished operation
   $ hg ci -m 'merge bar'
   $ hg log --config diff.git=1 -pr .
   changeset:   23:d51446492733
   tag:         tip
diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t
--- a/tests/test-commit-unresolved.t
+++ b/tests/test-commit-unresolved.t
@@ -40,7 +40,8 @@  Correct the conflict without marking the
 
 Mark the conflict as resolved and commit
 
   $ hg resolve -m A
+  no unresolved files; you may continue your unfinished operation
   $ hg commit -m "Merged"
 
   $ cd ..
diff --git a/tests/test-convert-svn-sink.t b/tests/test-convert-svn-sink.t
--- a/tests/test-convert-svn-sink.t
+++ b/tests/test-convert-svn-sink.t
@@ -351,8 +351,9 @@  Branchy history
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
   $ hg --cwd b revert -r 2 b
   $ hg --cwd b resolve -m b
+  no unresolved files; you may continue your unfinished operation
   $ hg --cwd b ci -d '5 0' -m 'merge'
 
 Expect 4 changes
 
diff --git a/tests/test-fileset.t b/tests/test-fileset.t
--- a/tests/test-fileset.t
+++ b/tests/test-fileset.t
@@ -153,8 +153,9 @@  Test merge states
   $ fileset 'unresolved()'
   b2
   $ echo e > b2
   $ hg resolve -m b2
+  no unresolved files; you may continue your unfinished operation
   $ fileset 'resolved()'
   b2
   $ fileset 'unresolved()'
   $ hg ci -m merge
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -219,8 +219,9 @@  Continue without resolve should fail:
 Fix up:
 
   $ echo b > e
   $ hg resolve -m e
+  no unresolved files; you may continue your unfinished operation
 
 Continue with a revision should fail:
 
   $ hg graft -c 6
@@ -353,8 +354,9 @@  Resolve conflicted graft
   (use hg resolve and hg graft --continue)
   [255]
   $ hg resolve --all
   merging a
+  no unresolved files; you may continue your unfinished operation
   $ hg graft -c
   grafting revision 1
   $ hg export tip --git
   # HG changeset patch
@@ -381,8 +383,9 @@  Resolve conflicted graft with rename
   (use hg resolve and hg graft --continue)
   [255]
   $ hg resolve --all
   merging a and b to b
+  no unresolved files; you may continue your unfinished operation
   $ hg graft -c
   grafting revision 2
   $ hg export tip --git
   # HG changeset patch
diff --git a/tests/test-histedit-fold-non-commute.t b/tests/test-histedit-fold-non-commute.t
--- a/tests/test-histedit-fold-non-commute.t
+++ b/tests/test-histedit-fold-non-commute.t
@@ -94,8 +94,9 @@  edit the history
 
 fix up
   $ echo 'I can haz no commute' > e
   $ hg resolve --mark e
+  no unresolved files; you may continue your unfinished operation
   $ cat > cat.py <<EOF
   > import sys
   > print open(sys.argv[1]).read()
   > print
@@ -128,8 +129,9 @@  fix up
 
 just continue this time
   $ hg revert -r 'p1()' e
   $ hg resolve --mark e
+  no unresolved files; you may continue your unfinished operation
   $ hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -216,8 +216,9 @@  should effectively drop the changes from
   $ hg resolve -l
   U file
   $ hg revert -r 'p1()' file
   $ hg resolve --mark file
+  no unresolved files; you may continue your unfinished operation
   $ hg histedit --continue
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/*-backup.hg (glob)
   $ hg logt --graph
@@ -275,8 +276,9 @@  dropped revision.
   > 4
   > 5
   > EOF
   $ hg resolve --mark file
+  no unresolved files; you may continue your unfinished operation
   $ hg commit -m '+5.2'
   created new head
   $ echo 6 >> file
   $ HGEDITOR=cat hg histedit --continue
diff --git a/tests/test-histedit-non-commute.t b/tests/test-histedit-non-commute.t
--- a/tests/test-histedit-non-commute.t
+++ b/tests/test-histedit-non-commute.t
@@ -153,8 +153,9 @@  edit the history
 
 fix up
   $ echo 'I can haz no commute' > e
   $ hg resolve --mark e
+  no unresolved files; you may continue your unfinished operation
   $ hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts during merge.
@@ -166,8 +167,9 @@  former children.
 
 just continue this time
   $ hg revert -r 'p1()' e
   $ hg resolve --mark e
+  no unresolved files; you may continue your unfinished operation
   $ hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
@@ -238,8 +240,9 @@  edit the history, this time with a fold 
   Fix up the change and run hg histedit --continue
 
   $ echo 'I can haz no commute' > e
   $ hg resolve --mark e
+  no unresolved files; you may continue your unfinished operation
   $ hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging e
   warning: conflicts during merge.
@@ -247,8 +250,9 @@  edit the history, this time with a fold 
   Fix up the change and run hg histedit --continue
 second edit also fails, but just continue
   $ hg revert -r 'p1()' e
   $ hg resolve --mark e
+  no unresolved files; you may continue your unfinished operation
   $ hg histedit --continue 2>&1 | fixbundle
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -1057,8 +1057,9 @@  conflict: keyword should stay outside co
 
 resolve to local
 
   $ HGMERGE=internal:local hg resolve -a
+  no unresolved files; you may continue your unfinished operation
   $ hg commit -m localresolve
   $ cat m
   $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
   bar
diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t
--- a/tests/test-lfconvert.t
+++ b/tests/test-lfconvert.t
@@ -131,8 +131,9 @@  add some changesets to rename/remove/mer
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
   $ hg cat -r . sub/maybelarge.dat > stuff/maybelarge.dat
   $ hg resolve -m stuff/maybelarge.dat
+  no unresolved files; you may continue your unfinished operation
   $ hg commit -m"merge"
   $ hg log -G --template "{rev}:{node|short}  {desc|firstline}\n"
   @    5:4884f215abda  merge
   |\
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -989,8 +989,9 @@  log -p -R repo
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
   $ echo 'merge 1' > foo
   $ hg resolve -m foo
+  no unresolved files; you may continue your unfinished operation
   $ hg ci -m "First merge, related"
 
   $ hg merge 4
   merging foo
@@ -1000,8 +1001,9 @@  log -p -R repo
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
   $ echo 'merge 2' > foo
   $ hg resolve -m foo
+  no unresolved files; you may continue your unfinished operation
   $ hg ci -m "Last merge, related"
 
   $ hg log --graph
   @    changeset:   10:4dae8563d2c5
diff --git a/tests/test-merge-types.t b/tests/test-merge-types.t
--- a/tests/test-merge-types.t
+++ b/tests/test-merge-types.t
@@ -49,8 +49,9 @@  Symlink is local parent, executable is o
   $ tellmeabout a
   a is a symlink:
   a -> symlink
   $ hg resolve a --tool internal:other
+  no unresolved files; you may continue your unfinished operation
   $ tellmeabout a
   a is an executable file with content:
   a
   $ hg st
diff --git a/tests/test-merge7.t b/tests/test-merge7.t
--- a/tests/test-merge7.t
+++ b/tests/test-merge7.t
@@ -56,8 +56,9 @@  resolve conflict
   > three
   > EOF
   $ rm -f *.orig
   $ hg resolve -m test.txt
+  no unresolved files; you may continue your unfinished operation
   $ hg commit -m "Merge 1"
 
 change test-a again
   $ cd ../test-a
diff --git a/tests/test-mq-qnew.t b/tests/test-mq-qnew.t
--- a/tests/test-mq-qnew.t
+++ b/tests/test-mq-qnew.t
@@ -157,8 +157,9 @@  plain headers
   warning: conflicts during merge.
   merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
+  no unresolved files; you may continue your unfinished operation
   abort: cannot manage merge changesets
   $ rm -r sandbox
 
 hg headers
@@ -230,8 +231,9 @@  hg headers
   warning: conflicts during merge.
   merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
+  no unresolved files; you may continue your unfinished operation
   abort: cannot manage merge changesets
   $ rm -r sandbox
 
 Test saving last-message.txt
diff --git a/tests/test-rebase-bookmarks.t b/tests/test-rebase-bookmarks.t
--- a/tests/test-rebase-bookmarks.t
+++ b/tests/test-rebase-bookmarks.t
@@ -167,8 +167,9 @@  rebase --continue with bookmarks present
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
   $ echo 'c' > c
   $ hg resolve --mark c
+  no unresolved files; you may continue your unfinished operation
   $ hg rebase --continue
   saved backup bundle to $TESTTMP/a3/.hg/strip-backup/3d5fa227f4b5-backup.hg (glob)
   $ hg tglog
   @  4: 'C' bookmarks: Y Z
diff --git a/tests/test-rebase-check-restore.t b/tests/test-rebase-check-restore.t
--- a/tests/test-rebase-check-restore.t
+++ b/tests/test-rebase-check-restore.t
@@ -75,8 +75,9 @@  Solve the conflict and go on:
 
   $ echo 'conflict solved' > A
   $ rm A.orig
   $ hg resolve -m A
+  no unresolved files; you may continue your unfinished operation
   $ hg rebase --continue
 
   $ hg tglog
   o  7:secret 'C'
@@ -128,8 +129,9 @@  Solve the conflict and go on:
 
   $ echo 'conflict solved' > A
   $ rm A.orig
   $ hg resolve -m A
+  no unresolved files; you may continue your unfinished operation
   $ hg rebase --continue
   saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -76,8 +76,9 @@  Try to continue without solving the conf
 Conclude rebase:
 
   $ echo 'resolved merge' >common
   $ hg resolve -m common
+  no unresolved files; you may continue your unfinished operation
   $ hg rebase --continue
   saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
diff --git a/tests/test-rebase-detach.t b/tests/test-rebase-detach.t
--- a/tests/test-rebase-detach.t
+++ b/tests/test-rebase-detach.t
@@ -373,8 +373,9 @@  Ensure --continue restores a correct sta
   merging H incomplete! (edit conflicts, then use 'hg resolve --mark')
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
   $ hg resolve --all -t internal:local
+  no unresolved files; you may continue your unfinished operation
   $ hg rebase -c
   saved backup bundle to $TESTTMP/a7/.hg/strip-backup/6215fafa5447-backup.hg (glob)
   $ hg  log -G --template "{rev}:{phase} '{desc}' {branches}\n"
   @  7:draft 'H'
diff --git a/tests/test-rebase-interruptions.t b/tests/test-rebase-interruptions.t
--- a/tests/test-rebase-interruptions.t
+++ b/tests/test-rebase-interruptions.t
@@ -103,8 +103,9 @@  Solve the conflict and go on:
 
   $ echo 'conflict solved' > A
   $ rm A.orig
   $ hg resolve -m A
+  no unresolved files; you may continue your unfinished operation
 
   $ hg rebase --continue
   warning: new changesets detected on source branch, not stripping
 
diff --git a/tests/test-rebase-mq-skip.t b/tests/test-rebase-mq-skip.t
--- a/tests/test-rebase-mq-skip.t
+++ b/tests/test-rebase-mq-skip.t
@@ -110,8 +110,9 @@  already has one local mq patch
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
 
   $ HGMERGE=internal:local hg resolve --all
+  no unresolved files; you may continue your unfinished operation
 
   $ hg rebase --continue
   saved backup bundle to $TESTTMP/b/.hg/strip-backup/*-backup.hg (glob)
 
diff --git a/tests/test-rebase-mq.t b/tests/test-rebase-mq.t
--- a/tests/test-rebase-mq.t
+++ b/tests/test-rebase-mq.t
@@ -68,8 +68,9 @@  Rebase - generate a conflict:
 Fix the 1st conflict:
 
   $ echo mq1r1 > f
   $ hg resolve -m f
+  no unresolved files; you may continue your unfinished operation
   $ hg rebase -c
   merging f
   warning: conflicts during merge.
   merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
@@ -79,8 +80,9 @@  Fix the 1st conflict:
 Fix the 2nd conflict:
 
   $ echo mq1r1mq2 > f
   $ hg resolve -m f
+  no unresolved files; you may continue your unfinished operation
   $ hg rebase -c
   saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t
--- a/tests/test-rebase-parameters.t
+++ b/tests/test-rebase-parameters.t
@@ -453,8 +453,9 @@  Test --tool parameter:
   $ hg resolve -l
   U c2
 
   $ hg resolve -m c2
+  no unresolved files; you may continue your unfinished operation
   $ hg rebase -c --tool internal:fail
   tool option will be ignored
   saved backup bundle to $TESTTMP/b3/.hg/strip-backup/*-backup.hg (glob)
 
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -38,8 +38,9 @@  resolving an unknown path emits a warnin
 resolve the failure
 
   $ echo resolved > file
   $ hg resolve -m file
+  no unresolved files; you may continue your unfinished operation
   $ hg commit -m 'resolved'
 
 resolve -l should error since no merge in progress
 
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -293,8 +293,9 @@  attempt to continue
   [255]
 
   $ hg revert -r . a/a
   $ hg resolve -m a/a
+  no unresolved files; you may continue your unfinished operation
 
   $ hg commit -m 'commit while unshelve in progress'
   abort: unshelve already in progress
   (use 'hg unshelve --continue' or 'hg unshelve --abort')