About Me

JMX, SNMP, Java, etc...

Daniel Fuchs blogs on JMX, SNMP, Java, etc...

The views expressed in this blog are my own, and I do not speak for my employer.
All | Personal | Sun
tags: blogging firewall hg java jconsole jmx jvm management mbean mercurial monitoring opendmk openjdk opensource rmi snmp ssl

Table Of Contents (list all entries)

« Java 5, premain, RMI... | Main | Saved by ZFS while... »
20080916 Tuesday September 16, 2008
Mercurial: listing files modified in incoming changesets, and guessing conflicts...

Yesterday my colleague Shanliang asked me whether there was a way to see which files had been modified in the changesets that would be pulled in by 'hg pull', and whether they would conflicts with the files currently being edited in his workspace.

After poking here and there with 'hg help', and with the help of Luis-Miguel, we finally came up with this solution:

hglistin
#!/usr/bin/bash
#
# lists the files that have been modified in the changesets that will
# be imported by 'hg pull'
#
# syntax: hglistin [parent-path]
#

hg in -v  "$@" | grep 'files:' | sed 's,files:,,' \
   | sed 's,^[ ]*,,' | tr ' ' '\012' | sort | uniq

hgconflicts
#!/usr/bin/bash
#
# lists the files that have been modified in the changesets that will
# be imported by 'hg pull', and that are also edited in this workspace.
#
# syntax: hgconflicts [parent-path]
#

list1() {
  hg in -v  "$@" | grep 'files:' | sed 's,files:,,' \
    | sed 's,^[ ]*,,' | tr ' ' '\012' | sort | uniq
}

list2() {
  hg status -nmr | sort | uniq
}

(list1  "$@" ; list2 ) | sort | uniq -d

The result of 'hgconflicts' is valid only when you have nothing committed to push (that is, when 'hg out' reports nothing).

Well, there's probably better ways to do that, and I promise, one of these days I'll take the time to figure out how to do the same thing in python ;-).
Hope you'll find it useful nonetheless!

Cheers,

-- daniel

Tags:
Posted by dfuchs ( Sep 16 2008, 11:17:46 AM CEST ) Permalink Comments [2]

Trackback URL: http://blogs.sun.com/jmxetc/entry/mercurial_listing_files_modified_in
Comments:

Have you tried using --template to just get the files? e.g. something like

hg in --quiet --template '{files}\n' | sort | uniq

Or is that getting you the same list?

-kto

Posted by 192.18.43.225 on September 19, 2008 at 10:25 PM CEST #

Hi Kelly,

Yes, this works, but you still need the 'tr' bit:

hg in --quiet --template '{files}\n' | tr ' ' '\012'| sort | uniq

I didn't know how the --template option worked. This is good to remember, thanks!

-- daniel

Posted by daniel on September 22, 2008 at 04:38 PM CEST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed
[Table Of Contents]

The views expressed in this blog are my own Weblog, and I do not speak for my employer.

Calendar

RSS Feeds

DFuchs on DZone

Search

Links

Lookup RFC

Planet JMX

From Grenoble

Navigation

Referers