[clonemissing] a new "clonemissing" command (closes #105422)

authorAurelien Campeas <aurelien.campeas@logilab.fr>
changeset508abfbee2e5
branchdefault
phasepublic
hiddenno
parent revision#53d7c466a320 fix path handling for hgsnap & encureconf (will now work correctly not just at the repo root) (closes #106605)
child revision#d46afa5e53c8 [attributes] be careful with the top-level namespace, create an `hgrc` key to handle the target hgrc entries (closes #106247)
files modified by this revision
hgext/confman.py
tests/test-confman.t
# HG changeset patch
# User Aurelien Campeas <aurelien.campeas@logilab.fr>
# Date 1349690419 -7200
# Mon Oct 08 12:00:19 2012 +0200
# Node ID 508abfbee2e55738c2df4349f5dd7c739dd46487
# Parent 53d7c466a320b63f9788eeb35876a2284756efab
[clonemissing] a new "clonemissing" command (closes #105422)

diff --git a/hgext/confman.py b/hgext/confman.py
@@ -190,11 +190,10 @@
1          for section, entry in _unflatten(secconf).iteritems():
2              for key, val in entry.iteritems():
3                  conf.set(section, key, val)
4          _saveconf(hgrcpath, conf)
5 
6 -# ensureconf
7 
8  def _check_and_fill_missing(ui, repo, **opts):
9      err, warn = checkconf(ui, repo, **opts)
10      if err:
11          ui.warn('You must complete the configuration before attempting to ensureconf. See:\n')
@@ -214,10 +213,13 @@
12          return dict((layout, revision.strip())
13                      for revision, layout in (line.split()
14                                               for line in open(snappath, 'rb')))
15      return {}
16 
17 +def clonemissing(ui, repo, **opts):
18 +    _check_and_fill_missing(ui, repo, **opts)
19 +
20  def ensureconf(ui, repo, **opts):
21      """ ensures the repos are updated according to their configuration """
22      _check_and_fill_missing(ui, repo, **opts)
23 
24      rootpath = repopath(repo)
@@ -244,12 +246,10 @@
25          except error.RepoLookupError, exc:
26              if str(exc).startswith('unknown revision'):
27                  raise error.RepoLookupError('unknown revision %s in repo %s' %
28                                              (rev, section))
29 
30 -# snapshot
31 -
32  def openrepo(ui, section, path):
33      try:
34          repo = hg.repository(ui, path)
35      except error.RepoError, err:
36          if str(err) == 'repository %s not found' % section:
@@ -338,10 +338,12 @@
37 
38 
39  cmdtable = {
40      'confcheck': (confcheck, [],
41                 'hg confcheck checks the .hgconf file completeness'),
42 +    'clonemissing': (clonemissing, [],
43 +                     'hg clonemissing clones the yet uncloned repositories'),
44      'ensureconf': (ensureconf,
45                      [('p', 'no-pull', None, 'do not attempt to pull the remote repos')],
46                      ('hg ensureconf clones (if needed), pulls & '
47                       'updates the managed repositories up to their '
48                       'spec in the .hgsnap and .hgconf files')),
diff --git a/tests/test-confman.t b/tests/test-confman.t
@@ -290,5 +290,22 @@
49    pulling repo foo
50    searching for changes
51    no changes found
52    updating repo foo to stable
53    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
54 +
55 +Clone missing
56 +  $ cd $TESTTMP/
57 +  $ hg init newcomer
58 +  $ cd newcomer
59 +  $ mkcommit a-default
60 +  $ cd $TESTTMP/conf
61 +  $ cat >> .hgconf << EOF
62 +  > [newcomer]
63 +  > pulluri = $TESTTMP/newcomer
64 +  > layout = newcomer
65 +  > EOF
66 +  $ hg clonemissing
67 +  cloning newcomer from $TESTTMP/newcomer to newcomer
68 +  updating to branch default
69 +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 +