diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1832,18 +1832,28 @@ def select(ui, repo, *args, **opts): def reposetup(ui, repo): class mqrepo(repo.__class__): + def abort_if_wdir_patched(self, errmsg, force=False): + if self.mq.applied and not force: + parent = revlog.hex(self.dirstate.parents()[0]) + if parent in [s.rev for s in self.mq.applied]: + raise util.Abort(errmsg) + def commit(self, *args, **opts): if len(args) >= 6: force = args[5] else: force = opts.get('force') - if self.mq.applied and not force: - parent = revlog.hex(self.dirstate.parents()[0]) - if parent in [s.rev for s in self.mq.applied]: - raise util.Abort(_('cannot commit over an applied mq patch')) + self.abort_if_wdir_patched( + _('cannot commit over an applied mq patch'), + force) return super(mqrepo, self).commit(*args, **opts) + def push(self, remote, force=False, revs=None): + if self.mq.applied and not force: + raise util.Abort(_('source has mq patches applied')) + return super(mqrepo, self).push(remote, force, revs) + def tags(self): if self.tagscache: return self.tagscache diff --git a/tests/test-mq b/tests/test-mq --- a/tests/test-mq +++ b/tests/test-mq @@ -10,6 +10,10 @@ hg help mq hg init a cd a echo a > a +hg ci -Ama + +hg clone . ../k + mkdir b echo z > b/z hg ci -Ama @@ -106,9 +110,16 @@ hg qapplied echo % commit should fail hg commit +echo % push should fail +hg push ../../k + echo % qunapplied hg qunapplied +echo % push should succeed +hg qpop -a +hg push ../../k + echo % strip cd ../../b echo x>x diff --git a/tests/test-mq.out b/tests/test-mq.out --- a/tests/test-mq.out +++ b/tests/test-mq.out @@ -49,6 +49,7 @@ list of commands (use "hg help -v mq" to qunapplied print the patches not yet applied strip strip a revision and all later revs on the same branch adding a +1 files updated, 0 files merged, 0 files removed, 0 files unresolved adding b/z % qinit % -R qinit @@ -104,6 +105,9 @@ Only one patch applied test.patch % commit should fail abort: cannot commit over an applied mq patch +% push should fail +pushing to ../../k +abort: source has mq patches applied % qunapplied test2.patch % strip