Mercurial > hg-stable
changeset 16635:9d76320d8b99 stable
mq: add --no-backup for qpush/qpop/qgoto
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Fri, 11 May 2012 16:57:26 +0200 |
parents | 435375cc0ca0 |
children | b371056ae353 |
files | hgext/mq.py tests/test-check-code-hg.t tests/test-mq-qpush-fail.t |
diffstat | 3 files changed, 62 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Fri May 11 16:18:47 2012 +0200 +++ b/hgext/mq.py Fri May 11 16:57:26 2012 +0200 @@ -1157,7 +1157,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ ('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 @@ 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 @@ 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
--- a/tests/test-check-code-hg.t Fri May 11 16:18:47 2012 +0200 +++ b/tests/test-check-code-hg.t Fri May 11 16:57:26 2012 +0200 @@ -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:
--- a/tests/test-mq-qpush-fail.t Fri May 11 16:18:47 2012 +0200 +++ b/tests/test-mq-qpush-fail.t Fri May 11 16:57:26 2012 +0200 @@ -189,6 +189,19 @@ $ 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 @@ 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]