'bzr switch' gives no indication that working copy has changes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Confirmed
|
Medium
|
Unassigned |
Bug Description
I recently faced this issue with using bzr switch with lightweight checkout.
I was working in a lightweight checkout and had some un-checkedin changes. After working on something else for a day I had forgotten about this. To work on another branch I just did a 'bzr switch PATH' and this worked ok and I went ahead and added another set of changes. On doing a diff I realized I had my old changes which were meant to be in another branch as well as new changes. I ended up using 'bzr shelve' interactively to separate my old changes from the new.
IMO at a minimum switch should show a warning so that the user can use shelve immediately or switch back and commit changes. Or maybe a --force option can be supported.
Below is roughly what I did.
[tmp]% mkdir switch-test && cd switch-test
[switch-test]% bzr init mainline
Created a standalone tree (format: 2a)
[switch-test]% cd mainline
[mainline]% echo "hello" > hello.txt && echo world > world.txt
[mainline]% bzr add
adding hello.txt
adding world.txt
[mainline]% bzr ci -m initial
Committing to: /home/parthm/
added hello.txt
added world.txt
Committed revision 1.
[mainline]% cd ..
[switch-test]% bzr init-repo myrepo
Shared repository with trees (format: 2a)
Location:
shared repository: myrepo
[switch-test]% cd myrepo
[myrepo]% bzr branch ../mainline
Branched 1 revision(s).
[myrepo]% bzr branch mainline foo
Branched 1 revision(s).
[myrepo]% bzr branch mainline bar
Branched 1 revision(s).
[myrepo]% bzr checkout --lightweight foo workingcopy
[myrepo]% cd workingcopy
[workingcopy]% bzr info
Lightweight checkout (format: 2a)
Location:
light checkout root: .
checkout of branch: /home/parthm/
shared repository: /home/parthm/
Related branches:
parent branch: /home/parthm/
[workingcopy]% echo "hello again" >> hello.txt
[workingcopy]% bzr switch ../bar
Tree is up to date at revision 1.
Switched to branch: /home/parthm/
[workingcopy]% echo "world again" >> world.txt
[workingcopy]% bzr diff
=== modified file 'hello.txt'
--- hello.txt 2010-05-28 13:37:56 +0000
+++ hello.txt 2010-05-28 13:38:58 +0000
@@ -1,1 +1,2 @@
hello
+hello again
=== modified file 'world.txt'
--- world.txt 2010-05-28 13:37:56 +0000
+++ world.txt 2010-05-28 13:39:22 +0000
@@ -1,1 +1,2 @@
world
+world again
[workingcopy]%
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Parth Malwankar wrote:
> Public bug reported:
>
> I recently faced this issue with using bzr switch with lightweight checkout.
> I was working in a lightweight checkout and had some un-checkedin changes. After working on something else for a day I had forgotten about this. To work on another branch I just did a 'bzr switch PATH' and this worked ok and I went ahead and added another set of changes. On doing a diff I realized I had my old changes which were meant to be in another branch as well as new changes. I ended up using 'bzr shelve' interactively to separate my old changes from the new.
>
> IMO at a minimum switch should show a warning so that the user can use
> shelve immediately or switch back and commit changes. Or maybe a --force
> option can be supported.
>
> Below is roughly what I did.
Switching with uncommitted changes is one of the primary use cases for
switch (oh, here is a simple bug fix, let me put this in a separate
bugfix branch).
That said, notifying the user that there are uncommitted changes is
reasonable.
Also, there is a fairly serious failure mode. Where you have uncommitted
changes in a newly added file. When you go to switch that file will end
up conflicted (changes to a file that don't exist), but you cannot
trivially switch back to the previous branch (because then it will
conflict again, because you have all these conflict markers, etc.)
Separate bug, though.
A warning would be ok, --force would not. Though a user could presumably
configure a setting if they never use the "let me put this in another
branch" case.
John
=:->
-----BEGIN PGP SIGNATURE----- enigmail. mozdev. org/
/2JkACgkQJdeBCY SNAANHlACgki9Ww ivEMZxXtP1wqij7 VWuf uuvh5900w5rlWHn Mk
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAkv
agcAn1nk9k2yYbW
=jHdT
-----END PGP SIGNATURE-----