See files affected by previous commits in bzr - bazaar

When using bazaar you can easily see uncommited changes with the bzr diff command. You can also see changes since a specific revision, or use bzr status to see the filenames only.
bzr diff -c 2169
bzr status -c 2169
Instead of looking for a specific commit number, using bzr log is there a simple way to look at all changes in a number of commits, the previous 2 commits for example?

You can view log of the previous 2 commits like this:
bzr log -l2
You can view all the logs from a specific revision until the end with:
bzr log -r2169..
You can of course specify an end range as well.
You might also find useful some interesting revision specifiers for example last:N. You can view the diff or status of the last 2 revisions with:
bzr diff -rlast:3
bzr status -rlast:3
You can read more about revision specifiers in bzr help revisionspec.
Let me know if you were looking for something else.

You can do this using verbose. With --verbose (-v), bzr log will print all affected paths.
To get the files affected only in last commit, use
bzr log --verbose -l1
To get the files affected is level of commits, use
bzr log --verbose -l<level-of-commit>
To get the files affected in specific commit
bzr log --verbose -r<rev-of-commit>
you can use either flag --verbose or --v

Related

How to retrieve branch whose tree has been removed and deleted?

I have a bazaar repository holding several branches. I recently removed one of the trees with bzr remove-tree path/to/branch followed by rm -r path/to/branch. Now if I understand correctly, the repository should still hold the branch history, since I never did bzr remove-branch. However, I can't figure out how to retrieve the branch to continue working on it. Can someone help?
You can use bzr heads --dead to see the heads (= most recent revisions) of deleted branches, including their global revision ids.
You can then do:
bzr branch -r REVISION_ID REPO_DIR BRANCH_DIR
Here, REVISION_ID is the id of the head that you want to restore, REPO_DIR is the directory that holds the repository, and BRANCH_DIR is the directory where you want the branch to be stored.
Edit: If the above doesn't work for some reason, you can also do:
bzr init BRANCH_DIR
cd BRANCH_DIR
bzr pull -r REVISION_ID .
BRANCH_DIR must be underneath the repository directory, of course.

how to revert changes only for one file with git-svn?

I've corrupted one file and I'd like to revert it back. My project is using git-svn.
So how can I revert this one particular file? Or even better if I could view whole change set of this file.
Detailed steps would be appreciated.
git revert SHA1_OF_FAULTY_COMMIT
add back the changes but don't commit
git cherry-pick -n SHA1_OF_FAULTY_COMMIT
Modify what needs to be modified, e.g.
git reset HEAD file_that_should_not_have_been_modified
Commit
git commit -m "to_be_merged"
Squash the two commits, put a meaningful comment.
git rebase -i HEAD~2
Review your changes, it should only contains the modification on the single file you:
git show
You can now push that to svn
git svn dcommit

Converting bzr's triple revision numbers

bzr annotate gives revision numbers of the form a.b.c where a is the revision that was branched off; for our workflow it's more interesting to know in which revision this changed was merged back into the current repo. Can I get bzr to tell me this info?
You can use revision prefix mainline:, see bzr help revisionspec for details.
For example,
bzr revno -r 1.2.3
prints 1.2.3, but
bzr revno -r mainline:1.2.3
prints revision number for revision that merged 1.2.3.

How to undo bzr add

Sometimes I type bzr add and don't notice that I am not in the root of the branch but an ignored sub-folder. This then adds all files in that folders - often it is a build folder, with lots of files. Hence the question: how to undo a bzr add.
There is built-in way without need of xargs: bzr remove --new --keep
This answer is shamelessly stolen from here to make it more accessible (to me as well).
This will undo an erroneous bzr add:
bzr added -0 | xargs -0 bzr rm --keep

git svn fetch does not fetch a Subversion commit message modified after initial clone

I cloned a large SVN repository (nearly 8,000 commits) and it seems to be OK.
Since then, the commit messages of about 20 Subversion commit messages have been changed to correct a typo. This was done legitimately. However, git svn fetch does not pull the updated commit messages. It still displays the old outdated commit message.
Is there a way to fix this? Preferably in a clean way and without hacking my local git repository too much?
I've tried git svn fetch -r 1234 (where 1234 is a known revision number). But no luck.
from http://git-scm.com/docs/git-svn:
git svn reset
Undoes the effects of fetch back to the specified revision. This allows
you to re-fetch an SVN revision.
[...]
Follow reset with a fetch and then git
reset or git rebase to move local
branches onto the new tree.
So in your case, if revision 1234 is the first one that had its commit message changed, you would do
$ git svn reset -p 1234
$ git svn fetch
If anything is different, including the commit message, then the new commit is a totally different object, with a new SHA1, so as it says, you'll need to rebase any branches you might have onto the appropriate rewritten commit.