Commits

Markus Zapke-Gründemann  committed 324e624

Allow to create anonymous branches.

  • Participants
  • Parent commits d606fea

Comments (0)

Files changed (2)

     """
     if branch:
         if branch not in repo.branchmap():
+            # Create a named branch.
             commands.update(ui, repo, rev=rev)
             commands.branch(ui, repo, label=branch)
         else:
+            # Update to the named branch.
             commands.update(ui, repo, rev=branch)
+    elif rev:
+        # Create an anonymous branch.
+        commands.update(ui, repo, rev=rev)
+        commands.branch(ui, repo)
     elif repo.dirstate.branch() != 'default':
+        # Update to the default branch.
         commands.update(ui, repo, rev='default')
     else:
         commands.update(ui, repo)
         if not os.path.exists(path):
             raise Abort(_('directory %s does not exist') % path)
         sources.append(util.expandpath(path))
-    if opts.get('rev') and not opts.get('branch'):
-        raise Abort(_('you specified a revision without giving a branch name'))
     repo = get_repo(ui, repo)
     update_repo(ui, repo, opts.get('rev'), opts.get('branch'))
     # Empty the repository except the metadata.

File test-importfs.t

   $ echo "c4" > d1/d3/f4
   $ echo "c5" > d1/d3/f5
 
-Provoke an error by using the rev option without the branch option:
-
-  $ hg importfs -r 1 r d1
-  abort: you specified a revision without giving a branch name
-  [255]
-
 Perform the first import (creates a new repository):
 
   $ hg importfs r d1
   4 files updated, 0 files merged, 2 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
+  b1
+  adding d2/f10
+  removing d2/f7
+  adding d3/f11
+  adding d3/f13
+  adding d3/f14
+  removing d3/f4
+  adding d3/f9
+  created new head
+
+Create a second anonymous branch:
+
+  $ 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
+  default
+  adding d2/f10
+  adding d3/f11
+  adding d3/f13
+  adding d3/f14
+  adding d3/f15
+  removing d3/f4
+  removing d3/f5
+  adding d3/f9
+  created new head
+
+Check the new heads:
+
+  $ hg -R r heads --template "changeset: {rev}\nbranch: {branches}\nparent: {parents}\nsummary: {desc}\n\n"
+  changeset: 13
+  branch: 
+  parent: 1:????????????  (glob)
+  summary: Creating a second anonymous branch.
+  
+  changeset: 12
+  branch: b1
+  parent: 3:????????????  (glob)
+  summary: Creating an anonymous branch.
+  
+  changeset: 11
+  branch: b1
+  parent: 9:????????????  (glob)
+  summary: importfs commit.
+  
+  changeset: 10
+  branch: b2
+  parent: 
+  summary: Creating branch b2
+  
+  changeset: 5
+  branch: 
+  parent: 2:????????????  (glob)
+  summary: importfs commit.
+