Patchwork [stable] revert: ensure that copies and renames are honored (issue3920)

login
register
mail settings
Submitter Bryan O'Sullivan
Date May 3, 2013, 7:46 p.m.
Message ID <9b1144f071f8688f33c8.1367610364@australite.local>
Download mbox | patch
Permalink /patch/1543/
State Accepted
Commit bd19587a3347c67032cab362176b89b85b38c3c2
Headers show

Comments

Bryan O'Sullivan - May 3, 2013, 7:46 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1367610017 25200
#      Fri May 03 12:40:17 2013 -0700
# Node ID 9b1144f071f8688f33c80d17663b41fd52da9227
# Parent  d982edcfe7f0e815a6dd878de1823e7da3e3b17c
revert: ensure that copies and renames are honored (issue3920)

Previously, we restored the states of files, but not the additional
information the dirstate uses to track copies and renames.
Matt Mackall - May 3, 2013, 7:50 p.m.
On Fri, 2013-05-03 at 12:46 -0700, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano@fb.com>
> # Date 1367610017 25200
> #      Fri May 03 12:40:17 2013 -0700
> # Node ID 9b1144f071f8688f33c80d17663b41fd52da9227
> # Parent  d982edcfe7f0e815a6dd878de1823e7da3e3b17c
> revert: ensure that copies and renames are honored (issue3920)

Queued for stable, thanks.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2055,6 +2055,12 @@  def revert(ui, repo, ctx, parents, *pats
                 checkout(f)
                 normal(f)
 
+            copied = copies.pathcopies(repo[parent], ctx)
+
+            for f in add[0] + undelete[0] + revert[0]:
+                if f in copied:
+                    repo.dirstate.copy(copied[f], f)
+
             if targetsubs:
                 # Revert the subrepos on the revert list
                 for sub in targetsubs:
diff --git a/tests/test-revert.t b/tests/test-revert.t
--- a/tests/test-revert.t
+++ b/tests/test-revert.t
@@ -275,4 +275,28 @@  should silently revert the named files
   $ hg revert --no-backup ignored removed
   $ hg st -mardi
 
+someone set up us the copies
+
+  $ rm .hgignore
+  $ hg update -C
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg mv ignored allyour
+  $ hg copy removed base
+  $ hg commit -m rename
+
+copies and renames, you have no chance to survive make your time (issue3920)
+
+  $ hg update '.^'
+  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ hg revert -rtip -a
+  adding allyour
+  adding base
+  removing ignored
+  $ hg status -C
+  A allyour
+    ignored
+  A base
+    removed
+  R ignored
+
   $ cd ..