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

login
register
mail settings
Submitter phabricator
Date March 3, 2019, 7:24 p.m.
Message ID <differential-rev-PHID-DREV-iq4nfdxqjqocssyazkfh-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/39021/
State New
Headers show

Comments

phabricator - March 3, 2019, 7:24 p.m.
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




To: navaneeth.suresh, #hg-reviewers
Cc: mercurial-devel
phabricator - March 15, 2019, 1:39 p.m.
pulkit added inline comments.

INLINE COMMENTS

> test-mq-qrefresh.t:570
> +  new file mode 100644
> +  examine changes to 'foo.h'? [Ynesfdaq?] y
> +  

does this prompt ended here? it didn't show changes in 'foo.h'?

REPOSITORY
  rHG Mercurial

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

To: navaneeth.suresh, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - March 16, 2019, 8:57 a.m.
navaneeth.suresh added inline comments.

INLINE COMMENTS

> pulkit wrote in test-mq-qrefresh.t:570
> does this prompt ended here? it didn't show changes in 'foo.h'?

i think that's usual here as the file `foo.h` is empty. i have the following case running successfully with this patch:

  $ echo foo > 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
  
  @@ -0,0 +1,1 @@
  +foo
  record this change to 'foo.h'? [Ynesfdaq?] y

REPOSITORY
  rHG Mercurial

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

To: navaneeth.suresh, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - March 16, 2019, 11:01 p.m.
pulkit added inline comments.

INLINE COMMENTS

> navaneeth.suresh wrote in test-mq-qrefresh.t:570
> i think that's usual here as the file `foo.h` is empty. i have the following case running successfully with this patch:
> 
>   $ echo foo > 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
>   
>   @@ -0,0 +1,1 @@
>   +foo
>   record this change to 'foo.h'? [Ynesfdaq?] y

I don't see the output which asks for `record this change to foo.h`  here in the test.

REPOSITORY
  rHG Mercurial

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

To: navaneeth.suresh, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - March 17, 2019, 4:59 a.m.
navaneeth.suresh added inline comments.

INLINE COMMENTS

> pulkit wrote in test-mq-qrefresh.t:570
> I don't see the output which asks for `record this change to foo.h`  here in the test.

IIUC, the current scenario is running into `abort: cannot create foo.h: destination already exists` if an empty file has been added. This means that the test case in my previous comment works fine without running into an error. I tested with hg (version 4.9+3-b70b7c585ee9) by adding a file with contents by running one command after another in my command line and got the same output. The interactive UI prompted me with only two queries. For an empty file, it should be only one as there are no changes to record. This might be the case for `qrefresh`. I'm not sure about this though.

REPOSITORY
  rHG Mercurial

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

To: navaneeth.suresh, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - March 24, 2019, 6:08 p.m.
navaneeth.suresh added a comment.


  Gentle ping for review.

REPOSITORY
  rHG Mercurial

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

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

Patch

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 "