简体   繁体   中英

How to synchronize a project with svn repository after deletion of local files in xcode?

I have added some files to svn repository during initial revisions. But now, those files are gone and that was done by removing them directly in xcode 4.2. But they still exist in svn and I want to update the svn repository to my local project version. I know that I could use svn rm command to delete every file but the idea about that makes me annoyed because I will need to find, pick and delete every file manually. Any less painful solutions?

ps. also, any advices on how to check the difference between local project and svn repository are welcome. Currently, if I'm performing update then xcode is sayging that my local copy is up to date, so I have even manually to find the missing files.

If you don't mind going into the command line, you could run svn status and find the files you deleted. These will start with the exclamation point. Here's an example from a repository I just futzed with:

$ svn status
!       subversion/pre-commit-kitchen-sink-hook.html
!       subversion/svn-watch.html
!       bludgen/bludgen.html
!       duplicate-properties-files/fixup.html
!       cvstools/group.html
!       cvstools/find-branch-usage.html
A       cvstools/someprogram.py
M       cvstools/find-branch-usage.pl
!       cvstools/scramble.html
M       cvstools/findNames.pl

Now, all you need to do is find the names of the programs. If you have no spaces in the names of your programs, a simply [awk] script should be sufficient:

$ svn status | awk '/^!/ {print $2}'
subversion/pre-commit-kitchen-sink-hook.html
subversion/svn-watch.html
bludgen/bludgen.html
duplicate-properties-files/fixup.html
cvstools/group.html
cvstools/find-branch-usage.html
cvstools/scramble.html

Now that you have a list of programs, you could run that through xargs into a svn rm command:

$ svn status | awk '/^!/ {print $2}' | xargs svn rm
D         subversion/pre-commit-kitchen-sink-hook.html
D         subversion/svn-watch.html
D         bludgen/bludgen.html
D         duplicate-properties-files/fixup.html
D         cvstools/group.html
D         cvstools/find-branch-usage.html
D         cvstools/scramble.html

Fortunately, Macs come with the Subversion command line client. This will delete the files you manually removed via Subversion and will allow you to commit your changes. You'll be able to then update your copy of the repository with the latest code. There might be some conflicts (you deleted a file that someone in a later revision updated), but these should be pretty manageable.

You can use svn diff to look for differences between your current working copy and the HEAD revision of the repository. Unfortunately, the --summarize parameter only works if you do a repository to repository difference. However, you can filter out the files that are different by using grep to look for lines that start with Index: :

$ svn diff -rHEAD | grep "^Index:"
Index: windows-tools/which.pl
Index: subversion/pre-commit
Index: subversion/README
Index: subversion/control.ini
Index: subversion/pre-commit-kitchen-sink-hook.html
Index: subversion/svn-watch.html
Index: cvstools/findNames.pl
Index: cvstools/group.html
Index: cvstools/find-branch-usage.html
Index: cvstools/someprogram.py
Index: cvstools/find-branch-usage.pl
Index: cvstools/scramble.html
Index: bludgen/bludgen.html
Index: duplicate-properties-files/fixup.html

The only real issue is whether the Subversion client that XCode uses is compatible with the Subversion command line client. For example, the VisualStudio Subversion client uses _svn as the name of the Subversion information directories while the command line client uses .svn .

I believe that the XCode Subversion client is compatible with the revision 1.6.x of the Subversion command line client (and even earlier revisions all the way back to 1.4), but not with the latest 1.7 version of Subversion.

If you haven't tampered with your Mac's Subversion installation, it should be fine.

The only way that I'm aware of to do what you are trying to is:

  • Goto File->Source Control->Repositories
  • Select Your repository
  • Click Commit
  • Click Flat view icon (on the left)
  • Any missing files are shown as !, and you can right click to discard the change.

EDIT - Sorry, I misunderstood the problem. This may help you to find missing files, but wont help you commit. I was thinking you were trying to restore the deletions, not commit them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM