[PATCH] revert: rename original to .orig instead of copying (issue2282)

Mads Kiilerich mads at kiilerich.com
Mon Jul 12 20:06:03 CDT 2010


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1278983054 -7200
# Node ID d4d62ad50e00084e89b20e8cb91feab4487d31cd
# Parent  67b07df92ca18e081ee9b3fdd290ace3a2c63611
revert: rename original to .orig instead of copying (issue2282)

By renaming before reverting the content of the file we ensure that we handle
and break hardlinks properly.

Handling of other hardlinks to .orig is somebody elses problem.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3165,7 +3165,7 @@
                     ui.note(_('saving current version of %s as %s\n') %
                             (rel, bakname))
                     if not opts.get('dry_run'):
-                        util.copyfile(target, bakname)
+                        util.rename(target, bakname)
                 if ui.verbose or not exact:
                     msg = xlist[1]
                     if not isinstance(msg, basestring):


More information about the Mercurial-devel mailing list