4556: rbt diff produces incorrect patch.diff format which caused rbt patch (svn patch) incorrectly delete files

totoroliu

What version are you running?

RBTools 0.7.10
svn, version 1.9.3 (r1718519)
diff (GNU diffutils) 3.3
Ubuntu 16.04.2 LTS

What steps will reproduce the problem?

  1. Run "svn merge" to have "svn status" with "R + FileA" (aka replace with History scheduled with commit.)
  2. rbt diff --svn-show-copies-as-adds=y --include FileA
  3. svn diff FileA
  4. rbt patch or svn patch would result FileA been deleted

What is the expected output? What do you see instead?

"rbt diff" should be in similar format as "svn diff".
"svn diff" has single diff header (Index:) for FileA.
"rbt diff" has TWO diff headers (Index:) for FileA.
With the TWO diff headers,
the first header is deleting the file at current branch;
the second header is adding the file back from the merge source.
However,
rbt patch (svn patch) is failed to add the file back,
and results the file been deleted.

What operating system are you using?

Ubuntu 16.04.2 LTS

Attach the debug out from the command.

$ svn st apache2/include/cache_common.h
R  +    apache2/include/cache_common.h



$ svn diff apache2/include/cache_common.h
Index: apache2/include/cache_common.h
===================================================================
--- apache2/include/cache_common.h  (revision 99047)
+++ apache2/include/cache_common.h  (working copy)

Property changes on: apache2/include/cache_common.h
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property



