Fix issue #4822, "svn diff --changelist ARG" broken in subdirectories.
authorJulian Foad <[email protected]>
Sat, 24 Aug 2019 10:50:44 +0000 (24 10:50 +0000)
committerJulian Foad <[email protected]>
Sat, 24 Aug 2019 10:50:44 +0000 (24 10:50 +0000)
A follow-up to r1835234.

* subversion/libsvn_wc/diff_local.c
  (svn_wc__diff7): Pass the correct anchor dir to the changelist filter.

* subversion/tests/cmdline/changelist_tests.py
  (diff_with_changelists_subdir): New test.
  (test_list): Run it.

git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1865841 13f79535-47bb-0310-9956-ffa450edef68

subversion/libsvn_wc/diff_local.c
subversion/tests/cmdline/changelist_tests.py

index 08cdced..26f9c68 100644 (file)
@@ -490,7 +490,7 @@ svn_wc__diff7(svn_boolean_t anchor_at_given_paths,
       SVN_ERR(svn_hash_from_cstring_keys(&changelist_hash, changelist_filter,
                                          result_pool));
       diff_processor = svn_wc__changelist_filter_tree_processor_create(
-                         diff_processor, wc_ctx, local_abspath,
+                         diff_processor, wc_ctx, eb.anchor_abspath,
                          changelist_hash, result_pool);
     }
 
index 1bbb4a6..213a346 100755 (executable)
@@ -1180,6 +1180,44 @@ def readd_after_revert(sbox):
   svntest.actions.run_and_verify_svn(None, [],
                                      'add', dummy)
 
+#----------------------------------------------------------------------
+
+# A wc-wc diff returned no results if changelists were specified and the
+# diff target dir was not the WC root.
+@Issue(4822)
+def diff_with_changelists_subdir(sbox):
+  "diff --changelist (wc-wc) in subdir of WC"
+
+  sbox.build()
+  wc_dir = sbox.wc_dir
+
+  expected_paths = sbox.ospaths(['A/D/gamma'])
+  subdir = 'A/D'
+  clname = 'a'
+
+  for path in expected_paths:
+    svntest.main.file_append(path, "New text.\n")
+  svntest.main.run_svn(None, "changelist", clname, *expected_paths)
+
+  # Run 'svn diff ...'
+  exit_code, output, errput = svntest.main.run_svn(None,
+                                'diff', '--changelist', clname,
+                                sbox.ospath(subdir))
+
+  # Filter the output for lines that begin with 'Index:', and
+  # reduce even those lines to just the actual path.
+  paths = sorted([x[7:].rstrip() for x in output if x[:7] == 'Index: '])
+
+  # Diff output on Win32 uses '/' path separators.
+  if sys.platform == 'win32':
+    paths = [x.replace('/', os.sep) for x in paths]
+
+  # And, compare!
+  if (paths != expected_paths):
+    raise svntest.Failure("Expected paths (%s) and actual paths (%s) "
+                          "don't gel"
+                          % (str(expected_paths), str(paths)))
+
 
 ########################################################################
 # Run the tests
@@ -1203,6 +1241,7 @@ test_list = [ None,
               add_remove_non_existent_target,
               add_remove_unversioned_target,
               readd_after_revert,
+              diff_with_changelists_subdir,
              ]
 
 if __name__ == '__main__':