[PATCH 2 of 2] revert: save backup of undeleted files (issue3422)

Matt Mackall mpm at selenic.com
Tue May 8 15:56:25 CDT 2012


On Fri, 2012-05-04 at 10:26 -0500, Kevin Bullock wrote:
> On May 4, 2012, at 10:16 AM, Kevin Bullock wrote:
> 
> > # HG changeset patch
> > # User Kevin Bullock <kbullock at ringworld.org>
> > # Date 1336141869 18000
> > # Branch stable
> > # Node ID a5119c4fa009c415ad398d84bc89669aa3ca1f80
> > # Parent  e19cb9f091f89a90afffcc57935b86aac0689437
> > revert: save backup of undeleted files (issue3422)
> > 
> > diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py
> > +++ b/mercurial/cmdutil.py
> > @@ -1528,7 +1528,7 @@ def revert(ui, repo, ctx, parents, *pats
> >             #   make backup if not in target manifest
> >             (modified, revert, remove, True, True),
> >             (added, revert, remove, True, False),
> > -            (removed, undelete, None, False, False),
> > +            (removed, undelete, None, True, False),
> 
> Note that this now creates .orig files on undelete even if the
> forgotten file in the working dir is unchanged from the version being
> reverted to. This is less than ideal, but I couldn't quite figure out
> how to check if the file was changed. repo.dirstate and repo.status
> are of no help here, because they both simply report the file as
> 'R' (removed). Anyone have ideas on this?

Not super-excited about making duplicate files. But comparing files is
untracked files turns out to not be all that painful:

$ hg forget README
$ hg dbsh
loaded repo : /home/mpm/hg
using source: /home/mpm/hg/mercurial
>>> a = repo['.']['README']
>>> a
<filectx README at 6a7ce975edd6>
>>> b = repo[None]['README']
>>> a.cmp(b)
False
>>> 'README' in repo[None]
False

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list