Merge "v.io/jiri: set default profiles appropriately."
diff --git a/cmd/jiri/doc.go b/cmd/jiri/doc.go
index bfe847c..a6a93a5 100644
--- a/cmd/jiri/doc.go
+++ b/cmd/jiri/doc.go
@@ -31,8 +31,6 @@
 The jiri flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -58,8 +56,6 @@
 The jiri cl flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -83,8 +79,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -130,8 +124,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -152,8 +144,6 @@
 The jiri cl new flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -181,8 +171,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -252,8 +240,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -276,8 +262,6 @@
 The jiri profile flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -327,8 +311,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile env - Display profile environment variables
 
@@ -364,8 +346,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile install - Install the given profiles
 
@@ -390,8 +370,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -418,8 +396,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile update - Install the latest default version of the given profiles
 
@@ -440,8 +416,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile cleanup - Cleanup the locally installed profiles
 
@@ -471,8 +445,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile available - List the available profiles
 
@@ -487,8 +459,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri project - Manage the jiri projects
 
@@ -506,8 +476,6 @@
 The jiri project flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -527,8 +495,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -548,8 +514,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -573,8 +537,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -595,8 +557,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -615,8 +575,6 @@
 The jiri rebuild flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -640,8 +598,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -663,8 +619,6 @@
    Use color to format output.
  -dir=
    Directory where snapshot are stored.  Defaults to $JIRI_ROOT/.snapshot.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -710,8 +664,6 @@
    Use color to format output.
  -dir=
    Directory where snapshot are stored.  Defaults to $JIRI_ROOT/.snapshot.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -731,8 +683,6 @@
    Use color to format output.
  -dir=
    Directory where snapshot are stored.  Defaults to $JIRI_ROOT/.snapshot.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -759,8 +709,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -804,8 +752,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -831,8 +777,6 @@
 The jiri which flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
