Patchwork [6,of,7,V4] mq: let the user choose where .orig files are kept

login
register
mail settings
Submitter Christian Delahousse
Date Nov. 11, 2015, 12:59 a.m.
Message ID <1ea4093ba6f2303e968b.1447203597@dev4253.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11356/
State Accepted
Commit 263edb591b72babf930ef6b4c69c7ce515ca7c55
Headers show

Comments

Christian Delahousse - Nov. 11, 2015, 12:59 a.m.
# HG changeset patch
# User Christian Delahousse <cdelahousse@fb.com>
# Date 1447195974 28800
#      Tue Nov 10 14:52:54 2015 -0800
# Node ID 1ea4093ba6f2303e968b6d25716a6b2116ecbb95
# Parent  550d3afadfb753e710c7032f8719cd82f2895b9a
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.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -697,11 +697,13 @@ 
             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 @@ 
   $ 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 @@ 
   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 @@ 
 
 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 @@ 
   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 @@ 
   +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