[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

How use patch_target_t for both files and (possibly multiple) properties

From: Daniel Näslund <daniel_at_longitudo.com>
Date: Sun, 20 Jun 2010 21:53:29 +0200

Hi stsp!

Attaching a patch showing a suggestion on how to split up
patch_target_t. Maybe you have some insights on this, before I rush out
and start grooking around and making changes to your design.

What 'svn patch' does
----------------------
1) Match hunks
2) Apply hunks to a stream backed up by a tmp file
3) Install. copy the tmp file to the target location
4) Notify the user on what has happened, e.g. fuzz, offset and rejects

The problem
-------------
Each property is essentially like it's own text file. 'svn patch' must
be generic enough to be able to perform the above actions on both
properties and texts.

Alternatives
--------------
* Simplify. Don't use the unidiff format but just copy the content
  straight off and apply it.
* Duplicate. Create special code for handling props, e.g. have both
  match_hunk() and match_property_hunk() and so on.

Proposed solution
-------------------
Use patch_target_t as a container for sub-patch_targets that can be either
file-text or a property. Store tree change info needed for step 3)
installing and step 4) notifying.

Use patch_target_stream_t for step 1) matching and step 2) applying. It
should contain streams to the property or text target and the hunks
associated with the specific file/property.

A scratch log message (the attached patch only contains changes to the
structs):

* subversion/libsvn_client/patch.c
  (patch_target_stream_t): New. A struct used for handling the match and
    apply step of 'svn patch'. It can be either associated with the
    content of a file or a property.
  (patch_target_t): Move some fields to patch_target_stream_t and
    introduce it as a new field.
  (get_hunk_info,
   scan_for_match,
   match_hunk): These funcs makes up step 1) matching. Use
    patch_target_stream_t instead of patch_target_t.
  (apply_hunk,
   reject_hunk): These funcs makes up step 2) applying. Use
    patch_target_stream_t instead of patch_target_t.
  (init_patch_target): Create the patch_target_stream_t objects.
  (apply_one_patch): Loop through the available property hunks in the
    patch and do step 1) matching. Loop through the property hunks in
    the patch and do step 2) applying.
  (...): More things to do.

Cheers,
Daniel

Received on 2010-06-20 21:54:28 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.