HowTo read all diffs by certain user in bzr

hingo's picture

In the series of shell one liners, today I wanted to stalk someone, so I came up with this one liner to show all diffs ever created by a specific user in a give bzr repository:

bzr log -n0 | grep -B 1 henrik | grep revno | grep -v merge | \
awk -F'revno: ' '{print $2}' | while read revno; do echo; \
echo '#####################################################################'; \
echo revno: $revno; bzr diff -c$revno; done 

bzr log -n0 prints out the full log history of your repo. It may look something like this:

    ------------------------------------------------------------
    revno: 2441.2.16 [merge]
    committer: Henrik Ingo 
    branch nick: drizzle-json_server-keyvalue
    timestamp: Sun 2012-05-20 17:21:22 +0300
    message:
      Merging the documentation for 0.2.
        ------------------------------------------------------------
        revno: 2441.4.3
        committer: Henrik Ingo 
        branch nick: drizzle-json_server-doc
        timestamp: Sat 2012-05-19 19:26:37 +0300
        message:
          More JSON Server documentation:
          
          Revert back from using sphinxcontrib.httpdomain to document JSON Server
          HTTP API. While this was nice, we don't want to introduce a dependency
          to download additional sphinx modules to all build slaves and devs.
          Instead we simply use .. code-block:: none
          
          Add documentation on the /sql API.
          
          Add more intro and a list of parameters for the /json API.

As you can see, the committer name is just below the revno. We want to extract the revno, so we do it like this:

grep -B 1 henrik | grep revno | grep -v merge | awk -F'revno: ' '{print $2}' 

This says:
* Print one line above each occurence of "henrik"
* Print only the lines including "revno" (This excludes the "committer" lines)
* Do not print lines including the word "merge" (only real commits, not merges)
* Use awk to extract the revno number from the rest of the line

We then use the while loop to run bzr diff -c for each revno.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Use [fn]...[/fn] (or <fn>...</fn>) to insert automatically numbered footnotes.
  • Allowed HTML tags: <h1> <h2> <h3> <h4> <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <sup> <div> <blockquote> <pre> <img>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically. (Better URL filter.)

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.