简体   繁体   中英

Diff branches while excluding merge for subversion

I'm using subversion and I want to diff the start of my branch to the current state of all my files. In addition, I want to exclude certain revisions from the diff. For example, consider the following:

NOTE: treat each character in each file below as a block of code. ("A" is a block of code and "B" is a different block of code)

ID 0: I start with the Trunk:

  • File_A (contains "A")
  • File_B (contains "B")
  • File_C (contains "C")
  • File_D (contains "D")

ID 1: I create a branch:

  • File_A (contains "A")
  • File_B (contains "B")
  • File_C (contains "C")
  • File_D (contains "D")

ID 2: I modify File_A, File_B, and File_D. I append to File_A and File_B and change the contents of File_D.

  • File_A (contains "A1")
  • File_B (contains "B1")
  • File_C (contains "C")
  • File_D (contains "F")

ID 3: I find out that File_B, File_C and File_D has changed in the trunk. The trunk is now:

  • File_A (contains "A")
  • File_B (contains "B2")
  • File_C (contains "C2")
  • File_D (contains "E")

ID 4: I then merge from the trunk into my branch:

  • File_A (contains "A1")
  • File_B (contains "B12")
  • File_C (contains "C2")
  • File_D (contains "EF")

ID 5: I modify B and C in my branch. Revision is 24015:

  • File_A (contains "A1")
  • File_B (contains "B123")
  • File_C (contains "C3")
  • File_D (contains "EF")

Now I want a diff between when I started my branch (ID 1) and when I finished my branch (ID 5) while excluding changes from the merge.

ID 6: I want the diff to show the following:

  • File_A (it was "A" and is now "A1" / diff shows "1")
  • File_B (it was "B" and is now "B13" / diff shows "13")
  • File_C (it was "C" and is now "C3" / diff shows "3")
  • File_D (it was "D" and is now "F" / diff shows all differences between D and F)

I want create a patch file that contains the changes for the four files above. So when applied to ID 1, I get ID 6. Does anyone have any ideas?

Two obvious ways

  • Short way : svn help diff , 4-th form. Just diff heads of branch and trunk: identical hunks in both sides ( A , C2 , B ) will be skipped (you'll effectively ignore mergesets, if they only performed merges without edits)

  • Dumb way, as requested : svn help diff , 2-nd form with -c option. You'll diff branch (start of branch or HEAD - can't recall from mind and too lazy to test) with multiple use -c REV in order to enumerate all revisions in branch without mergeset(s)

Textually diffs may be slightly different, because SVN's unified diff work in context (3 lines around hunk by default) and for "thin" changes it will (may be) visible

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM