##// END OF EJS Templates
share: define norepo in command decorator
Gregory Szorc -
r21772:5a4d1a6c default
parent child Browse files
Show More
@@ -1,70 +1,69 b''
1 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
1 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
2 #
2 #
3 # This software may be used and distributed according to the terms of the
3 # This software may be used and distributed according to the terms of the
4 # GNU General Public License version 2 or any later version.
4 # GNU General Public License version 2 or any later version.
5
5
6 '''share a common history between several working directories'''
6 '''share a common history between several working directories'''
7
7
8 from mercurial.i18n import _
8 from mercurial.i18n import _
9 from mercurial import cmdutil, hg, commands, util
9 from mercurial import cmdutil, hg, util
10
10
11 cmdtable = {}
11 cmdtable = {}
12 command = cmdutil.command(cmdtable)
12 command = cmdutil.command(cmdtable)
13 testedwith = 'internal'
13 testedwith = 'internal'
14
14
15 @command('share',
15 @command('share',
16 [('U', 'noupdate', None, _('do not create a working copy'))],
16 [('U', 'noupdate', None, _('do not create a working copy'))],
17 _('[-U] SOURCE [DEST]'))
17 _('[-U] SOURCE [DEST]'),
18 norepo=True)
18 def share(ui, source, dest=None, noupdate=False):
19 def share(ui, source, dest=None, noupdate=False):
19 """create a new shared repository
20 """create a new shared repository
20
21
21 Initialize a new repository and working directory that shares its
22 Initialize a new repository and working directory that shares its
22 history with another repository.
23 history with another repository.
23
24
24 .. note::
25 .. note::
25
26
26 using rollback or extensions that destroy/modify history (mq,
27 using rollback or extensions that destroy/modify history (mq,
27 rebase, etc.) can cause considerable confusion with shared
28 rebase, etc.) can cause considerable confusion with shared
28 clones. In particular, if two shared clones are both updated to
29 clones. In particular, if two shared clones are both updated to
29 the same changeset, and one of them destroys that changeset
30 the same changeset, and one of them destroys that changeset
30 with rollback, the other clone will suddenly stop working: all
31 with rollback, the other clone will suddenly stop working: all
31 operations will fail with "abort: working directory has unknown
32 operations will fail with "abort: working directory has unknown
32 parent". The only known workaround is to use debugsetparents on
33 parent". The only known workaround is to use debugsetparents on
33 the broken clone to reset it to a changeset that still exists.
34 the broken clone to reset it to a changeset that still exists.
34 """
35 """
35
36
36 return hg.share(ui, source, dest, not noupdate)
37 return hg.share(ui, source, dest, not noupdate)
37
38
38 @command('unshare', [], '')
39 @command('unshare', [], '')
39 def unshare(ui, repo):
40 def unshare(ui, repo):
40 """convert a shared repository to a normal one
41 """convert a shared repository to a normal one
41
42
42 Copy the store data to the repo and remove the sharedpath data.
43 Copy the store data to the repo and remove the sharedpath data.
43 """
44 """
44
45
45 if repo.sharedpath == repo.path:
46 if repo.sharedpath == repo.path:
46 raise util.Abort(_("this is not a shared repo"))
47 raise util.Abort(_("this is not a shared repo"))
47
48
48 destlock = lock = None
49 destlock = lock = None
49 lock = repo.lock()
50 lock = repo.lock()
50 try:
51 try:
51 # we use locks here because if we race with commit, we
52 # we use locks here because if we race with commit, we
52 # can end up with extra data in the cloned revlogs that's
53 # can end up with extra data in the cloned revlogs that's
53 # not pointed to by changesets, thus causing verify to
54 # not pointed to by changesets, thus causing verify to
54 # fail
55 # fail
55
56
56 destlock = hg.copystore(ui, repo, repo.path)
57 destlock = hg.copystore(ui, repo, repo.path)
57
58
58 sharefile = repo.join('sharedpath')
59 sharefile = repo.join('sharedpath')
59 util.rename(sharefile, sharefile + '.old')
60 util.rename(sharefile, sharefile + '.old')
60
61
61 repo.requirements.discard('sharedpath')
62 repo.requirements.discard('sharedpath')
62 repo._writerequirements()
63 repo._writerequirements()
63 finally:
64 finally:
64 destlock and destlock.release()
65 destlock and destlock.release()
65 lock and lock.release()
66 lock and lock.release()
66
67
67 # update store, spath, sopener and sjoin of repo
68 # update store, spath, sopener and sjoin of repo
68 repo.unfiltered().__init__(repo.baseui, repo.root)
69 repo.unfiltered().__init__(repo.baseui, repo.root)
69
70 commands.norepo += " share"
General Comments 0
You need to be logged in to leave comments. Login now