# HG changeset patch # User Idan Kamara # Date 2011-06-24 20:25:42 # Node ID e9ed3506f066fe5ca88db31fbdea76e0244a9d7f # Parent f5765353d4300a879ec44590ee658cd78736053c 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. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1134,6 +1134,8 @@ class queue(object): 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 @@ class queue(object): 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 @@ class queue(object): 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 @@ class queue(object): 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: diff --git a/tests/test-mq-qpush-exact.t b/tests/test-mq-qpush-exact.t --- a/tests/test-mq-qpush-exact.t +++ b/tests/test-mq-qpush-exact.t @@ -163,12 +163,8 @@ qpush --exact --force with changes to an $ 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 @@ qpush --exact --force with changes to an $ 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 diff --git a/tests/test-mq.t b/tests/test-mq.t --- a/tests/test-mq.t +++ b/tests/test-mq.t @@ -1259,65 +1259,6 @@ Issue1033: test applying on an empty fil 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 @@ test qpush with --force, issue1087 $ 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