4546: rbt diff is different from svn diff

totoroliu
david
david

What version are you running?

rbtools-0.7.9

What steps will reproduce the problem?

  1. prepare a test file below and commit into SVN:

-- test line1
-- this line (test1)
-- test lin2
-- test line (test2)

  1. remove line#2: -- this line (test1)

  1. svn diff would show:
$ svn diff
Index: test
===================================================================
--- test    (revision 16006)
+++ test    (working copy)
@@ -1,4 +1,3 @@
 -- test line1
--- this line (test1)
 -- test lin2
 -- test line (test2)

  1. rbt diff is incorrect and missing the line of change:
$ rbt diff
Index: /TestProject/trunk/Test/folder/test
===================================================================
--- /TestProject/trunk/Test/folder/test (revision 16006)
+++ /TestProject/trunk/Test/folder/test (working copy)
@@ -1,4 +1,3 @@
 -- test line1
 -- test lin2
 -- test line (test2)

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

rbt diff should be the same as svn diff,
but there are missing lines and caused rbt patch failure.

What operating system are you using?

Ubuntu 14.04.05 LTS

Attach the debug out from the command.

$ rbt diff --debug
>>> RBTools 0.7.9
>>> Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]
>>> Running on Linux-4.4.0-75-generic-x86_64-with-Ubuntu-16.04-xenial
>>> Home = /home/rickliu
>>> Current directory = /home/rickliu/scrach/TestProject_trunk/Test/folder
>>> Command line: rbt diff --debug
>>> Checking for a Subversion repository...
>>> Running: svn --non-interactive info
>>> Running: diff --version
>>> Running: svn --non-interactive --version -q
>>> repository info: Path: http://scm-yvr.fortinet.com/svn/svntest, Base path: /TestProject/trunk/Test/folder, Supports changesets: False
>>> Making HTTP GET request to http://172.16.182.156/api/
>>> Running: svn --non-interactive info
>>> Running: diff --version
>>> Running: svn --non-interactive --version -q
>>> repository info: Path: http://scm-yvr.fortinet.com/svn/svntest, Base path: /TestProject/trunk/Test/folder, Supports changesets: False
>>> Running: svn --non-interactive status -q --ignore-externals
>>> Running: svn --non-interactive diff --diff-cmd=diff --notice-ancestry -r BASE
>>> Running: svn --non-interactive info test
>>> Running: svn --non-interactive diff --diff-cmd=diff --notice-ancestry -r BASE --no-diff-deleted
>>> Running: svn --non-interactive info test
>>> Running: svn --non-interactive info test
>>> Running: svn --non-interactive info test
Index: /TestProject/trunk/Test/folder/test
===================================================================
--- /TestProject/trunk/Test/folder/test (revision 16006)
+++ /TestProject/trunk/Test/folder/test (working copy)
@@ -1,4 +1,3 @@
 -- test line1
 -- test lin2
 -- test line (test2)

Please provide any additional information below.

totoroliu
#1 totoroliu

Upload the test files

  • +
    -- test line1
    -- this line (test1)
    -- test lin2
    -- test line (test2)
    +
    Index: test
    ===================================================================
    --- test	(revision 16006)
    +++ test	(working copy)
    @@ -1,4 +1,3 @@
     -- test line1
    --- this line (test1)
     -- test lin2
     -- test line (test2)
    +
    Index: /TestProject/trunk/Test/folder/test
    ===================================================================
    --- /TestProject/trunk/Test/folder/test	(revision 16006)
    +++ /TestProject/trunk/Test/folder/test	(working copy)
    @@ -1,4 +1,3 @@
     -- test line1
     -- test lin2
     -- test line (test2)
chipx86
#2 chipx86

So the problem has to do with the handle_renames function in rbtools/clients/svn.py. We look for --- and +++ lines, but we're not keeping state to determine if we're in a diff header or in code.

The fix shouldn't be too bad. Instead of unconditionally skipping --- and +++ lines, we need to look for Index: lines and then parse out until we're into the code, then normalize the lines until we're back in Index:.

  • -New
    +Confirmed
  • +djblets:Release-0.8.x
  • -Priority:Medium
    +Priority:High
    +SCM:Subversion
david
#3 david
  • +david
david
#4 david

Up for review at https://reviews.reviewboard.org/r/8934/

  • -Confirmed
    +PendingReview
david
#5 david

Fixed in release-0.7.x (8e28fae). This will ship in 0.7.10, which is coming within the next day or so.

  • -PendingReview
    +Fixed
  • -djblets:Release-0.8.x
totoroliu
#6 totoroliu

Hi David,

I'm using "RBTools 0.7.11" now,
and I got "CRITICAL: too many values to unpack" error
if my text file test2.txt contains:
-- T1 (ESF) 65

svn diff
Index: test2.txt
===================================================================
--- test2.txt (revision 201771)
+++ test2.txt (nonexistent)
@@ -1 +0,0 @@
--- T1 (ESF) 65

rbt diff --debug

RBTools 0.7.11
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609]
Running on Linux-4.4.0-112-generic-x86_64-with-Ubuntu-16.04-xenial
Home = /home/rickliu
Current directory = /tmp/rick_rb_test_trunk/
Command line: rbt diff --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: https://xxx.com/svn/xxx, Base path: /rick_rb_test_trunk/, Supports changesets: False
Making HTTP GET request to https://reviewboard.xxx.com/api/
Running: svn --non-interactive info
Running: diff --version
Running: svn --non-interactive --version -q
repository info: Path: https://xxx.com/svn/xxx, Base path: /rick_rb_test_trunk/, Supports changesets: False
Running: svn --non-interactive status -q --ignore-externals
Running: svn --non-interactive diff --diff-cmd=diff --notice-ancestry -r BASE
Running: svn --non-interactive info test2.txt
Running: svn --non-interactive diff --diff-cmd=diff --notice-ancestry -r BASE --no-diff-deleted
Running: svn --non-interactive info test2.txt
Running: svn --non-interactive info test2.txt
Running: svn --non-interactive info test2.txt
Traceback (most recent call last):
File "/usr/local/bin/rbt", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/rbtools/commands/main.py", line 133, in main
command.run_from_argv([RB_MAIN, command_name] + args)
File "/usr/local/lib/python2.7/dist-packages/rbtools/commands/init.py", line 665, in run_from_argv
exit_code = self.main(*args) or 0
File "/usr/local/lib/python2.7/dist-packages/rbtools/commands/diff.py", line 69, in main
extra_args=extra_args)
File "/usr/local/lib/python2.7/dist-packages/rbtools/clients/svn.py", line 405, in diff
diff = self.convert_to_absolute_paths(diff, repository_info)
File "/usr/local/lib/python2.7/dist-packages/rbtools/clients/svn.py", line 663, in convert_to_absolute_paths
file, rest = self.parse_filename_header(line)
ValueError: too many values to unpack

totoroliu
#7 totoroliu

Attach test2.txt and svn.diff

  • +
    --      T1 (ESF)                   65
    +
    Index: test2.txt
    ===================================================================
    --- test2.txt	(revision 201771)
    +++ test2.txt	(nonexistent)
    @@ -1 +0,0 @@
    ---      T1 (ESF)                   65