# HG changeset patch # User Christian Delahousse # Date 2015-11-10 22:52:54 # Node ID 263edb591b72babf930ef6b4c69c7ce515ca7c55 # Parent d55d22840592ee8898f19d0c227be86d9fdfbe94 mq: let the user choose where .orig files are kept This patch uses cmdutil.origpath to let the user decide where .orig files are kept when backup files are created. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -697,11 +697,13 @@ class queue(object): absf = repo.wjoin(f) if os.path.lexists(absf): self.ui.note(_('saving current version of %s as %s\n') % - (f, f + '.orig')) + (f, cmdutil.origpath(self.ui, repo, f))) + + absorig = cmdutil.origpath(self.ui, repo, absf) if copy: - util.copyfile(absf, absf + '.orig') + util.copyfile(absf, absorig) else: - util.rename(absf, absf + '.orig') + util.rename(absf, absorig) def printdiff(self, repo, diffopts, node1, node2=None, files=None, fp=None, changes=None, opts={}): 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 @@ -444,7 +444,7 @@ test mq.keepchanges setting $ hg st a M a $ echo b >> b - $ hg --config mq.keepchanges=1 qpop --force + $ hg --config mq.keepchanges=1 qpop --force --config 'ui.origbackuppath=.hg/origbackups' popping p3 now at: p2 $ hg st b @@ -461,4 +461,10 @@ test mq.keepchanges setting now at: p2 $ hg st a +test previous qpop (with --force and --config) saved .orig files to where user +wants them + $ ls .hg/origbackups + b.orig + $ rm -rf .hg/origbackups + $ cd .. diff --git a/tests/test-mq.t b/tests/test-mq.t --- a/tests/test-mq.t +++ b/tests/test-mq.t @@ -1394,9 +1394,10 @@ qpush should fail, local changes apply force, should discard changes in hello, but not bye - $ hg qpush -f --verbose + $ hg qpush -f --verbose --config 'ui.origbackuppath=.hg/origbackups' applying empty - saving current version of hello.txt as hello.txt.orig + creating directory: $TESTTMP/forcepush/.hg/origbackups + saving current version of hello.txt as $TESTTMP/forcepush/.hg/origbackups/hello.txt.orig patching file hello.txt committing files: hello.txt @@ -1405,7 +1406,6 @@ apply force, should discard changes in h now at: empty $ hg st M bye.txt - ? hello.txt.orig $ hg diff --config diff.nodates=True diff -r ba252371dbc1 bye.txt --- a/bye.txt @@ -1428,6 +1428,10 @@ apply force, should discard changes in h +world +universe +test that the previous call to qpush with -f (--force) and --config actually put +the orig files out of the working copy + $ ls .hg/origbackups + hello.txt.orig test popping revisions not in working dir ancestry