From ddbbfd845a3813658370c26a7d7ea91ac6f57fae Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Mon, 15 Aug 2005 17:16:23 +0100 Subject: [PATCH] Make 'stg pull' use 'git pull' directly In the initial version, 'git fetch' was used but its interface might change in the future. Signed-off-by: Catalin Marinas --- stgit/commands/pull.py | 47 ++++++++++++++++++++--------------------------- stgit/git.py | 6 ++---- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/stgit/commands/pull.py b/stgit/commands/pull.py index 3bad086..2aba444 100644 --- a/stgit/commands/pull.py +++ b/stgit/commands/pull.py @@ -65,36 +65,29 @@ def func(parser, options, args): check_conflicts() check_head_top_equal() - orig_head = git_id('base') - + # pop all patches + applied = crt_series.get_applied() + if len(applied) > 0: + print 'Popping all patches...', + sys.stdout.flush() + crt_series.pop_patch(applied[0]) + print 'done' + + # pull the remote changes print 'Pulling from "%s"...' % location - new_head = git.fetch(location, options.head, options.tag) + git.pull(location, options.head, options.tag) print 'done' - if new_head == orig_head: - print 'Branch already up-to-date' - else: - write_string(os.path.join(git.base_dir, 'ORIG_HEAD'), orig_head) - - applied = crt_series.get_applied() - - if len(applied) > 0: - print 'Popping all patches...', - sys.stdout.flush() - crt_series.pop_patch(applied[0]) + # push the patches back + if options.nopush: + applied = [] + for p in applied: + print 'Pushing patch "%s"...' % p, + sys.stdout.flush() + crt_series.push_patch(p) + if crt_series.empty_patch(p): + print 'done (empty patch)' + else: print 'done' - git.switch(new_head) - - if options.nopush: - applied = [] - for p in applied: - print 'Pushing patch "%s"...' % p, - sys.stdout.flush() - crt_series.push_patch(p) - if crt_series.empty_patch(p): - print 'done (empty patch)' - else: - print 'done' - print_crt_patch() diff --git a/stgit/git.py b/stgit/git.py index fdba68a..9d8cdf0 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -449,7 +449,7 @@ def switch(tree_id): for fs in to_delete: os.remove(fs[1]) -def fetch(location, head = None, tag = None): +def pull(location, head = None, tag = None): """Fetch changes from the remote repository. At the moment, just use the 'git fetch' scripts """ @@ -459,11 +459,9 @@ def fetch(location, head = None, tag = None): elif tag: args += ['tag', tag] - if __run('git fetch', args) != 0: + if __run('git pull', args) != 0: raise GitException, 'Failed "git fetch %s"' % location - return read_string(os.path.join(base_dir, 'FETCH_HEAD')) - def apply_patch(filename = None): """Apply a patch onto the current index. There must not be any local changes in the tree, otherwise the command fails -- 2.11.0