Check out lastest development version - bazaar

What is the bzr equivalent of
cd ..
rm -fr widelands
git clone url/to/widelands.git
?
After searching for hours yesterday, how to get rid of local changes, I rage quit and did:
$ cd ..
$ rm -fr widelands
$ LANG=C bzr branch lp:widelands # LANG because of the well known not yet fixed bug
Branched 8986 revisions.
$ cd widelands
$ LANG=C bzr checkout
bzr: ERROR: A control directory already exists: "file:///[...]/widelands/".
???
$ LANG=C bzr remove-tree .
bzr: ERROR: Working tree "[...]/widelands/" has uncommitted changes (See bzr status).
????????????
$ bzr status
removed:
[list of thousands of files]
?????????????????????????????????
$ ls -lA
total 2
drwxr-xr-x 6 root root 2048 Feb 21 15:43 .bzr
According to this page https://wl.widelands.org/wiki/Building%20Widelands/, the steps to get the current development version of widelands is:
bzr branch lp:widelands
cd widelands
bzr checkout
[further steps to compile etc]
And that's basicly, what I tried above.
/edit: I now successfully tried LANG=C bzr revert --no-backup which didn't help me in the old repository before I rage quit, but the question still applies.

If what you're trying to do is remove the existing clone and create a new one, then the equivalent in bzr is:
$ cd ..
$ rm -fr widelands
$ bzr branch lp:widelands widelands
If you're trying to get rid of pending changes in the current control directory (i.e. git reset --hard), then bzr revert is what you're after.

Related

Get SVN URL of removed git-svn file

I would like to track a removed file as far back in history as possible, while using git-svn on a subdirectory of the SVN repository.
Using git log --full-history -- path/to/removed_file.py, I can get see the history starting with the time the file was moved into the subdirectory I checked out using git-svn.
I can see which SVN revision that was in the git-svn commit message postfix, so I would now like to use svn log <full_url>#revision to see the rest of the history.
I know that I could use git svn info --url path/to/existing_file.py to see the required full SVN url, but what is a quick (ideally scriptable) way of getting the SVN URL of a file that is no longer in the repository?
To git, it doesn't matter much that a file foo/bar.py is removed in HEAD — as long as you have it in history, you can view every past version of it.
For clarity of concreteness, I'll take this git-svn repo from the LLVM project as an example. There, the file docs/todo.rst has been deleted in svn revision 308987, git commit fb572868… and is absent in master.
Let's first init a local clone.
$ git clone https://github.com/llvm-mirror/lnt && cd lnt
Cloning into 'lnt'...
...
$ git svn init https://llvm.org/svn/llvm-project/lnt/trunk
$ git update-ref refs/remotes/git-svn refs/remotes/origin/master
$
$ #-- ask svn info of anything to check setup and/or force laziness
$ git svn info --url README.md
Rebuilding .git/svn/refs/remotes/git-svn/.rev_map.91177308-0d34-0410-b5e6-96231b3b80d8 ...
r154126 = 3c3062527ac17b5fac440c55a3e1510d0ab8c9d9
r154135 = 82a95d29ac7d25c355fbd0898a44dc3e71a75fd8
...
r374687 = 446f9a3b651086e87684d643705273ef78045279
r374824 = 8c57bba3687ada10de5653ae46c537e957525bdb
Done rebuilding .git/svn/refs/remotes/git-svn/.rev_map.91177308-0d34-0410-b5e6-96231b3b80d8
https://llvm.org/svn/llvm-project/lnt/trunk/README.md
So it gives back the README.md URL as expected. Now let's try the case of a deleted file:
$ git svn info --url docs/todo.rst
svn: 'docs/todo.rst' is not under version control
Fails, just like you say. man git-svn says that info Does not currently support a -r/--revision argument.
OK then, let's try emulating what it does, first by hand.
https://llvm.org/svn/llvm-project/lnt/trunk/README.md?r=374824 — this is the URL for given file at given revision.
Our vanished docs/todo.rst is available at https://llvm.org/svn/llvm-project/lnt/trunk/docs/todo.rst?p=308986 Notice the decrement: per git show fb572868 | grep git-svn-id, docs/todo.rst is already deleted in r308987 — so we request r308986.
On to scripting it... rather simple job.
git-svn-oldinfo () {
relfname="$1"
git log -n1 -- "$relfname" \
| awk '/git-svn-id:/ {sub(/#/, " ", $2); print $2}' \
| { read baseurl rev; echo "${baseurl}/${relfname}?p=$((rev-1))"; }
}
#-- test:
$ git-svn-oldinfo docs/todo.rst
https://llvm.org/svn/llvm-project/lnt/trunk/docs/todo.rst?p=308986
Quick-n-dirty but tested — you're welcome to adjust & extend as needed.
Edit
Despite git log being a "porcelain" command (i.e. not really designed for scripting), it's quite possible to parse out the filenames from it too, if you're to query by globs like **/removed_file.py:
git-svn-oldinfo-glob () {
fileglob="$1"
git log -n1 --stat --format=oneline -- "$fileglob" \
| { read commit msg; \
read fullname _remainder_dummy; \
git cat-file -p $commit \
| tail -n1 \
| awk '/git-svn-id:/ {sub(/#/, " ", $2); print $2}' \
| { read baseurl rev; echo "${baseurl}/${fullname}?p=$((rev-1))"; } \
}
}
#-- test:
$ git-svn-oldinfo-glob '**/todo.rst'
https://llvm.org/svn/llvm-project/lnt/trunk/docs/todo.rst?p=308986
Take it with a grain of salt: it'll probably break in hilarious ways or output garbage if the glob matches multiple files, non-removed files, files with whitespace in the name, etc.
As always, check out man git-log and customize as needed.