diff --git a/cmd/jiri/snapshot.go b/cmd/jiri/snapshot.go
index de89012..437cd81 100644
--- a/cmd/jiri/snapshot.go
+++ b/cmd/jiri/snapshot.go
@@ -153,7 +153,7 @@
 func createSnapshot(jirix *jiri.X, snapshotDir, snapshotFile, label string) error {
 	// Create a snapshot that encodes the current state of master
 	// branches for all local projects.
-	if err := project.CreateSnapshot(jirix, snapshotFile); err != nil {
+	if err := project.CreateSnapshot(jirix, snapshotFile, ""); err != nil {
 		return err
 	}
 
diff --git a/cmd/jiri/update.go b/cmd/jiri/update.go
index f87107d..9dccf97 100644
--- a/cmd/jiri/update.go
+++ b/cmd/jiri/update.go
@@ -57,7 +57,7 @@
 	if err := retry.Function(jirix.Context, updateFn, retry.AttemptsOpt(attemptsFlag)); err != nil {
 		return err
 	}
-	if err := project.WriteUpdateHistorySnapshot(jirix); err != nil {
+	if err := project.WriteUpdateHistorySnapshot(jirix, ""); err != nil {
 		return err
 	}
 
diff --git a/doc.go b/doc.go
index bfe847c..a6a93a5 100644
--- a/doc.go
+++ b/doc.go
@@ -31,8 +31,6 @@
 The jiri flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -58,8 +56,6 @@
 The jiri cl flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -83,8 +79,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -130,8 +124,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -152,8 +144,6 @@
 The jiri cl new flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -181,8 +171,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -252,8 +240,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -276,8 +262,6 @@
 The jiri profile flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -327,8 +311,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile env - Display profile environment variables
 
@@ -364,8 +346,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile install - Install the given profiles
 
@@ -390,8 +370,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -418,8 +396,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile update - Install the latest default version of the given profiles
 
@@ -440,8 +416,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile cleanup - Cleanup the locally installed profiles
 
@@ -471,8 +445,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri profile available - List the available profiles
 
@@ -487,8 +459,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
 
 Jiri project - Manage the jiri projects
 
@@ -506,8 +476,6 @@
 The jiri project flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -527,8 +495,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -548,8 +514,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -573,8 +537,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -595,8 +557,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -615,8 +575,6 @@
 The jiri rebuild flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -640,8 +598,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -663,8 +619,6 @@
    Use color to format output.
  -dir=
    Directory where snapshot are stored.  Defaults to $JIRI_ROOT/.snapshot.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -710,8 +664,6 @@
    Use color to format output.
  -dir=
    Directory where snapshot are stored.  Defaults to $JIRI_ROOT/.snapshot.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -731,8 +683,6 @@
    Use color to format output.
  -dir=
    Directory where snapshot are stored.  Defaults to $JIRI_ROOT/.snapshot.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -759,8 +709,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -804,8 +752,6 @@
 
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
@@ -831,8 +777,6 @@
 The jiri which flags are:
  -color=true
    Use color to format output.
- -n=false
-   Show what commands will run but do not execute them.
  -v=false
    Print verbose output.
 
diff --git a/profiles/profilescmdline/manager_cmdline.go b/profiles/profilescmdline/manager_cmdline.go
index 1375750..95e8f59 100644
--- a/profiles/profilescmdline/manager_cmdline.go
+++ b/profiles/profilescmdline/manager_cmdline.go
@@ -283,7 +283,7 @@
 	if err == nil && fi.IsDir() {
 		env := cmdline.EnvFromOS()
 		env.Vars["PATH"] = jirix.Env()["PATH"]
-		return env.LookPathAll("jiri-profile", map[string]bool{})
+		return env.LookPathPrefix("jiri-profile", map[string]bool{})
 	}
 	return []string{}
 }
diff --git a/project/.api b/project/.api
index 28a5de7..7ce2b0a 100644
--- a/project/.api
+++ b/project/.api
@@ -4,8 +4,7 @@
 pkg project, func BuildTools(*jiri.X, Projects, Tools, string) error
 pkg project, func CheckoutSnapshot(*jiri.X, string, bool) error
 pkg project, func CleanupProjects(*jiri.X, Projects, bool) error
-pkg project, func CreateSnapshot(*jiri.X, string) error
-pkg project, func CurrentManifest(*jiri.X) (*Manifest, error)
+pkg project, func CreateSnapshot(*jiri.X, string, string) error
 pkg project, func CurrentProjectKey(*jiri.X) (ProjectKey, error)
 pkg project, func DataDirPath(*jiri.X, string) (string, error)
 pkg project, func GetProjectStates(*jiri.X, bool) (map[ProjectKey]*ProjectState, error)
@@ -21,7 +20,7 @@
 pkg project, func ProjectFromFile(*jiri.X, string) (*Project, error)
 pkg project, func TransitionBinDir(*jiri.X) error
 pkg project, func UpdateUniverse(*jiri.X, bool) error
-pkg project, func WriteUpdateHistorySnapshot(*jiri.X) error
+pkg project, func WriteUpdateHistorySnapshot(*jiri.X, string) error
 pkg project, method (*Import) ProjectKey() ProjectKey
 pkg project, method (*Manifest) ToBytes() ([]byte, error)
 pkg project, method (*Manifest) ToFile(*jiri.X, string) error
diff --git a/project/project.go b/project/project.go
index dc47bdd..0a59d01 100644
--- a/project/project.go
+++ b/project/project.go
@@ -46,7 +46,7 @@
 	Projects     []Project     `xml:"projects>project"`
 	Tools        []Tool        `xml:"tools>tool"`
 	// SnapshotPath is the relative path to the snapshot file from JIRI_ROOT.
-	// It is only set when running "jiri snapshot checkout <path>".
+	// It is only set when creating a snapshot.
 	SnapshotPath string   `xml:"snapshotpath,attr,omitempty"`
 	XMLName      struct{} `xml:"manifest"`
 }
@@ -591,11 +591,27 @@
 
 // CreateSnapshot creates a manifest that encodes the current state of master
 // branches of all projects and writes this snapshot out to the given file.
-func CreateSnapshot(jirix *jiri.X, path string) error {
+func CreateSnapshot(jirix *jiri.X, file, snapshotPath string) error {
 	jirix.TimerPush("create snapshot")
 	defer jirix.TimerPop()
 
-	manifest := Manifest{}
+	// If snapshotPath is empty, use the file as the path.
+	if snapshotPath == "" {
+		snapshotPath = file
+	}
+
+	// Get a clean, symlink-free, relative path to the snapshot.
+	snapshotPath = filepath.Clean(snapshotPath)
+	if evaledSnapshotPath, err := filepath.EvalSymlinks(snapshotPath); err == nil {
+		snapshotPath = evaledSnapshotPath
+	}
+	if relSnapshotPath, err := filepath.Rel(jirix.Root, snapshotPath); err == nil {
+		snapshotPath = relSnapshotPath
+	}
+
+	manifest := Manifest{
+		SnapshotPath: snapshotPath,
+	}
 
 	// Add all local projects to manifest.
 	localProjects, err := LocalProjects(jirix, FullScan)
@@ -629,7 +645,7 @@
 	for _, tool := range tools {
 		manifest.Tools = append(manifest.Tools, tool)
 	}
-	return manifest.ToFile(jirix, path)
+	return manifest.ToFile(jirix, file)
 }
 
 // CheckoutSnapshot updates project state to the state specified in the given
@@ -651,50 +667,7 @@
 	if err := updateTo(jirix, localProjects, remoteProjects, remoteTools, gc); err != nil {
 		return err
 	}
-	if err := WriteUpdateHistorySnapshot(jirix); err != nil {
-		return err
-	}
-
-	// Get a clean, symlink-free, relative path to the snapshot.
-	snapshotPath := filepath.Clean(snapshot)
-	evaledSnapshotPath, err := filepath.EvalSymlinks(snapshotPath)
-	if err != nil {
-		evaledSnapshotPath = snapshotPath
-
-	}
-	relSnapshotPath, err := filepath.Rel(jirix.Root, evaledSnapshotPath)
-	if err != nil {
-		relSnapshotPath = evaledSnapshotPath
-	}
-	// Write current manifest, including the SnapshotPath.
-	manifest := &Manifest{
-		SnapshotPath: relSnapshotPath,
-		Projects:     remoteProjects.toSlice(),
-		Tools:        remoteTools.toSlice(),
-	}
-	return writeCurrentManifest(jirix, manifest)
-}
-
-// CurrentManifest returns a manifest that identifies the result of
-// the most recent "jiri update" invocation.
-func CurrentManifest(jirix *jiri.X) (*Manifest, error) {
-	filename := filepath.Join(jirix.Root, ".current_manifest")
-	m, err := ManifestFromFile(jirix, filename)
-	if runutil.IsNotExist(err) {
-		fmt.Fprintf(jirix.Stderr(), `WARNING: Could not find %s.
-The contents of this file are stored as metadata in binaries the jiri
-tool builds. To fix this problem, please run "jiri update".
-`, filename)
-		return &Manifest{}, nil
-	}
-	return m, err
-}
-
-// writeCurrentManifest writes the given manifest to a file that
-// stores the result of the most recent "jiri update" invocation.
-func writeCurrentManifest(jirix *jiri.X, manifest *Manifest) error {
-	filename := filepath.Join(jirix.Root, ".current_manifest")
-	return manifest.ToFile(jirix, filename)
+	return WriteUpdateHistorySnapshot(jirix, snapshot)
 }
 
 // CurrentProjectKey gets the key of the current project from the current
@@ -1032,10 +1005,10 @@
 
 // WriteUpdateHistorySnapshot creates a snapshot of the current state of all
 // projects and writes it to the update history directory.
-func WriteUpdateHistorySnapshot(jirix *jiri.X) error {
+func WriteUpdateHistorySnapshot(jirix *jiri.X, snapshotPath string) error {
 	seq := jirix.NewSeq()
 	snapshotFile := filepath.Join(jirix.UpdateHistoryDir(), time.Now().Format(time.RFC3339))
-	if err := CreateSnapshot(jirix, snapshotFile); err != nil {
+	if err := CreateSnapshot(jirix, snapshotFile, snapshotPath); err != nil {
 		return err
 	}
 
@@ -1791,10 +1764,9 @@
 			return err
 		}
 	}
-	manifest := &Manifest{}
 	s := jirix.NewSeq()
 	for _, op := range ops {
-		updateFn := func() error { return op.Run(jirix, manifest) }
+		updateFn := func() error { return op.Run(jirix) }
 		// Always log the output of updateFn, irrespective of
 		// the value of the verbose flag.
 		if err := s.Verbose(true).Call(updateFn, "%v", op).Done(); err != nil {
@@ -1804,10 +1776,7 @@
 	if err := runHooks(jirix, ops); err != nil {
 		return err
 	}
-	if err := applyGitHooks(jirix, ops); err != nil {
-		return err
-	}
-	return writeCurrentManifest(jirix, manifest)
+	return applyGitHooks(jirix, ops)
 }
 
 // runHooks runs all hooks for the given operations.
@@ -1918,39 +1887,6 @@
 	return project.ToFile(jirix, metadataFile)
 }
 
-// addProjectToManifest records the information about the given
-// project in the given manifest. The function is used to create a
-// manifest that records the current state of jiri projects, which
-// can be used to restore this state at some later point.
-//
-// NOTE: The function assumes that the the given project is on a
-// master branch.
-func addProjectToManifest(jirix *jiri.X, manifest *Manifest, project Project) error {
-	if manifest == nil {
-		return nil
-	}
-	// If the project uses relative revision, replace it with an absolute one.
-	switch project.Protocol {
-	case "git":
-		if project.Revision == "HEAD" {
-			revision, err := gitutil.New(jirix.NewSeq(), gitutil.RootDirOpt(project.Path)).CurrentRevision()
-			if err != nil {
-				return err
-			}
-			project.Revision = revision
-		}
-	default:
-		return UnsupportedProtocolErr(project.Protocol)
-	}
-	relPath, err := filepath.Rel(jirix.Root, project.Path)
-	if err != nil {
-		return err
-	}
-	project.Path = relPath
-	manifest.Projects = append(manifest.Projects, project)
-	return nil
-}
-
 // fsUpdates is used to track filesystem updates made by operations.
 // TODO(nlacasse): Currently we only use fsUpdates to track deletions so that
 // jiri can delete and create a project in the same directory in one update.
@@ -1984,7 +1920,7 @@
 	// Root returns the operation's root directory, relative to JIRI_ROOT.
 	Root() string
 	// Run executes the operation.
-	Run(jirix *jiri.X, manifest *Manifest) error
+	Run(jirix *jiri.X) error
 	// String returns a string representation of the operation.
 	String() string
 	// Test checks whether the operation would fail.
@@ -2022,7 +1958,7 @@
 	return "create"
 }
 
-func (op createOperation) Run(jirix *jiri.X, manifest *Manifest) (e error) {
+func (op createOperation) Run(jirix *jiri.X) (e error) {
 	s := jirix.NewSeq()
 
 	path, perm := filepath.Dir(op.destination), os.FileMode(0755)
@@ -2059,10 +1995,7 @@
 		Rename(tmpDir, op.destination).Done(); err != nil {
 		return err
 	}
-	if err := syncProjectMaster(jirix, op.project); err != nil {
-		return err
-	}
-	return addProjectToManifest(jirix, manifest, op.project)
+	return syncProjectMaster(jirix, op.project)
 }
 
 func (op createOperation) String() string {
@@ -2092,7 +2025,7 @@
 func (op deleteOperation) Kind() string {
 	return "delete"
 }
-func (op deleteOperation) Run(jirix *jiri.X, _ *Manifest) error {
+func (op deleteOperation) Run(jirix *jiri.X) error {
 	s := jirix.NewSeq()
 	if op.gc {
 		// Never delete projects with non-master branches, uncommitted
@@ -2154,7 +2087,7 @@
 func (op moveOperation) Kind() string {
 	return "move"
 }
-func (op moveOperation) Run(jirix *jiri.X, manifest *Manifest) error {
+func (op moveOperation) Run(jirix *jiri.X) error {
 	s := jirix.NewSeq()
 	path, perm := filepath.Dir(op.destination), os.FileMode(0755)
 	if err := s.MkdirAll(path, perm).Rename(op.source, op.destination).Done(); err != nil {
@@ -2166,10 +2099,7 @@
 	if err := syncProjectMaster(jirix, op.project); err != nil {
 		return err
 	}
-	if err := writeMetadata(jirix, op.project, op.project.Path); err != nil {
-		return err
-	}
-	return addProjectToManifest(jirix, manifest, op.project)
+	return writeMetadata(jirix, op.project, op.project.Path)
 }
 
 func (op moveOperation) String() string {
@@ -2203,17 +2133,14 @@
 func (op updateOperation) Kind() string {
 	return "update"
 }
-func (op updateOperation) Run(jirix *jiri.X, manifest *Manifest) error {
+func (op updateOperation) Run(jirix *jiri.X) error {
 	if err := reportNonMaster(jirix, op.project); err != nil {
 		return err
 	}
 	if err := syncProjectMaster(jirix, op.project); err != nil {
 		return err
 	}
-	if err := writeMetadata(jirix, op.project, op.project.Path); err != nil {
-		return err
-	}
-	return addProjectToManifest(jirix, manifest, op.project)
+	return writeMetadata(jirix, op.project, op.project.Path)
 }
 
 func (op updateOperation) String() string {
@@ -2234,11 +2161,8 @@
 	return "null"
 }
 
-func (op nullOperation) Run(jirix *jiri.X, manifest *Manifest) error {
-	if err := writeMetadata(jirix, op.project, op.project.Path); err != nil {
-		return err
-	}
-	return addProjectToManifest(jirix, manifest, op.project)
+func (op nullOperation) Run(jirix *jiri.X) error {
+	return writeMetadata(jirix, op.project, op.project.Path)
 }
 
 func (op nullOperation) String() string {
diff --git a/snapshot.go b/snapshot.go
index de89012..21d572d 100644
--- a/snapshot.go
+++ b/snapshot.go
@@ -153,7 +153,7 @@
 func createSnapshot(jirix *jiri.X, snapshotDir, snapshotFile, label string) error {
 	// Create a snapshot that encodes the current state of master
 	// branches for all local projects.
-	if err := project.CreateSnapshot(jirix, snapshotFile); err != nil {
+	if err := project.CreateSnapshot(jirix, snapshotFile, ""); err != nil {
 		return err
 	}
 
@@ -266,19 +266,18 @@
 	}
 
 	// Check that all labels exist.
-	failed := false
+	var notexist []string
 	for _, label := range args {
 		labelDir := filepath.Join(snapshotDir, "labels", label)
-		if _, err := jirix.NewSeq().Stat(labelDir); err != nil {
-			if !runutil.IsNotExist(err) {
-				return err
-			}
-			failed = true
-			fmt.Fprintf(jirix.Stderr(), "snapshot label %q not found", label)
+		switch _, err := jirix.NewSeq().Stat(labelDir); {
+		case runutil.IsNotExist(err):
+			notexist = append(notexist, label)
+		case err != nil:
+			return err
 		}
 	}
-	if failed {
-		return cmdline.ErrExitCode(2)
+	if len(notexist) > 0 {
+		return fmt.Errorf("snapshot labels %v not found", notexist)
 	}
 
 	// Print snapshots for all labels.
diff --git a/tool/.api b/tool/.api
index 334a88b..32747af 100644
--- a/tool/.api
+++ b/tool/.api
@@ -21,7 +21,6 @@
 pkg tool, type Context struct
 pkg tool, type ContextOpts struct
 pkg tool, type ContextOpts struct, Color *bool
-pkg tool, type ContextOpts struct, DryRun *bool
 pkg tool, type ContextOpts struct, Env map[string]string
 pkg tool, type ContextOpts struct, Manifest *string
 pkg tool, type ContextOpts struct, Stderr io.Writer
@@ -30,7 +29,6 @@
 pkg tool, type ContextOpts struct, Timer *timing.Timer
 pkg tool, type ContextOpts struct, Verbose *bool
 pkg tool, var ColorFlag bool
-pkg tool, var DryRunFlag bool
 pkg tool, var ManifestFlag string
 pkg tool, var Name string
 pkg tool, var VerboseFlag bool
diff --git a/tool/context.go b/tool/context.go
index d396753..c8b0959 100644
--- a/tool/context.go
+++ b/tool/context.go
@@ -27,7 +27,6 @@
 // ContextOpts records the context options.
 type ContextOpts struct {
 	Color    *bool
-	DryRun   *bool
 	Manifest *string
 	Env      map[string]string
 	Stdin    io.Reader
@@ -41,7 +40,6 @@
 func newContextOpts() *ContextOpts {
 	return &ContextOpts{
 		Color:    &ColorFlag,
-		DryRun:   &DryRunFlag,
 		Env:      map[string]string{},
 		Manifest: &ManifestFlag,
 		Stdin:    os.Stdin,
@@ -57,9 +55,6 @@
 	if opts.Color == nil {
 		opts.Color = defaultOpts.Color
 	}
-	if opts.DryRun == nil {
-		opts.DryRun = defaultOpts.DryRun
-	}
 	if opts.Env == nil {
 		opts.Env = defaultOpts.Env
 	}
@@ -121,7 +116,7 @@
 
 // DryRun returns the dry run setting of the context.
 func (ctx Context) DryRun() bool {
-	return *ctx.opts.DryRun
+	return false
 }
 
 // Env returns the environment of the context.
@@ -148,7 +143,7 @@
 // NewSeq returns a new instance of Sequence initialized using the options
 // stored in the context.
 func (ctx Context) NewSeq() runutil.Sequence {
-	return runutil.NewSequence(ctx.opts.Env, ctx.opts.Stdin, ctx.opts.Stdout, ctx.opts.Stderr, *ctx.opts.Color, *ctx.opts.DryRun, *ctx.opts.Verbose)
+	return runutil.NewSequence(ctx.opts.Env, ctx.opts.Stdin, ctx.opts.Stdout, ctx.opts.Stderr, *ctx.opts.Color, false, *ctx.opts.Verbose)
 }
 
 // Stdin returns the standard input of the context.
diff --git a/tool/tool.go b/tool/tool.go
index 5ec4ffc..aafcb2a 100644
--- a/tool/tool.go
+++ b/tool/tool.go
@@ -17,7 +17,6 @@
 var (
 	// Flags for running commands.
 	ColorFlag   bool
-	DryRunFlag  bool
 	VerboseFlag bool
 
 	// Flags for working with projects.
@@ -27,7 +26,6 @@
 // InitializeRunFlags initializes flags for running commands.
 func InitializeRunFlags(flags *flag.FlagSet) {
 	flags.BoolVar(&ColorFlag, "color", true, "Use color to format output.")
-	flags.BoolVar(&DryRunFlag, "n", false, "Show what commands will run but do not execute them.")
 	flags.BoolVar(&VerboseFlag, "v", false, "Print verbose output.")
 }
 
diff --git a/update.go b/update.go
index f87107d..9dccf97 100644
--- a/update.go
+++ b/update.go
@@ -57,7 +57,7 @@
 	if err := retry.Function(jirix.Context, updateFn, retry.AttemptsOpt(attemptsFlag)); err != nil {
 		return err
 	}
-	if err := project.WriteUpdateHistorySnapshot(jirix); err != nil {
+	if err := project.WriteUpdateHistorySnapshot(jirix, ""); err != nil {
 		return err
 	}