Commits

Markus Zapke-Gründemann committed d3591e9

Added purge call before update call and --clean option to update.

The update operation inside the repository is using the --clean option.

The repository is purged before each update/commit because there can be files
without write permissions and Mercurial fails to update them.

Comments (0)

Files changed (4)

 - Renamed --exclude option to --exclude-pattern.
 - Added new option --exclude-path to exclude a path relative to SOURCE.
 - Added new option --retain-empty-dirs to import empty directories.
+- The update operation inside the repository is using the --clean option.
+- The repository is purged before each update/commit because there can be files
+  without write permissions and Mercurial fails to update them.
 
 1.0.1
 =====
 
 
 def update_repo(ui, repo, rev, branch=None):
-    """Update the repository.
+    """Update the repository using the --clean option.
 
     Creates a new branch if necessary.
     """
     if branch:
         if branch not in repo.branchmap():
             # Create a named branch.
-            commands.update(ui, repo, rev=rev)
+            commands.update(ui, repo, rev=rev, clean=True)
             commands.branch(ui, repo, label=branch)
         else:
             # Update to the named branch.
-            commands.update(ui, repo, rev=branch)
+            commands.update(ui, repo, rev=branch, clean=True)
     elif rev:
         # Create an anonymous branch.
-        commands.update(ui, repo, rev=rev)
+        commands.update(ui, repo, rev=rev, clean=True)
         commands.branch(ui, repo)
     elif repo.dirstate.branch() != 'default':
         # Update to the default branch.
-        commands.update(ui, repo, rev='default')
+        commands.update(ui, repo, rev='default', clean=True)
     else:
-        commands.update(ui, repo)
+        commands.update(ui, repo, clean=True)
 
 
 def onerror(func, path, exc_info=tuple()):
             raise Abort(_('directory %s does not exist') % path)
         sources.append(path)
     repo = get_repo(ui, repo)
+    # The repository is purged before the update because there can be files
+    # without write permissions and Mercurial fails to update them.
+    purge_repo(repo)
     update_repo(ui, repo, opts.get('rev'), opts.get('branch'))
     purge_repo(repo)
     # Prepare exclusion rules.

test-importfs-two-sources.t

 
   $ echo "c7" > d3/f1
   $ hg importfs r d1 d3
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  5 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Check the log:
 
 Perform the second import (uses the repository created before):
 
   $ hg importfs r d1 -t t1 -m 'm1'
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  5 files updated, 0 files merged, 0 files removed, 0 files unresolved
   adding d2/f6
 
 Show the log of the last changeset:
 Perform a third import using a branch:
 
   $ hg importfs -b b1 -r 0 -t t2 r d1
-  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  5 files updated, 0 files merged, 1 files removed, 0 files unresolved
   marked working directory as branch b1
   adding d2/f6
   adding d2/f7
 Commit the same files on top of the default branch:
 
   $ hg importfs r d1
-  3 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  7 files updated, 0 files merged, 0 files removed, 0 files unresolved
   adding d2/f7
   removing d3/f5
 
 Reuse the branch:
 
   $ hg importfs -b b1 r d1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  7 files updated, 0 files merged, 0 files removed, 0 files unresolved
   adding d3/f8
 
 Show the log of the last changeset:
 
   $ mv d1/d3/f8 d1/d3/f9
   $ hg importfs -b b1 r d1
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  7 files updated, 0 files merged, 0 files removed, 0 files unresolved
   removing d3/f8
   adding d3/f9
   recording removal of r/d3/f8 as rename to r/d3/f9 (100% similar)
   $ mv d1/d2/f7 d1/d2/f10
   $ echo "c10" >> d1/d2/f10
   $ hg importfs -b b1 -s 50 r d1
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  7 files updated, 0 files merged, 0 files removed, 0 files unresolved
   adding d2/f10
   removing d2/f7
   recording removal of r/d2/f7 as rename to r/d2/f10 (60% similar)
   $ mv d1/d3/f4 d1/d3/f11
   $ echo "c11" >> d1/d3/f11
   $ hg importfs -b b1 -s 0 r d1
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  7 files updated, 0 files merged, 0 files removed, 0 files unresolved
   adding d3/f11
   removing d3/f4
 
 Create a second branch without specifying a rev (so it uses the tip of default):
 
   $ hg importfs -b b2 -m "Creating branch b2" r d1
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  7 files updated, 0 files merged, 0 files removed, 0 files unresolved
   marked working directory as branch b2
   adding d3/f12
 
 The repository updates to the last revision and doesn't use the tag t2:
 
   $ hg importfs -b b1 r d1
-  4 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  8 files updated, 0 files merged, 0 files removed, 0 files unresolved
   adding d3/f13
 
 Create an anonymous branch:
 
   $ echo "c14" > d1/d3/f14
   $ hg importfs -r t2 -m "Creating an anonymous branch." r d1
-  2 files updated, 0 files merged, 5 files removed, 0 files unresolved
+  6 files updated, 0 files merged, 1 files removed, 0 files unresolved
   b1
   adding d2/f10
   removing d2/f7
 
   $ echo "c15" > d1/d3/f15
   $ hg importfs -r t1 -m "Creating a second anonymous branch." r d1
-  2 files updated, 0 files merged, 5 files removed, 0 files unresolved
+  6 files updated, 0 files merged, 0 files removed, 0 files unresolved
   default
   adding d2/f10
   adding d3/f11