Finding a change you made long ago

Wednesday, April 28, 2010 10 Comments

It *must* has happened to you: a new bug or issue shows up and then a bell rings: you know you wrote some code long ago (like two or three months ago) that had something to do with it. But... where's the code? And even more important: why did you change it?

Ok, let's go: you all know Plastic SCM has a query system. Yes, you can go to the command line and type "cm find" and then you'll be able to start finding revisions, branches, labels, merges... everything. If you're a hardcore CLI hacker then you'll probably enjoy it, but let's face it... it's 2010 and well, we didn't yet step on Mars as the Odyssey said but it doesn't mean we've to continue using tools from the 70's and 80's...

So, take a look at the Plastic GUI, to the changesets view, for instance, and you'll find there a very familiar button: 'advanced'. Click on it and you'll discover that the changeset's view is actually running a query, something like "find changeset where date > '3/29/2010' on repository 'codice@localhost:6060'".



Let's use it to find the changes we're looking for: what about trying to find the revisions I've done in the last 3 months or so? It will translate into something like "find revs where date > '1/29/2010' and owner='me'" (Note: you can use 'me' instead of 'your-name', small trick).




Now you've a good list of 'candidates': all the revisions you've done during the last months. Easy. But, how to find the one you're looking for? You remember it was under src\client\basecommands directory, just that... So, use the filter on the view to reduce the potential candidates.



Once the list gets smaller, you can double click each file to see its contents (you know, on the 80's you'd use something like "cm cat" or so, but now there're better ways...) or even better, use CTRL-D (shortcut for differences) to see what you modified on that revision.

It took me one minute to find my change yesterday... hope it helps!

10 comments:

  1. Thanks, I already use this quite often, but what I really miss: search for CHANGES (in files)!

    For example: I know someone changed a line of code somewhere. But when and where? So I have to manually do a CTRL-D (if you're lucky you know the file...) a couple of times, hoping to find the changeset.
    Can this be done easier?

    ReplyDelete
  2. Hi André,

    Do you mean you know how your line looks like and you'd like to search on all files looking for some specific code? Something like a code search or so?

    ReplyDelete
  3. Hi Pablo,

    Yes I meant a code search, especially the changed lines of code.

    Btw, is there also a graphical annotate/blame viewer? So something like CTRL-D but then with which lines is changed in which branch/changeset/user?

    ReplyDelete
  4. Hi André,

    Ok, code search is something we plan to do, indexing the code and running a search on it. It's pretty doable to be honest. Easy. But, what do you mean by "especially changed code"?

    About the annotate: you know you've the cm blame command from the CLI, and there's a viewer built-in if you're a IntelliJ user BUT there's not yet a viewer on the GUI (and again, you just hit the jackpot because we expect to have one before the end of this SPRINT, in one week).

    ReplyDelete
  5. Pablo, Thanks for your response.
    Such a feature would be very nice.
    What I meant are 2 search options:
    - search in code (whole repository, directory, branch, etc?)
    - search only changed lines of code (so not complete code, only modified ones)

    Annotate/blame in GUI within 2 weeks would be very nice!

    ReplyDelete
  6. Hi,

    About the 'search' we've the following goal: providing some sort of 'indexing' facility so each commit will get indexed and then easily searchable.

    You know you've the "cm find" functionality which is quite strong, but it doesn't search contents. That's what 'indexing' will provide.

    It could even be implemented as a trigger, but we'll come up with something tightly integrated instead, easier to set up and so on.

    What I find interesting is your suggestion about 'only modified lines'. It should mean you should be able to find matches not on the whole rev code but just on the 'changed code' which would make things easier I guess. I could be done during the indexing phase.

    ReplyDelete
  7. uuh, you're not saying the CLI is retarded and the people who use the command line are backwards .. are you?

    ReplyDelete
  8. @hansen j: did I?

    No, obviously not. We've made a big effort with Plastic SCM to make everything easy and quick from the GUI, but it doesn't mean you can't do it from the CLI.

    Of course you can do things like:

    cm find revs where owner='me' and date > '2010/01/01'

    And then show the contents with:

    cm cat myfile#br:/main#0

    or

    cm diff myfile#br:/main/feature1030#12 myfile#br:/main#14

    Which is perfectly ok.

    But you can do the same from the GUI in half of the time. Well, that's the point of GUIs... :-)

    ReplyDelete
  9. André, take a look at this: http://www.facebook.com/PlasticSCM, new screenshots about the annotate view.

    ReplyDelete
  10. Thanks pablo, that annotate view looks very nice! Really looking forward to that release!

    ReplyDelete