# HG changeset patch # User Aurelien Campeas # Date 1571419142 -7200 # Fri Oct 18 19:19:02 2019 +0200 # Node ID 1c0f9c4c79886c2fddcd1fd59ba3ecc2f6e75af7 # Parent 979768bd12cb4b5532e834ab691cd477747ee22d opts: add a global -g/--hggit switch to toggle git/hggit use (hggit by default) To really use git: use --no-hggit closes #62 diff --git a/hgext3rd/confman/configuration.py b/hgext3rd/confman/configuration.py --- a/hgext3rd/confman/configuration.py +++ b/hgext3rd/confman/configuration.py @@ -89,7 +89,9 @@ if not os.path.exists(path): return None try: - return repoclassbyconf(self.confs[section], path)(self, path) + return repoclassbyconf( + self.confs[section], path, self.opts.get('hggit') + )(self, path) except error.RepoError: return None @@ -176,8 +178,11 @@ ui.status('cloning %s from %s to %s\n' % (section, source, dest)) try: path = self.pathfromsection(section) - repoclassbyconf(conf, path).clone(self, source, dest, - self.confs[section]) + repoclassbyconf( + conf, path, self.opts.get('hggit') + ).clone( + self, source, dest, self.confs[section] + ) except Exception, err: # the clone operation did fail self.failed.add(section) diff --git a/hgext3rd/confman/managed.py b/hgext3rd/confman/managed.py --- a/hgext3rd/confman/managed.py +++ b/hgext3rd/confman/managed.py @@ -147,21 +147,32 @@ return out.splitlines() -def repoclassbyconf(conf, path): +def repoclassbyconf(conf, path, hggit=False): '''introspect the configuration parameters values and the filesystem and deduct the right repository manager class. ''' uri = urlparse.urlparse(conf['pulluri']) pulluri = conf['pulluri'] + + # first check the local repo (if it exists) if (osp.isdir(osp.join(path, '.hg')) or osp.isdir(osp.join(pulluri, '.hg'))): return hgrepo - if (uri.scheme == 'git' or uri.path.endswith('.git') - or osp.isdir(osp.join(path, '.git')) - or osp.isdir(osp.join(pulluri, '.git'))): + + if osp.isdir(osp.join(path, '.git')): return gitrepo + + # then the hg-vs-git-vs-hggit + if (uri.scheme == 'git' or + uri.path.endswith('.git') or + osp.isdir(osp.join(pulluri, '.git'))): + if hggit: + return hgrepo + return gitrepo + if uri.path.endswith('.tar.gz') or uri.path.endswith('.tar.bz2'): return tgzrepo + if uri.path.endswith('.zip'): return ziprepo return hgrepo diff --git a/hgext3rd/confman/opts.py b/hgext3rd/confman/opts.py --- a/hgext3rd/confman/opts.py +++ b/hgext3rd/confman/opts.py @@ -5,6 +5,8 @@ PULLURIOPT = ('p', 'use-hgrc-path', '', 'distant repository path name registered into hgrc.paths.*') URIMAPOPT = ('', 'uri-map-file', '', 'specify uri map file') +HGGITOPT = ('', 'hggit', True, 'git: operate with hg-git') -DEFAULTOPTS = [INCLUDEOPT, EXCLUDEOPT, ROOTPATHOPT] + +DEFAULTOPTS = [INCLUDEOPT, EXCLUDEOPT, ROOTPATHOPT, HGGITOPT] REMOTEOPTS = [PULLURIOPT, URIMAPOPT] diff --git a/tests/test-git.t b/tests/test-git.t --- a/tests/test-git.t +++ b/tests/test-git.t @@ -69,7 +69,7 @@ Ensureconf - $ hg cfensureconf + $ hg cfensureconf --no-hggit Cloning into '$TESTTMP/conf/foo'... done. cloning foo from $TESTTMP/foo to $TESTTMP/conf/foo @@ -142,7 +142,7 @@ conf |- foo (HEAD) first-commit ok `- bar.quux (default public) quux-version-1.0 ok - $ hg cfensure + $ hg cfensure --no-hggit From $TESTTMP/foo ???????..??????? master -> origin/master (glob) * [new tag] foo-0.1 -> foo-0.1 @@ -166,7 +166,7 @@ |- foo (HEAD) first-commit [baseline 'foo-0.2' in a parallel branch] `- bar.quux (default public) quux-version-1.0 ok - $ hg cfensure + $ hg cfensure --no-hggit foo bar.quux