mgiammarco
mgiammarco

Reputation: 471

Mercurial: clone only a branch of a repository

in my mercurial project I have some users that can clone the repository, but I need that they only can see some branches.

For example they can see only the "stable" branch so I can be sure they will never try unstable code. Or customer X can see only the branch with his customizations.

I know I can extract the source code of the release and give it to them. But for "non technical" reasons they want access to the repository.

Is it possible?

Thanks, Mario

Upvotes: 0

Views: 868

Answers (1)

shamp00
shamp00

Reputation: 11326

You can use the ACL extension, in which you define [acl.deny.branches] and [acl.allow.branches].

The following sample config is taken from the ACL documentation page.

  [hooks]

  # Use this if you want to check access restrictions at commit time
  pretxncommit.acl = python:hgext.acl.hook

  # Use this if you want to check access restrictions for pull, push,
  # bundle and serve.
  pretxnchangegroup.acl = python:hgext.acl.hook

  [acl]
  # Check whether the source of incoming changes is in this list where
  # "serve" == ssh or http, and "push", "pull" and "bundle" are the
  # corresponding hg commands.
  sources = serve

  [acl.groups]
  # If a group name is not defined here, and Mercurial is running under
  # a Unix-like system, the list of users will be taken from the OS.
  # Otherwise, an exception will be raised.
  designers = user1, user2

  [acl.deny.branches] 

  # Everyone is denied to the frozen branch: 
  frozen-branch = * 

  # A bad user is denied on all branches: 
  * = bad-user 

  [acl.allow.branches] 

  # A few users are allowed on branch-a: 
  branch-a = user-1, user-2, user-3 

  # Only one user is allowed on branch-b: 
  branch-b = user-1 

  # The super user is allowed on any branch: 
  * = super-user 

  # Everyone is allowed on branch-for-tests: 
  branch-for-tests = * 

Upvotes: 3

Related Questions