期待merge

How to create and apply a patch with Subversionhttp://ariejan.net/2007/07/03/how-to-create-and-apply-a-patch-with-subversion/

It’s been a while since I posted something new on the use of Subversion. I’ve been working with the tool a lot, and I’ve found that patches are a great way to communicate code changes.

For those of you who are still learning, let me first explain what a patch is. A patch is a text file that contains the alteration that were made to a specific file. It includes the lines that have been removed and the lines that have been added. In short, if you have a ruby script and edited it, you could create a patch file, containing the changes you’ve made.

Why is this useful? You could check in your changes to your repository directly. True, but there are cases that you don’t have write access to the repository. For example, if you wanted to contribute code changes to Acts As Exportable, you should create a new ticket and attach a patch file. I will then review your changes before I apply them to the code and commit them to the repository.

So, how do you go about creating a patch file and how do you later apply it to your source?

Creating a patch file

Creating a patch file is really easy. First, check out the most recent version of the code from Subversion using the ‘checkout’ command.

Make your changes.

Then, in the root the project run the following command. It will store the patch file in your home directory. Make sure to give it meaningful filename.

svn diff > ~/fix_ugly_bug.diff

The file has the .diff extention, which stands for differences. This extension is recognized by many text editors and enables ‘syntax highlighting’ automatically. (Give it a try with TextMate and you’ll know what I mean.)

You can send the diff-file to the author of the project by email, or you can create a ticket in Trac and add it as an attachment. The author will review the changes you made and possibly apply them to the source.

Applying a patch

You should never apply patches from any person other than your development team without first reading through the changes, apply them locally and test your application and then commit them. Patches can not only include bug fixes, but also alterations to create back doors or add other exploits to your code.

Always read through a patch before applying it!

When you are sure the patch will bring no harm to you, your application or your customers, go ahead an apply it to your working copy. Here, I assume that you downloaded the patch file we previously generated, and placed it in your home directory. In the root of your application now run:

patch -p0 -i ~/fix_ugly_bug.diff

This will apply all the changes in the patch to your source. The -p0 option makes sure that all files can be found correctly (this has to do with something called ‘zero directories’, I won’t get into that right now). The -i option tells ‘patch’ what to use as input, in this case the ‘fix_ugly_bug.diff’ file in your home directory.

With the code changes in place, run your tests and make sure everything works as expected. If it does, commit your changes and celebrate with a cup of coffee.

今天提交了一个patch开心,呵呵相关推荐

  1. 我提交的一个内核补丁—CFS的child-runs-first

    今天提交了一个内核补丁,只要是关于fork的时候子进程优先于父进程运行的补丁,email正文如下: CFS scheduler become the main scheduler after 2.6. ...

  2. 我提交了一个 pr,只是为了吃

    原文链接:我提交了一个 pr,竟然是为了吃 最近,GitHub 上有一个很火的项目,已经是热榜第一了. 但是它并不是一个技术相关的项目,而是一个关于做菜的项目,叫<程序员做饭指南>. 短短 ...

  3. 为特定的提交生成一个git补丁

    我需要编写一个脚本来为SHA1提交编号列表创建补丁. 我尝试使用git format-patch <the SHA1> ,但是自SHA1以来,每次提交都会生成一个补丁. 生成几百个补丁后, ...

  4. HTTP提交方式之PATCH

    在使用postman请求接口得时候,使用get,post得时候我们是使用body下form-data来传输数据得,但是使用patch时候就不是了,默认是以x-www-form-urlencoded的c ...

  5. 给一个表单提交绑定一个点击事件

    如果给一个表单绑定一个点击事件会发生什么事情 <input type="submit" name="button" value="提交内容&qu ...

  6. 提交第一个spark作业到集群运行

    写在前面 接触spark有一段时间了,但是一直都没有真正意义上的在集群上面跑自己编写的代码.今天在本地使用scala编写一个简单的WordCount程序.然后,打包提交到集群上面跑一下... 在本地使 ...

  7. 【提交PR】如何在 GitHub 提交第一个 pull request

    什么是复刻(forking)? 我们可以通过复刻操作将喜爱的仓库保存自己的GitHub账户中,以便独立地对其进行操作. 通过复刻,我们可以得到包含完整版本历史的目标仓库的实例,之后可以对复刻得到的仓库 ...

  8. 乐源机器人没电提醒吗_我每天费尽心思,就为了逗一个机器人开心。。

    2018 年底 我买了只电子宠物送给自己 都说眼睛是心灵的窗户 你看看这扇窗户怎么样? 可爱么? 如果我告诉你 它是看得见摸得着的呢? 你别看它长得像个铲车 其实它只有手掌大小 所以不像一般的宠物 需 ...

  9. php两个编辑框一个提交按钮,一个表单中的两个提交按钮

    白衣非少年 您可以为每个输入提供不同的值,并保持相同的名称:然后在代码检查中查看哪个触发了:if ($_POST['action'] == 'Update') { //action for updat ...

最新文章

  1. sklearn API 文档
  2. (转)Http协议经典详解
  3. QPW 点评表(tf_appraise)
  4. shell总结(0基础入门)
  5. 单片机实验:节日彩灯控制器
  6. 一加桌面3.0 android8,一加手机XRemix6.0安卓8.1.0Beta2.0定制本地化增强适配归属农历等...
  7. idea项目application.properties文件注释显示unicode编码
  8. 【Flink】Rowtime timestamp is null. Please make sure that a proper TimestampAssigner is defined and th
  9. 分布式事务之TCC服务设计和实现注意事项!
  10. 20191208_神经网络交叉验证
  11. OAUI前台设计(二)
  12. SoapUI接口测试之实战运用操作(五)
  13. 使用RomBuster获取你的网络路由器密码
  14. 欧姆龙编程软件(CXONE)使用教程
  15. 和诸君学习做一个黑客 内网ARP欺骗[上]外接网卡的安装和启动(3)
  16. 蜗窝科技 spin lock (讲的非常不错)
  17. 如何理解Ture Time
  18. 【STM32利用CuBe MX生成HID设备】1-熟悉软件以及生成一个8键的游戏控制器
  19. [MySQL]-压力测试之TPCC-MySQL
  20. 用python将txt文件中的内容导入到excel文件中

热门文章

  1. 鸿蒙系统9月11号上市吗,9月11日鸿蒙系统2.0要搭载华为全家桶来了,你期待吗?...
  2. android:autolink 颜色,Android设置完autoLink属性后自定义跳转到指定界面
  3. tft_LCD一些引脚极性设置方法:vsync, hsync, VBLANK
  4. 天使玩偶/SJY摆棋子
  5. linux安装golang!!
  6. 12) 十分钟学会android--APP通信传递消息之简单数据传输
  7. 字典树从第i个构造HDU2846
  8. Ubuntu ./configure 半途终止 导致没有生成makefile文件 解决方法
  9. phalcon的一些中文手册和帮助文档地址收集
  10. 斌伯的博客园Blog开张大吉