diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1157,7 +1157,7 @@ class queue(object): raise util.Abort(_("patch %s not in series") % patch) def push(self, repo, patch=None, force=False, list=False, - mergeq=None, all=False, move=False, exact=False): + mergeq=None, all=False, move=False, exact=False, nobackup=False): diffopts = self.diffopts() wlock = repo.wlock() try: @@ -1257,7 +1257,7 @@ class queue(object): end = self.series.index(patch, start) + 1 tobackup = set() - if force: + if not nobackup and force: m, a, r, d = self.checklocalchanges(repo, force=True) tobackup.update(m + a) @@ -1298,7 +1298,8 @@ class queue(object): finally: wlock.release() - def pop(self, repo, patch=None, force=False, update=True, all=False): + def pop(self, repo, patch=None, force=False, update=True, all=False, + nobackup=False): wlock = repo.wlock() try: if patch: @@ -1346,7 +1347,8 @@ class queue(object): tobackup = set() if update: m, a, r, d = self.checklocalchanges(repo, force=force) - tobackup.update(m + a) + if not nobackup and force: + tobackup.update(m + a) self.applieddirty = True end = len(self.applied) @@ -2496,7 +2498,8 @@ def fold(ui, repo, *files, **opts): wlock.release() @command("qgoto", - [('f', 'force', None, _('overwrite any local changes'))], + [('f', 'force', None, _('overwrite any local changes')), + ('', 'no-backup', None, _('do not save backup copies of files'))], _('hg qgoto [OPTION]... PATCH')) def goto(ui, repo, patch, **opts): '''push or pop patches until named patch is at top of stack @@ -2504,10 +2507,11 @@ def goto(ui, repo, patch, **opts): Returns 0 on success.''' q = repo.mq patch = q.lookup(patch) + nobackup = opts.get('no_backup') if q.isapplied(patch): - ret = q.pop(repo, patch, force=opts.get('force')) + ret = q.pop(repo, patch, force=opts.get('force'), nobackup=nobackup) else: - ret = q.push(repo, patch, force=opts.get('force')) + ret = q.push(repo, patch, force=opts.get('force'), nobackup=nobackup) q.savedirty() return ret @@ -2634,7 +2638,9 @@ def savename(path): ('m', 'merge', None, _('merge from another queue (DEPRECATED)')), ('n', 'name', '', _('merge queue name (DEPRECATED)'), _('NAME')), - ('', 'move', None, _('reorder patch series and apply only the patch'))], + ('', 'move', None, + _('reorder patch series and apply only the patch')), + ('', 'no-backup', None, _('do not save backup copies of files'))], _('hg qpush [-f] [-l] [-a] [--move] [PATCH | INDEX]')) def push(ui, repo, patch=None, **opts): """push the next patch onto the stack @@ -2659,14 +2665,15 @@ def push(ui, repo, patch=None, **opts): ui.warn(_("merging with queue at: %s\n") % mergeq.path) ret = q.push(repo, patch, force=opts.get('force'), list=opts.get('list'), mergeq=mergeq, all=opts.get('all'), move=opts.get('move'), - exact=opts.get('exact')) + exact=opts.get('exact'), nobackup=opts.get('no_backup')) return ret @command("^qpop", [('a', 'all', None, _('pop all patches')), ('n', 'name', '', _('queue name to pop (DEPRECATED)'), _('NAME')), - ('f', 'force', None, _('forget any local changes to patched files'))], + ('f', 'force', None, _('forget any local changes to patched files')), + ('', 'no-backup', None, _('do not save backup copies of files'))], _('hg qpop [-a] [-f] [PATCH | INDEX]')) def pop(ui, repo, patch=None, **opts): """pop the current patch off the stack @@ -2685,7 +2692,7 @@ def pop(ui, repo, patch=None, **opts): else: q = repo.mq ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate, - all=opts.get('all')) + all=opts.get('all'), nobackup=opts.get('no_backup')) q.savedirty() return ret diff --git a/tests/test-check-code-hg.t b/tests/test-check-code-hg.t --- a/tests/test-check-code-hg.t +++ b/tests/test-check-code-hg.t @@ -220,9 +220,6 @@ > raise util.Abort(_('qfold cannot fold already applied patch %s') % p) warning: line over 80 characters hgext/mq.py:0: - > ('', 'move', None, _('reorder patch series and apply only the patch'))], - warning: line over 80 characters - hgext/mq.py:0: > ('U', 'noupdate', None, _('do not update the new working directories')), warning: line over 80 characters hgext/mq.py:0: diff --git a/tests/test-mq-qpush-fail.t b/tests/test-mq-qpush-fail.t --- a/tests/test-mq-qpush-fail.t +++ b/tests/test-mq-qpush-fail.t @@ -189,6 +189,19 @@ test qpop --force and backup files $ cat c.orig cc +test qpop --force --no-backup + + $ hg qpush + applying p1 + now at: p1 + $ rm a.orig + $ echo a >> a + $ hg qpop --force --no-backup --verbose + popping p1 + patch queue now empty + $ test -f a.orig && echo 'error: backup with --no-backup' + [1] + test qpush --force and backup files $ echo a >> a @@ -237,3 +250,34 @@ test qpush --force and backup files b1 $ cat d.orig d1 + +test qpush --force --no-backup + + $ hg revert -qa + $ hg qpop -a + popping p3 + popping p2 + patch queue now empty + $ echo a >> a + $ rm a.orig + $ hg qpush --force --no-backup --verbose + applying p2 + patching file a + a + now at: p2 + $ test -f a.orig && echo 'error: backup with --no-backup' + [1] + +test qgoto --force --no-backup + + $ hg qpop + popping p2 + patch queue now empty + $ echo a >> a + $ hg qgoto --force --no-backup p2 --verbose + applying p2 + patching file a + a + now at: p2 + $ test -f a.orig && echo 'error: backup with --no-backup' + [1]