Show mod/add/del files in a merge changeset

Hua Zheng (Geoffrey) geoffreyzheng at yahoo.com
Wed Feb 11 12:59:32 CST 2009


Thanks for the response. For a merge, repo.status give me files from the other parent on top of the merge itself.

0 - 1 - 3
 \- 2 -/

Suppose 1 changes file1, 2 changes file2, and 3 changes file3. repo.status(1, 3)[0] is [file2, file3], and repo.status(2, 3)[0] is [file1, file3].

Technically it's correct, but I want to know files that are changed/added/deleted only in 3. I have the following code that seems to work:

        def hasFile(ctx, f):
            try:
                ctx.filectx(f)
                return True
            except revlog.LookupError:
                return False
        mods = []
        adds = []
        dels = []
        for f in ctx.files():
            '''  Ctx Parents
            Mod  Y   Y
            Add  Y   N
            Del  N   Y          
            '''
            mine = hasFile(ctx, f)
            theirs = hasFile(ctx.parents()[0], f) and hasFile(ctx.parents()[1], f)
            if mine and theirs:
                mods.append(f)
            elif mine:
                adds.append(f)
            elif theirs:
                dels.append(f)

But I wonder if there's something already like this in hg code.



________________________________
From: Micah Ransdell <mjr578 at gmail.com>
To: huazheng <geoffreyzheng at yahoo.com>
Cc: mercurial at selenic.com
Sent: Wednesday, February 11, 2009 12:38:38 PM
Subject: Re: Show mod/add/del files in a merge changeset

There is an example that I have used in cmdutil -> changeset_templater, in the _show function. Pretty much you are looking at the repository status between the parent and changectx you are looking at. You get back three lists, modified, added, and deleted files.

..snip...
        files = []
        def getfiles():
            if not files:
                files[:] = self.repo.status(
                    log.parents(changenode)[0], changenode)[:3]
            return files
...snip...

Hope that helps.

Micah


On Mon, Feb 9, 2009 at 7:25 PM, huazheng <geoffreyzheng at yahoo.com> wrote:


Hi there. Is there a command option, or an API function to distinguish
modified, added, and deleted files in a merge changeset?

I'm sure I can figure it out from changectx.files() and parents, but it
seems like a pretty basic thing that someone would have already done it.

TortoiseHg seems to implement it in changeset.ChangeSet.diff_generator.

Thanks!
--
View this message in context: http://www.nabble.com/Show-mod-add-del-files-in-a-merge-changeset-tp21927032p21927032.html
Sent from the Mercurial mailing list archive at Nabble.com.

_______________________________________________
Mercurial mailing list
Mercurial at selenic.com
http://selenic.com/mailman/listinfo/mercurial


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial/attachments/20090211/6b919216/attachment.htm 


More information about the Mercurial mailing list