After doing a bzr mv --auto a deleted file and a new file have been incorrectly picked up as a moved file, and now show up as renamed under bzr status. How can I change this so that the new file is marked as new again (and the deleted as deleted)?
Given:
$ bzr status
renamed:
a => b
you would need to do:
$ bzr mv b a
b => a
~$ mv a b
$ bzr add b
adding b
$ bzr status
removed:
a
added:
b
You can do a simple revert on the file.
Note that this will revert the rename, but also the modification you made inside, so be careful !
Related
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.
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.
Lets say I have 6 files that I'm working on and I only want to shelve 3 of the 6
Is this correct bzr shelve file1.txt file2.txt file5.txt -m "this is the thing"
How do I unshelve it later?
How do I delete the shelve if I do not need it?
Is this correct bzr shelve file1.txt file2.txt file5.txt -m "this is the thing"
Yes, that's correct. It will shelve the changes to the specified files and directories only. Furthermore:
If there are no changes in those, it will do nothing, just tell you No changes to shelve.
To skip the interactive questions for every change in those files, the --all flag is convenient, for example: bzr shelve file1.txt file2.txt file5.txt -m "this is the thing" --all
How do I unshelve it later?
Find the id of the shelf with bzr shelve --list. Then unshelve with bzr unshelve THE_ID. Btw, if you don't specify an id, then bzr unshelve will unshelve the most recent shelf.
How do I delete the shelve if I do not need it?
Using the --delete-only flag of bzr unshelve, for example:
bzr unshelve --delete-only THE_ID
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
I'm wonder if there is anyway to just export files that have changed in specific revision.
e.g : I have branch with three files :
file.php
file.js
file.css
Just file.js has changed in last commit.
How to use export command to just export changed file (file.js) and prevent exporting others.
Is there any Plugin or external 3rdParty ?
Using bzr export you can specify a single directory to export, but not individual files.
As an alternative, you can get the contents of a file at some past revision like this:
bzr cat -r REV path/to/file > file.rREV
You can get the list of changed files at some past revision with the one-liner:
bzr diff -c REV | grep ^===
To wrap it up, here's a complete one-liner that does just what you asked for: export just the modified files of some specific revision REV into a directory called EX:
bzr diff -cREV | grep '^=== modified file ' | sed -e "s/[^']*//" -e "s/'//g" |\
while read fname; do echo $fname; mkdir -p EX/"$(dirname "$fname")";\
bzr cat -rREV "$fname" > EX/"$fname"; done
It loops over the modified files in revision REV, prepares the export directory EX with all parent directories needed to save the file preserving the path, and finally gets the file with bzr cat and writes it at the correct relative path inside EX.