git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: git@vger.kernel.org, "Karl Hasselström" <kha@treskal.com>
Subject: [StGit PATCH 4/9] Convert 'clone' to the use stgit.lib
Date: Tue, 28 Apr 2009 16:09:57 +0100	[thread overview]
Message-ID: <20090428150957.27261.83658.stgit@pc1117.cambridge.arm.com> (raw)
In-Reply-To: <20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com>

The patch also adds the stgit.lib.git.clone() function.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
---
 stgit/commands/clone.py |   30 +++++++++++++-----------------
 stgit/lib/git.py        |    4 ++++
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/stgit/commands/clone.py b/stgit/commands/clone.py
index 7fe9c35..369c8a9 100644
--- a/stgit/commands/clone.py
+++ b/stgit/commands/clone.py
@@ -1,5 +1,5 @@
 __copyright__ = """
-Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
+Copyright (C) 2009, Catalin Marinas <catalin.marinas@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License version 2 as
@@ -15,10 +15,11 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
-import sys, os
-from stgit.commands.common import *
-from stgit.utils import *
-from stgit import argparse, stack, git
+import os
+from stgit.commands import common
+from stgit.lib import git, stack
+from stgit import argparse
+from stgit.out import out
 
 help = 'Make a local clone of a remote repository'
 kind = 'repo'
@@ -38,7 +39,7 @@ not already exist."""
 args = [argparse.repo, argparse.dir]
 options = []
 
-directory = DirectoryAnywhere(needs_current_series = False, log = False)
+directory = common.DirectoryAnywhere(needs_current_series = False, log = False)
 
 def func(parser, options, args):
     """Clone the <repository> into the local <dir> and initialises the
@@ -51,17 +52,12 @@ def func(parser, options, args):
     local_dir = args[1]
 
     if os.path.exists(local_dir):
-        raise CmdException, '"%s" exists. Remove it first' % local_dir
-
-    print 'Cloning "%s" into "%s"...' % (repository, local_dir)
+        raise common.CmdException, '"%s" exists. Remove it first' % local_dir
 
+    out.start('Cloning "%s" into "%s"' % (repository, local_dir))
     git.clone(repository, local_dir)
     os.chdir(local_dir)
-    git.checkout(tree_id = 'HEAD')
-
-    # be sure to forget any cached value for .git, since we're going
-    # to work on a brand new repository
-    basedir.clear_cache()
-    stack.Series().init()
-
-    print 'done'
+    directory = common.DirectoryHasRepositoryLib()
+    directory.setup()
+    stack.Stack.initialise(directory.repository)
+    out.done()
diff --git a/stgit/lib/git.py b/stgit/lib/git.py
index 9c530c7..6f2c977 100644
--- a/stgit/lib/git.py
+++ b/stgit/lib/git.py
@@ -933,3 +933,7 @@ def diffstat(diff):
     """Return the diffstat of the supplied diff."""
     return run.Run('git', 'apply', '--stat', '--summary'
                    ).raw_input(diff).raw_output()
+
+def clone(remote, local):
+    """Clone a remote repository using 'git clone'."""
+    run.Run('git', 'clone', remote, local).run()

  parent reply	other threads:[~2009-04-28 15:13 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 15:09 [StGit PATCH 0/9] Various StGit updates Catalin Marinas
2009-04-28 15:09 ` [StGit PATCH 1/9] Show "Pushing <patch>...done" when pushing a patch Catalin Marinas
2009-04-29  6:04   ` Karl Hasselström
2009-04-28 15:09 ` [StGit PATCH 2/9] Show some progress information when checking for upstream merges Catalin Marinas
2009-04-29  6:07   ` Karl Hasselström
2009-04-28 15:09 ` [StGit PATCH 3/9] Do not sleep after the last patch sent by e-mail Catalin Marinas
2009-04-29  6:13   ` Karl Hasselström
2009-04-28 15:09 ` Catalin Marinas [this message]
2009-04-29  6:21   ` [StGit PATCH 4/9] Convert 'clone' to the use stgit.lib Karl Hasselström
2009-05-13 16:10     ` Catalin Marinas
2009-04-28 15:10 ` [StGit PATCH 5/9] Convert 'hide' to the lib infrastructure Catalin Marinas
2009-04-29  6:27   ` Karl Hasselström
2009-05-13 16:08     ` Catalin Marinas
2009-04-28 15:10 ` [StGit PATCH 6/9] Convert 'unhide' " Catalin Marinas
2009-04-29  6:29   ` Karl Hasselström
2009-04-28 15:10 ` [StGit PATCH 7/9] Reinstate the --annotate option for refresh Catalin Marinas
2009-04-29  6:33   ` Karl Hasselström
2009-04-28 15:10 ` [StGit PATCH 8/9] Add the log --clear option Catalin Marinas
2009-04-29  6:35   ` Karl Hasselström
2009-04-28 15:10 ` [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts Catalin Marinas
2009-04-29  6:43   ` Karl Hasselström
2009-04-29 11:48     ` Samuel Tardieu
2009-04-29 11:56       ` Samuel Tardieu
2009-04-29 14:25       ` Karl Hasselström
2009-05-04 12:48   ` Shinya Kuribayashi
2009-05-29 12:22     ` Catalin Marinas
2009-05-30  0:36       ` Shinya Kuribayashi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090428150957.27261.83658.stgit@pc1117.cambridge.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).