changeset 14732:e9ed3506f066 stable

backout of d04ba50e104d: allow to qpop/push with a dirty working copy The new behavior was breaking existing tools that relied on a sequence such as this: 1) start with a dirty working copy 2) qimport some patch 3) try to qpush it 4) old behavior would fail at this point due to outstanding changes. (new behavior would only fail if the outstanding changes and the patches changes intersect) 5) innocent user qrefreshes, gets his local changes in the imported patch It's worth considering if we can move this behavior to -f in the future.
author Idan Kamara <idankk86@gmail.com>
date Fri, 24 Jun 2011 23:25:42 +0300
parents f5765353d430
children 130113308856 f924cf565f36 1688f20c95c3
files hgext/mq.py tests/test-mq-qpush-exact.t tests/test-mq.t
diffstat 3 files changed, 17 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Fri Jun 24 13:35:03 2011 -0500
+++ b/hgext/mq.py	Fri Jun 24 23:25:42 2011 +0300
@@ -1134,6 +1134,8 @@
             if start == len(self.series):
                 self.ui.warn(_('patch series already fully applied\n'))
                 return 1
+            if not force:
+                self.checklocalchanges(repo, refresh=self.applied)
 
             if exact:
                 if move:
@@ -1172,19 +1174,6 @@
                 end = self.series.index(patch, start) + 1
 
             s = self.series[start:end]
-
-            if not force:
-                mm, aa, rr, dd = repo.status()[:4]
-                wcfiles = set(mm + aa + rr + dd)
-                if wcfiles:
-                    for patchname in s:
-                        pf = os.path.join(self.path, patchname)
-                        patchfiles = patchmod.changedfiles(self.ui, repo, pf)
-                        if wcfiles.intersection(patchfiles):
-                            self.localchangesfound(self.applied)
-            elif mergeq:
-                self.checklocalchanges(refresh=self.applied)
-
             all_files = set()
             try:
                 if mergeq:
@@ -1265,6 +1254,9 @@
                         break
                 update = needupdate
 
+            if not force and update:
+                self.checklocalchanges(repo)
+
             self.applieddirty = 1
             end = len(self.applied)
             rev = self.applied[start].node
@@ -1287,12 +1279,6 @@
                 qp = self.qparents(repo, rev)
                 ctx = repo[qp]
                 m, a, r, d = repo.status(qp, top)[:4]
-                parentfiles = set(m + a + r + d)
-                if not force and parentfiles:
-                    mm, aa, rr, dd = repo.status()[:4]
-                    wcfiles = set(mm + aa + rr + dd)
-                    if wcfiles.intersection(parentfiles):
-                        self.localchangesfound()
                 if d:
                     raise util.Abort(_("deletions found between repo revs"))
                 for f in a:
--- a/tests/test-mq-qpush-exact.t	Fri Jun 24 13:35:03 2011 -0500
+++ b/tests/test-mq-qpush-exact.t	Fri Jun 24 23:25:42 2011 +0300
@@ -163,12 +163,8 @@
   $ hg update 1 -q
   $ echo c0 >> f0
   $ hg qpush -e
-  applying p0
-  now at: p0
-  $ cat f0
-  c0
-  $ hg qpop -aq
-  patch queue now empty
+  abort: local changes found
+  [255]
   $ hg qpush -ef
   applying p0
   now at: p0
@@ -182,13 +178,8 @@
   $ hg update 1 -q
   $ echo c0 >> f0
   $ hg qpush -e p1
-  applying p0
-  applying p1
-  now at: p1
-  $ cat f0
-  c0
-  $ hg qpop -aq
-  patch queue now empty
+  abort: local changes found
+  [255]
   $ hg qpush -e p1 -f
   applying p0
   applying p1
--- a/tests/test-mq.t	Fri Jun 24 13:35:03 2011 -0500
+++ b/tests/test-mq.t	Fri Jun 24 23:25:42 2011 +0300
@@ -1259,65 +1259,6 @@
   now at: changea
   $ cd ..
 
-test qpop with local changes, issue2780
-
-  $ hg init forcepop
-  $ cd forcepop
-  $ echo 1 > 1
-  $ hg ci -Am 1
-  adding 1
-  $ hg qnew foo
-  $ echo 2 > 2
-  $ hg add
-  adding 2
-
-unrelated changes
-
-  $ hg qpop
-  popping foo
-  patch queue now empty
-
-related changes
-
-  $ hg forget 2
-  $ rm 2
-  $ hg qpush
-  applying foo
-  patch foo is empty
-  now at: foo
-  $ echo 2 >> 1
-  $ hg qrefresh
-  $ echo 2 >> 1
-  $ hg qpop
-  abort: local changes found, refresh first
-  [255]
-  $ hg st
-  M 1
-
-related changes with force
-  $ hg qpop --force
-  popping foo
-  patch queue now empty
-  $ hg st
-
-related renamed source without change
-  $ hg qpush
-  applying foo
-  now at: foo
-  $ echo 1 > 1
-  $ hg mv 1 2
-  $ hg qref --git
-  $ hg qpop
-  popping foo
-  patch queue now empty
-  $ echo 3 > 1
-  $ hg st
-  M 1
-  $ hg qpush
-  abort: local changes found
-  [255]
-  $ cd ..
-
 test qpush with --force, issue1087
 
   $ hg init forcepush
@@ -1334,9 +1275,16 @@
   $ echo world >> hello.txt
 
 
-apply, should not discard changes with empty patch
+qpush should fail, local changes
 
   $ hg qpush
+  abort: local changes found
+  [255]
+
+
+apply force, should not discard changes with empty patch
+
+  $ hg qpush -f
   applying empty
   patch empty is empty
   now at: empty