Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH v2] GitSync.update: respect sync-depth (bug 552814)
Date: Thu, 14 Jul 2016 17:09:37
Message-Id: 20160714100847.0264f7b5.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v2] GitSync.update: respect sync-depth (bug 552814) by Zac Medico
1 On Thu, 14 Jul 2016 09:28:14 -0700
2 Zac Medico <zmedico@g.o> wrote:
3
4 > Fix updates to respect sync-depth (previously it was only respected
5 > for clone operations). Since the default merge strategy typically
6 > fails when the the depth is not unlimited, use `git fetch` followed
7 > by `git reset --hard`.
8 >
9 > X-Gentoo-Bug: 552814
10 > X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=552814
11 > ---
12 > [PATCH v2] fixes the git reset call to use --quiet when appropriate
13 >
14 > pym/portage/sync/modules/git/git.py | 27 +++++++++++++++++++++++++--
15 > 1 file changed, 25 insertions(+), 2 deletions(-)
16 >
17 > diff --git a/pym/portage/sync/modules/git/git.py
18 > b/pym/portage/sync/modules/git/git.py index 02eeb16..09257f3 100644
19 > --- a/pym/portage/sync/modules/git/git.py
20 > +++ b/pym/portage/sync/modules/git/git.py
21 > @@ -79,11 +79,26 @@ class GitSync(NewBase):
22 > '''
23 >
24 > git_cmd_opts = ""
25 > - if self.settings.get("PORTAGE_QUIET") == "1":
26 > + quiet = self.settings.get("PORTAGE_QUIET") == "1"
27 > + if quiet:
28 > git_cmd_opts += " --quiet"
29 > if
30 > self.repo.module_specific_options.get('sync-git-pull-extra-opts'):
31 > git_cmd_opts += " %s" %
32 > self.repo.module_specific_options['sync-git-pull-extra-opts']
33 > - git_cmd = "%s pull%s" % (self.bin_command,
34 > git_cmd_opts)
35 > + if self.repo.sync_depth is None:
36 > + git_cmd = "%s pull%s" % (self.bin_command,
37 > git_cmd_opts)
38 > + else:
39 > + # Since the default merge strategy typically
40 > fails when
41 > + # the depth is not unlimited, use `git
42 > fetch` followed by
43 > + # `git reset --hard`.
44 > + remote_branch = portage._unicode_decode(
45 > +
46 > subprocess.check_output([self.bin_command, 'rev-parse',
47 > + '--abbrev-ref',
48 > '--symbolic-full-name', '@{upstream}'],
49 > +
50 > cwd=portage._unicode_encode(self.repo.location))).rstrip('\n') +
51 > + git_cmd_opts += " --depth %d" %
52 > self.repo.sync_depth
53 > + git_cmd = "%s fetch %s%s" %
54 > (self.bin_command,
55 > + remote_branch.partition('/')[0],
56 > git_cmd_opts) +
57 > writemsg_level(git_cmd + "\n")
58 >
59 > rev_cmd = [self.bin_command, "rev-list",
60 > "--max-count=1", "HEAD"] @@ -93,6 +108,14 @@ class GitSync(NewBase):
61 > exitcode = portage.process.spawn_bash("cd %s ; exec
62 > %s" % ( portage._shell_quote(self.repo.location), git_cmd),
63 > **self.spawn_kwargs)
64 > +
65 > + if exitcode == os.EX_OK and self.repo.sync_depth is
66 > not None:
67 > + reset_cmd = [self.bin_command, 'reset',
68 > '--hard', remote_branch]
69 > + if quiet:
70 > + reset_cmd.append('--quiet')
71 > + exitcode = subprocess.call(reset_cmd,
72 > +
73 > cwd=portage._unicode_encode(self.repo.location)) +
74 > if exitcode != os.EX_OK:
75 > msg = "!!! git pull error in %s" %
76 > self.repo.location self.logger(self.xterm_titles, msg)
77
78 looks fine
79
80 --
81 Brian Dolbec <dolsen>

Replies