Add git submodule using a specific commit number

I'm using git submodule commands to add this FSM repo in my project. I want to checkout a specific release commit. By default the master branch is checked out.
After adding the git repo, when I run
$ git submodule
It gives
d1b66d66cfa95f238a7498465908a262f4b2326a directory_path/fsmlite
The commit number here belongs to a master branch commit. How can I checkout another commit instead, using its commit number?
There might be some other way to do this, but I got the desired commit by
$ cd directory_path/fsmlite
$ git checkout v0.7.1 (this is the branch I wanted to point to)
$ git submodule update
$ cd parent_dir
$ git submodule
+de19ea0a71cb6082fe9311694a27e8f0cc2f972a directory_path/fsmlite (v0.7.1)
which is the specific commit number I wanted

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.

Enabling SVN tracking in a git clone of a git-svn clone that didn't start at revision 1?

Suppose I have a git svn clone that I created like this:
$ mkdir foo
$ cd foo
$ git svn clone -s -r 100:HEAD http://svn.example.com/project
and then I git clone it like this:
$ cd ..
$ git clone foo bar
$ cd bar
So now bar has foo as its origin.
How do I make bar track the original SVN server? The git-svn man page provides an example of the case where the original git svn clone includes the full revision history, but this doesn't seem to cover the case that the original git svn clone doesn't start from r1. When I try the various things I see described, what git svn fetch does is always start a disconnected history starting at r1.

How to commit a Git repo to an empty repo SVN server?

I have setup an empty svn on a server and I have been working on locally making commits along the way. Now I wish to commit my repo to an svn server. For this I tried:
git-svn checkout http://remote.svn.server.com
git-svn dcommit
Git complains that:
Use of uninitialized value in concatenation (.) or string at /usr/bin/git-svn line 411.
Committing to ...
Unable to determine upstream SVN information from HEAD history
Since I started on my local computer first, and the repo online is empty, I can't find any info on how to make this work.
I needed something like this recently and the process is relatively straightforward.
There's good tutorial by Brandon Dimcheff, "Commit a linear git history to subversion" (replaces old broken link), which these steps are based on.
As of Git version 1.6.3 these are the steps:
$ svnadmin create svn_repository
$ svn mkdir -m "Initial setup" file:///full/path/to/svn_repository/trunk
$ mkdir gitrepo && cd gitrepo
$ git init
$ echo 'Hello from Git' > file.txt
$ git add file.txt
$ git commit -m "Hello from Git"
$ git svn init --trunk=trunk file:///full/path/to/svn_repository/
$ git svn fetch
$ git branch -a # Lists remotes/trunk
$ git rebase --onto remotes/trunk --root master
# => Applying: Hello from Git etc.
$ git svn dcommit
# => Committing to ... Committed r2 ... etc
You can do a svn checkout of svn_repository now and see your Git repo.
Here is what I would do:
git-svn clone http://remote.svn.server.com otherdir
Then in other dir pull the changes locally from your previous dir. Then you should have a git repo that is "connected" via git-svn and you should be able to use dcommit on it.
This might also be a useful read.