Submitter | Laurent Charignon |
---|---|
Date | May 21, 2015, 11:17 p.m. |
Message ID | <8f8a971dcca865d75dbf.1432250236@lcharignon-mbp.dhcp.thefacebook.com> |
Download | mbox | patch |
Permalink | /patch/9230/ |
State | Accepted |
Delegated to: | Pierre-Yves David |
Headers | show |
Comments
On 05/21/2015 06:17 PM, Laurent Charignon wrote: > # HG changeset patch > # User Laurent Charignon <lcharignon@fb.com> > # Date 1432244064 25200 > # Thu May 21 14:34:24 2015 -0700 > # Node ID 8f8a971dcca865d75dbfa29f084b4438207d33ba > # Parent 49349c5b51b04257a674de2cb3f17e1475953c9f > revert: fix bug in revert --interactive I think we want a more descriptive summary line. What do you think of: revert: fix edition of newly added file during --interactive Also: no issue number?
On 5/22/15, 2:53 PM, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org> wrote: > > >On 05/21/2015 06:17 PM, Laurent Charignon wrote: >> # HG changeset patch >> # User Laurent Charignon <lcharignon@fb.com> >> # Date 1432244064 25200 >> # Thu May 21 14:34:24 2015 -0700 >> # Node ID 8f8a971dcca865d75dbfa29f084b4438207d33ba >> # Parent 49349c5b51b04257a674de2cb3f17e1475953c9f >> revert: fix bug in revert --interactive > >I think we want a more descriptive summary line. What do you think of: > > revert: fix edition of newly added file during --interactive Sure, it looks better > >Also: no issue number? I didn't open an issue for that as it was found + resolved at the same time. > >-- >Pierre-Yves David >
Patch
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -3123,6 +3123,7 @@ else: normal = repo.dirstate.normal + newlyaddedandmodifiedfiles = set() if interactive: # Prompt the user for changes to revert torevert = [repo.wjoin(f) for f in actions['revert'][0]] @@ -3137,6 +3138,7 @@ except patch.PatchError, err: raise util.Abort(_('error parsing patch: %s') % err) + newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) # Apply changes fp = cStringIO.StringIO() for c in chunks: @@ -3160,8 +3162,10 @@ repo.dirstate.normallookup(f) for f in actions['add'][0]: - checkout(f) - repo.dirstate.add(f) + # Don't checkout modified files, they are already created by the diff + if f not in newlyaddedandmodifiedfiles: + checkout(f) + repo.dirstate.add(f) normal = repo.dirstate.normallookup if node == parent and p2 == nullid: diff --git a/tests/test-revert-interactive.t b/tests/test-revert-interactive.t --- a/tests/test-revert-interactive.t +++ b/tests/test-revert-interactive.t @@ -270,3 +270,53 @@ 3 4 5 + $ rm f.orig + $ hg update -C . + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + +Check editing files newly added by a revert + +1) Create a dummy editor changing 1 to 42 + $ cat > $TESTTMP/editor.sh << '__EOF__' + > cat "$1" | sed "s/1/42/g" > tt + > mv tt "$1" + > __EOF__ + +2) Remove f + $ hg rm f + $ hg commit -m "remove f" + +3) Do another commit on top + $ touch k; hg add k + $ hg commit -m "add k" + $ hg st + +4) Use interactive revert to recover f and change it on the fly + $ HGEDITOR="\"sh\" \"\${TESTTMP}/editor.sh\"" PRINTHUNK="YES" hg revert -i -r ".^^" <<EOF + > y + > e + > EOF + adding f + removing k + diff --git a/f b/f + new file mode 100644 + examine changes to 'f'? [Ynesfdaq?] y + + @@ -0,0 +1,7 @@ + +a + +1 + +2 + +3 + +4 + +5 + +b + record this change to 'f'? [Ynesfdaq?] e + + $ cat f + a + 42 + 2 + 3 + 4 + 5 + b