"staging area"?

Masklinn masklinn at masklinn.net
Sun Jun 20 18:34:01 UTC 2010


On 2010-06-20, at 20:17 , Daniel Carrera wrote:
> 
> I have a question: What is the objective of remove a file from the
> repository? What does it accomplish?
It marks the file as deleted in the history (for mercurial), otherwise the file is in a "missing" state: it doesn't exist anymore in your working copy, but as far as mercurial is concerned it's still there:

> touch a                                                                                                                                                                                       > hg add a                                                                                                                                                                                            > hg ci -m 'added a'                                                                                                                                                                                  
> hg st                                                                                                                                                                                              
> rm a                                                                                                                                                                                                
remove a? y 
> hg st                                                                                                                                                                                               ! a
> hg rm a                                                                                                                                                                                             > hg st                                                                                                                                                                                               
R a

`! a` translates into "this file exists, but I can't find it anymore" whereas `R a` translates into "you have removed this file from the repository", you can see the difference when you try to commit:

> hg st                                                                                                                                                                                               ! a
> hg ci -m "removed a?"                                                                                                                                                                               nothing changed
> hg st                                                                                                                                                                                               ! a
> hg rm -A                                                                                                                                                                                            removing a
> hg ci -m "removed a?"                                                                                                                                                                               > hg st

As you can see, if you commit when the file is in a "missing" state (!, assuming you have other changes to commit) a coworker seeing the commited revision will *still* have the file because as far as mercurial is concerned it's still there. If you commit when the file is in R state, then from this revision onwards (and unless you reintroduce it) the file doesn't exist anymore in the repository.


More information about the Mercurial mailing list