D6056: patch: stop aborting when ADD/RENAME/COPY files on --interactive (issue5727)

navaneeth.suresh (Navaneeth Suresh) phabricator at mercurial-scm.org
Sun Mar 3 14:24:35 EST 2019


navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  issue5727 was reported specifically for mq on using qrefresh. On investigating further,
  I realized that it was a check in `patch.py` that resulting in the abort. I may be wrong.
  On interactive mode, `gp.mode` was not `None`. I added a check in `_applydiff()` not to
  abort when `gp.mode` is `None` or `ui.interactive` is `True`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6056

AFFECTED FILES
  mercurial/patch.py
  tests/test-mq-qrefresh.t

CHANGE DETAILS

diff --git a/tests/test-mq-qrefresh.t b/tests/test-mq-qrefresh.t
--- a/tests/test-mq-qrefresh.t
+++ b/tests/test-mq-qrefresh.t
@@ -550,3 +550,22 @@
   2: secret
 
   $ cd ..
+
+Interactive qrefresh should not abort if files have been added
+
+  $ hg init issue5727
+  $ cd issue5727
+  $ echo '[extensions]' >> $HGRCPATH
+  $ echo 'record =' >> $HGRCPATH
+  $ hg qnew -m "BugId: 0 add foo.h" foo.diff
+  $ touch foo.h
+  $ hg add foo.h
+  $ hg qrefresh -i --config ui.interactive=true <<EOF
+  > y
+  > y
+  > n
+  > EOF
+  diff --git a/foo.h b/foo.h
+  new file mode 100644
+  examine changes to 'foo.h'? [Ynesfdaq?] y
+  
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2065,7 +2065,7 @@
                         # Added files without content have no hunk and
                         # must be created
                         data = ''
-                if data or mode:
+                if data or (mode and not ui.interactive()):
                     if (gp.op in ('ADD', 'RENAME', 'COPY')
                         and backend.exists(gp.path)):
                         raise PatchError(_("cannot create %s: destination "



To: navaneeth.suresh, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list