1textutil::patch(n)         Text and string utilities        textutil::patch(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       textutil::patch - Application of uni-diff patches to directory trees
9

SYNOPSIS

11       package require Tcl  8.2
12
13       package require textutil::patch  ?0.1?
14
15       ::textutil::patch::apply basedirectory striplevel patch reportcmd
16
17       {*}reportcmd apply filename
18
19       {*}reportcmd fail filename hunk expected seen
20
21       {*}reportcmd fail-already filename hunk
22
23______________________________________________________________________________
24

DESCRIPTION

26       This package provides a single command which applies a patch in unified
27       format     [https://www.gnu.org/software/diffutils/manual/html_node/De
28       tailed-Unified.html] to a directory tree.
29
30       ::textutil::patch::apply basedirectory striplevel patch reportcmd
31              Applies  the  patch (text of the path, not file) to the files in
32              the basedirectory using the specified striplevel.  The result of
33              the command is the empty string.
34
35              The  striplevel argument is equivalent to option -p of the patch
36              command.
37
38              Errors are thrown when the patch does not parse, and nothing  is
39              done to the files in basedirectory.
40
41              All  activities  during  the application of the patch, including
42              the inability to apply a hunk are reported through  the  command
43              prefix  reportcmd  instead.  Files  with  problems  are left un‐
44              changed.  Note however that this does  not  prevent  changes  to
45              files  with  no  problems,  before  and  after  the  problematic
46              file(s).
47
48              The command prefix is called in 3 possible forms:
49
50              {*}reportcmd apply filename
51                     The caller begins operation on file fname,  applying  all
52                     hunks collected for said file.
53
54              {*}reportcmd fail filename hunk expected seen
55                     Application  of  hunk  number  hunk  of file filename has
56                     failed.  The command expected to find the text  expected,
57                     and saw seen instead.
58
59              {*}reportcmd fail-already filename hunk
60                     Application  of  hunk  number  hunk  of file filename has
61                     failed.  The command believes that this hunk has  already
62                     been applied to the file.
63

BUGS, IDEAS, FEEDBACK

65       This  document,  and the package it describes, will undoubtedly contain
66       bugs and other problems.  Please report such in the  category  textutil
67       of  the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist].  Please
68       also report any ideas for enhancements you may have for either  package
69       and/or documentation.
70
71       When proposing code changes, please provide unified diffs, i.e the out‐
72       put of diff -u.
73
74       Note further that  attachments  are  strongly  preferred  over  inlined
75       patches.  Attachments  can  be  made  by  going to the Edit form of the
76       ticket immediately after its creation, and  then  using  the  left-most
77       button in the secondary navigation bar.
78

KEYWORDS

80       diff  -ruN,  diff,  unified  format, fossil, git, patch, unified format
81       diff
82

CATEGORY

84       Text processing
85
86
87
88tcllib                                0.1                   textutil::patch(n)
Impressum