$ rbt diff --svn-show-copies-as-adds=y --include apache2/include/cache_common.h --debug
>>> RBTools 0.7.10
>>> Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]
>>> Running on Linux-4.4.0-78-generic-x86_64-with-Ubuntu-16.04-xenial
>>> Home = /home/rickliu
>>> Current directory = /tmp/server
>>> Command line: rbt diff --svn-show-copies-as-adds=y --include apache2/include/cache_common.h --debug
>>> Running: tf vc help
>>> Checking for a Subversion repository...
>>> Running: svn --non-interactive info
>>> Running: diff --version
>>> Running: svn --non-interactive --version -q
>>> repository info: Path: http://xxxx/svn/, Base path: /server, Supports changesets: False
>>> Making HTTP GET request to http://reviewboard.xxxx.com/api/
>>> Running: svn --non-interactive info
>>> Running: diff --version
>>> Running: svn --non-interactive --version -q
>>> repository info: Path: http://xxxx/svn/, Base path: /server, Supports changesets: False
>>> Running: svn --non-interactive diff --diff-cmd=diff --notice-ancestry -r BASE apache2/include/cache_common.h --show-copies-as-adds
>>> Running: svn --non-interactive info apache2/include/cache_common.h
>>> Running: svn --non-interactive diff --diff-cmd=diff --notice-ancestry -r BASE apache2/include/cache_common.h --show-copies-as-adds --no-diff-deleted
>>> Running: svn --non-interactive info apache2/include/cache_common.h
>>> Running: svn --non-interactive info apache2/include/cache_common.h
>>> Running: svn --non-interactive info apache2/include/cache_common.h
>>> Running: svn --non-interactive info apache2/include/cache_common.h
>>> Running: svn --non-interactive info apache2/include/cache_common.h
Index: /server/apache2/include/cache_common.h
===================================================================
--- /server/apache2/include/cache_common.h  (revision 99047)
+++ /server/apache2/include/cache_common.h  (nonexistent)
@@ -1,56 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file cache_common.h
- * @brief Common Cache structs
- *
- * @defgroup Cache_cache  Cache Functions
- * @ingroup  MOD_CACHE
- * @{
- */
-
-#ifndef CACHE_COMMON_H
-#define CACHE_COMMON_H
-
-/* a cache control header breakdown */
-typedef struct cache_control {
-    unsigned int parsed:1;
-    unsigned int cache_control:1;
-    unsigned int pragma:1;
-    unsigned int no_cache:1;
-    unsigned int no_cache_header:1; /* no cache by header match */
-    unsigned int no_store:1;
-    unsigned int max_age:1;
-    unsigned int max_stale:1;
-    unsigned int min_fresh:1;
-    unsigned int no_transform:1;
-    unsigned int only_if_cached:1;
-    unsigned int public:1;
-    unsigned int private:1;
-    unsigned int private_header:1; /* private by header match */
-    unsigned int must_revalidate:1;
-    unsigned int proxy_revalidate:1;
-    unsigned int s_maxage:1;
-    unsigned int invalidated:1; /* has this entity been invalidated? */
-    apr_int64_t max_age_value; /* if positive, then set */
-    apr_int64_t max_stale_value; /* if positive, then set */
-    apr_int64_t min_fresh_value; /* if positive, then set */
-    apr_int64_t s_maxage_value; /* if positive, then set */
-} cache_control_t;
-
-#endif /* CACHE_COMMON_H */
-/** @} */

Property changes on: apache2/include/cache_common.h
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: /server/apache2/include/cache_common.h
===================================================================
--- /branches/5.x/server/apache2/include/cache_common.h (nonexistent)
+++ /server/apache2/include/cache_common.h  (working copy)
@@ -0,0 +1,56 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file cache_common.h
+ * @brief Common Cache structs
+ *
+ * @defgroup Cache_cache  Cache Functions
+ * @ingroup  MOD_CACHE
+ * @{
+ */
+
+#ifndef CACHE_COMMON_H
+#define CACHE_COMMON_H
+
+/* a cache control header breakdown */
+typedef struct cache_control {
+    unsigned int parsed:1;
+    unsigned int cache_control:1;
+    unsigned int pragma:1;
+    unsigned int no_cache:1;
+    unsigned int no_cache_header:1; /* no cache by header match */
+    unsigned int no_store:1;
+    unsigned int max_age:1;
+    unsigned int max_stale:1;
+    unsigned int min_fresh:1;
+    unsigned int no_transform:1;
+    unsigned int only_if_cached:1;
+    unsigned int public:1;
+    unsigned int private:1;
+    unsigned int private_header:1; /* private by header match */
+    unsigned int must_revalidate:1;
+    unsigned int proxy_revalidate:1;
+    unsigned int s_maxage:1;
+    unsigned int invalidated:1; /* has this entity been invalidated? */
+    apr_int64_t max_age_value; /* if positive, then set */
+    apr_int64_t max_stale_value; /* if positive, then set */
+    apr_int64_t min_fresh_value; /* if positive, then set */
+    apr_int64_t s_maxage_value; /* if positive, then set */
+} cache_control_t;
+
+#endif /* CACHE_COMMON_H */
+/** @} */

Property changes on: apache2/include/cache_common.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Please provide any additional information below.

totoroliu
#1 totoroliu

$ rbt patch --debug 104521
>>> RBTools 0.7.10
>>> Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]
>>> Running on Linux-4.4.0-78-generic-x86_64-with-Ubuntu-16.04-xenial
>>> Home = /home/rickliu
>>> Current directory = /tmp/server
>>> Command line: rbt patch --debug 104521
>>> Running: tf vc help
>>> Checking for a Subversion repository...
>>> Running: svn --non-interactive info
>>> Running: diff --version
>>> Running: svn --non-interactive --version -q
>>> repository info: Path: http://xxxxx/svn/, Base path: /server, Supports changesets: False
>>> Making HTTP GET request to http://reviewboard.xxxxxx.com/api/
>>> Making HTTP GET request to http://reviewboard.xxxxxx.com/api/repositories/?tool=Subversion
>>> Cached response for HTTP GET http://reviewboard.xxxxxx.com/api/repositories/?tool=Subversion expired and was modified
>>> Making HTTP GET request to http://reviewboard.xxxxxx.com/api/review-requests/104521/diffs/
>>> Added cache entry for HTTP GET request to http://reviewboard.xxxxxx.com/api/review-requests/104521/diffs/
>>> Making HTTP GET request to http://reviewboard.xxxxxx.com/api/review-requests/104521/diffs/1/
>>> Added cache entry for HTTP GET request to http://reviewboard.xxxxxx.com/api/review-requests/104521/diffs/1/
>>> Making HTTP GET request to http://reviewboard.xxxxxx.com/api/review-requests/104521/diffs/1/
>>> Added cache entry for HTTP GET request to http://reviewboard.xxxxxx.com/api/review-requests/104521/diffs/1/
Patch is being applied from request 104521 with diff revision 1.
>>> Running: svn --non-interactive patch --strip=5 /tmp/tmptMkAQ5

U        apache2/include/cache_common.h
>         hunk @@ -0,0 +1,56 @@ already applied
D         apache2/include/cache_common.h

Successfully applied patch.
rickliu@rickliu-linux:/tmp/server$ svn st
D       apache2/include/cache_common.h
chipx86
#2 chipx86
  • -New
    +Confirmed
  • +Release-0.7.x
  • -Priority:Medium
    +Priority:High
    +SCM:Subversion