Add 'repo sync -d' to detach projects from their current topic

The -d flag moves the project back to a detached HEAD state,
matching what is listed in the manifest.  This can be useful to
set a client to something stable (or at least well-known), such as
before a sequence of 'repo download' commands are used to get some
changes for testing.

Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/project.py b/project.py
index 06240b7..d2ec34f 100644
--- a/project.py
+++ b/project.py
@@ -573,7 +573,7 @@
     for file in self.copyfiles:
       file._Copy()
 
-  def Sync_LocalHalf(self):
+  def Sync_LocalHalf(self, detach_head=False):
     """Perform only the local IO portion of the sync process.
        Network access is not required.
 
@@ -594,7 +594,7 @@
 
     branch = self.CurrentBranch
 
-    if branch is None:
+    if branch is None or detach_head:
       # Currently on a detached HEAD.  The user is assumed to
       # not have any local modifications worth worrying about.
       #