Converting bzr's triple revision numbers - bazaar

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.

Related

KDE SVN2GIT "WARN: Branch ... in repository ... doesn't exist at revision ... -- did you resume from the wrong revision?" Can't continue

I'm trying to migrate an 11GB SVN repo with over than 24k revisions inside to a single GIT repository.
I did a single file dump of the SVN using svnrdump command and load it into my local SVN server, placed on my MacBook machine.
I downloaded the svn2git from the https://github.com/svn-all-fast-export/svn2git repository.
Due to differences in the way how SVN and GIT handle tags, I used a merged-branches-tags.rules from the svn2git sample directory, which look like this (I've removed comments):
create repository myproject
end repository
match /trunk/
repository myproject
branch master
end match
match /(branches|tags)/([^/]+)/
repository myproject
branch \2
end match
Then I used a docker image solution as described in the documentation (in my console it was a single line. I've did split it to clarify what I was doing):
docker run --rm -it \
-v /Users/me/work/SVN/dest:/workdir \
-v /Users/me/work/svnServer/repositories/my_svn_repo:/tmp/svn \
-v /Users/me/work/SVN/svn2git/samples:/tmp/conf \
svn2git /usr/local/svn2git/svn-all-fast-export \
--rules /tmp/conf/merged-branches-tags.rules \
--add-metadata --svn-branches --debug-rules --svn-ignore --empty-dirs \
/tmp/svn/
During the first try I got an error between revisions 12600 and 126001:
Exporting revision 12601 /tags/7.0M0p0000 was copied from /tags rev 12600
rev 12601 /tags/7.0M0p0000/ matched rule: "/tmp/conf/merged-branches-tags.rules:28 /(branches|tags)/([^/]+++++
)/" exporting.
.WARN: SVN reports a "copy from" # 12601 from /tags # 12600 but no matching rules found! Ignoring copy, treating as a modification
WARN: Transaction: "7.0M0p0000" is not a known branch in repository "myproject"
Going to create it automatically
add/change dir ( /tags/7.0M0p0000 -> "7.0M0p0000" "" )
+++++
WARN: Branch "7.0M0p0000" in repository "myproject" doesn't exist at revision 12601 -- did you resume from the wrong revision?
Failed to write to process: Process crashed for repository myproject
6223345 modifications from SVN /tags/7.0M0p0000/ to myproject/7.0M0p0000%
I've check it and in the rev 12601 there there is a new tag named as "7.0M0p0000", which I'm going to import as a branch and which wasn't in the repo in rev 12600.
Do you have any ideas what can I do to fix that and continue my migration?
Any help will be really appreciated.
After a further investigation, it turns out that the mentioned "7.0M0p0000" tag was created in the rev 12601 as a copy of all the tags from rev 12600.
I've found it in the dump file, created using this command:
svnrdump dump -r 12600:12601 --incremental http://xxx.xxx.xxx.xxx/svn/my_repo > my_repo.dump
There was an entry:
Revision-number: 12601
...
Node-path: tags/7.0M0p0000
Node-kind: dir
Node-action: add
Node-copyfrom-rev: 12600
Node-copyfrom-path: tags
It seems that KDE's svn2git is unable to deal with such cases (which was probably done by mistake).
The only solution I found was completely skip this tag by adding a match to my merged-branches-tags.rules file (order of match expressions is important):
match /tags/7.0M0p0000/
min revision 12600
max revision 12606
end match
...
match /(branches|tags)/([^/]+)/
repository myproject
branch \2
end match

Get svnversion with git-svn

with git svn I can use a svn repository with git. In svn, I can get version of revision with
svnversion
how I can get the version of svn revision with git svn?
git svn info | grep '^Revision: ' | cut -c 11-
git svn info displays some information including the current revision
grep '^Revision: ' extracts from this the line where the current revision is mentioned
cut -c 11- extracts the actual revision number from it by cutting off the first 10 characters which are Revision:
The #Vampire answer is pretty good, I'd just like to include just one more command, in case you want to get the revision of a specific commit, instead the last one of the repository:
git svn log
This command will list all the commits that you have into the SVN repository, giving the SVN revision, author, timestamp, lines edited, and the commit message.

See files affected by previous commits in bzr

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

bzr how to shelve?

according to the documentation I have questions
http://doc.bazaar.canonical.com/beta/en/user-reference/shelve-help.html
I can shelve by going bzr shelve
Can I name that shelve set as I see it gets an ID? eg bzr shelve "this is my first attempt"
how do I view all shelve sets?
How do I view specific changes to a specific shelve set
Are shelve sets relative to the repository that I am in?
First, let's create a shared repository and grab a sample branch to play with:
$ bzr init-repo /tmp/shared-repo
Shared repository with trees (format: 2a)
Location:
shared repository: /tmp/shared-repo
$ cd /tmp/shared-repo
$ bzr branch lp:~bzrbook/bzrbook-examples/shelving
Branched 6 revisions.
$ cd shelving
Your questions:
Can I name that shelve set as I see it gets an ID? eg bzr shelve "this is my first attempt"
Yes, using the -m flag, for example:
$ date >> menu.txt
$ bzr shelve -m 'menu change' --all
Selected changes:
M menu.txt
Changes shelved with id "1".
how do I view all shelve sets?
Using the --list flag, for example:
$ bzr shelve --list
1: menu change
Now you can see that giving a name to the shelf worked. If we hadn't given a name:
$ bzr rm guests.txt
deleted guests.txt
$ bzr shelve --all
Selected changes:
+N guests.txt
Changes shelved with id "2".
$ bzr shelve --list
2: <no message>
1: menu change
Btw, when you have shelves, the bzr status command tells you about them, and how to list:
$ bzr st
2 shelves exist. See "bzr shelve --list" for details.
How do I view specific changes to a specific shelve set
Using bzr unshelve --preview, for example:
$ bzr unshelve --preview 1
Using changes with id "1".
Message: menu change
M menu.txt
=== modified file 'menu.txt'
--- a/menu.txt 2014-04-11 05:34:17 +0000
+++ b/menu.txt 2014-04-11 05:37:55 +0000
## -16,3 +16,4 ##
Mixed burrito
Onion soup
Tacoz
+Fri Apr 11 07:34:13 CEST 2014
Are shelve sets relative to the repository that I am in?
Shelve sets are saved in your working tree. They are not part of the repository, in other words they are not version controlled. If you delete the working directory of the branch where you created your shelves, they will be lost. This is mentioned in the first paragraph of the Description in bzr shelve -h and the link you included.

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.