[gentoo-portage-dev] [PATCH] Add support to Mercurial SCM in bin/repoman
This patch adds support to the Mercurial SCM [1] in repoman. [1] - http://mercurial.selenic.com/ Best Regards, -- Rafael Goncalves Martins http://rafaelmartins.eng.br Index: bin/repoman === --- bin/repoman (revision 15200) +++ bin/repoman (working copy) @@ -486,11 +486,13 @@ vcs = git elif os.path.isdir(os.path.join(portdir_overlay, .bzr)): vcs = bzr +elif os.path.isdir(os.path.join(portdir_overlay, .hg)): + vcs = hg vcs_local_opts = repoman_settings.get(REPOMAN_VCS_LOCAL_OPTS, ).split() vcs_global_opts = repoman_settings.get(REPOMAN_VCS_GLOBAL_OPTS) if vcs_global_opts is None: - if vcs not in [git, bzr]: + if vcs not in [git, bzr, hg]: vcs_global_opts = -q else: vcs_global_opts = @@ -932,6 +934,11 @@ bzrstatus = os.popen(bzr status -S .).readlines() mychanged = [ ./ + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and elem[1:2] == M ] mynew = [ ./ + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and ( elem[1:2] == NK or elem[0:1] == R ) ] +elif vcs == hg: + mychanged = os.popen(hg status --no-status --modified .).readlines() + mychanged = [./ + elem.rstrip() for elem in mychanged] + mynew = os.popen(hg status --no-status --added .).readlines() + mynew = [./ + elem.rstrip() for elem in mynew] if vcs: new_ebuilds.update(x for x in mynew if x.endswith(.ebuild)) @@ -1092,9 +1099,13 @@ s = s[s.rfind(\n) + 1:] fails[file.UTF8].append(%s/%s: line %i, just after: '%s' % (checkdir, y, line, s)) - if vcs == git and check_ebuild_notadded: - myf = os.popen(git ls-files --others %s % \ - (portage._shell_quote(checkdir_relative),)) + if vcs in (git, hg) and check_ebuild_notadded: + if vcs == git: + myf = os.popen(git ls-files --others %s % \ +(portage._shell_quote(checkdir_relative),)) + if vcs == hg: + myf = os.popen(hg status --no-status --unknown %s % \ +(portage._shell_quote(checkdir_relative),)) for l in myf: if l[:-1][-7:] == .ebuild: stats[ebuild.notadded] += 1 @@ -1259,7 +1270,7 @@ # It will be generated on server side from scm log, # before package moves to the rsync server. # This is needed because we try to avoid merge collisions. - if vcs not in ( git, ) and ChangeLog not in checkdirlist: + if vcs not in ( git, hg ) and ChangeLog not in checkdirlist: stats[changelog.missing]+=1 fails[changelog.missing].append(x+/ChangeLog) @@ -1977,6 +1988,15 @@ raise # TODO propogate this except: err(Error retrieving bzr info; exiting.) + if vcs == hg: + myunadded = os.popen(hg status --no-status --unknown .).readlines() + myunadded = [./ + elem.rstrip() for elem in myunadded] + + # Mercurial doesn't handle manually deleted files as removed from + # the repository, so the user need to remove them before commit, + # using hg remove [FILES] + mydeleted = os.popen(hg status --no-status --deleted .).readlines() + mydeleted = [./ + elem.rstrip() for elem in mydeleted] myautoadd=[] @@ -2002,6 +2022,8 @@ print((git add + .join(myautoadd)+)) elif vcs == bzr: print((bzr add + .join(myautoadd)+)) + elif vcs == hg: +print((hg add + .join(myautoadd)+)) retval=0 else: if vcs == cvs: @@ -2012,6 +2034,8 @@ retval=os.system(git add + .join(myautoadd)) elif vcs == bzr: retval=os.system(bzr add + .join(myautoadd)) + elif vcs == hg: +retval=os.system(hg add + .join(myautoadd)) if retval: writemsg_level(!!! Exiting on %s (shell) error code: %s\n % \ (vcs, retval), level=logging.ERROR, noiselevel=-1) @@ -2026,6 +2050,15 @@ print() sys.exit(1) + if vcs == hg and mydeleted: + print(red(!!! The following files are removed manually from your local tree but are not)) + print(red(!!! removed from the repository. Please remove them, using \hg remove [FILES]\.)) + for x in mydeleted: + print( ,x) + print() + print() + sys.exit(1) + if vcs == cvs: mycvstree = cvstree.getentries(./, recursive=1) mychanged = cvstree.findchanged(mycvstree, recursive=1, basedir=./) @@ -2084,8 +2117,16 @@ myremoved = [ ./ + elem.split()[-3:-2][0].split('/')[-1:][0] for elem in bzrstatus if elem and ( elem[1:2] == K or elem[0:1] == R ) ] # Bazaar expands nothing. + if vcs == hg: + mychanged = os.popen(hg status --no-status --modified .).readlines() + mychanged = [./ + elem.rstrip() for elem in mychanged] + mynew = os.popen(hg status --no-status --added .).readlines() + mynew = [./ + elem.rstrip() for elem in mynew] + myremoved = os.popen(hg status --no-status --removed .).readlines() + myremoved = [./ + elem.rstrip() for elem in myremoved] + if vcs: - if not (mychanged or mynew or myremoved): + if not (mychanged or mynew or myremoved or (vcs == hg and mydeleted)): print(green(RepoMan sez:), \Doing nothing is not always good for QA.\) print() print((Didn't find any changed files...)) @@ -2101,7 +2142,7 @@ mymanifests.add(f)
[gentoo-portage-dev] Re: [PATCH] Add support to Mercurial SCM in bin/repoman
I'm re-sending the patch, with a small fix. Please disregard the previous patch. Sorry. -- Rafael Goncalves Martins http://rafaelmartins.eng.br Index: bin/repoman === --- bin/repoman (revision 15200) +++ bin/repoman (working copy) @@ -486,11 +486,13 @@ vcs = git elif os.path.isdir(os.path.join(portdir_overlay, .bzr)): vcs = bzr +elif os.path.isdir(os.path.join(portdir_overlay, .hg)): + vcs = hg vcs_local_opts = repoman_settings.get(REPOMAN_VCS_LOCAL_OPTS, ).split() vcs_global_opts = repoman_settings.get(REPOMAN_VCS_GLOBAL_OPTS) if vcs_global_opts is None: - if vcs not in [git, bzr]: + if vcs not in [git, bzr, hg]: vcs_global_opts = -q else: vcs_global_opts = @@ -932,6 +934,11 @@ bzrstatus = os.popen(bzr status -S .).readlines() mychanged = [ ./ + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and elem[1:2] == M ] mynew = [ ./ + elem.split()[-1:][0].split('/')[-1:][0] for elem in bzrstatus if elem and ( elem[1:2] == NK or elem[0:1] == R ) ] +elif vcs == hg: + mychanged = os.popen(hg status --no-status --modified .).readlines() + mychanged = [./ + elem.rstrip() for elem in mychanged] + mynew = os.popen(hg status --no-status --added .).readlines() + mynew = [./ + elem.rstrip() for elem in mynew] if vcs: new_ebuilds.update(x for x in mynew if x.endswith(.ebuild)) @@ -1092,9 +1099,13 @@ s = s[s.rfind(\n) + 1:] fails[file.UTF8].append(%s/%s: line %i, just after: '%s' % (checkdir, y, line, s)) - if vcs == git and check_ebuild_notadded: - myf = os.popen(git ls-files --others %s % \ - (portage._shell_quote(checkdir_relative),)) + if vcs in (git, hg) and check_ebuild_notadded: + if vcs == git: + myf = os.popen(git ls-files --others %s % \ +(portage._shell_quote(checkdir_relative),)) + if vcs == hg: + myf = os.popen(hg status --no-status --unknown %s % \ +(portage._shell_quote(checkdir_relative),)) for l in myf: if l[:-1][-7:] == .ebuild: stats[ebuild.notadded] += 1 @@ -1259,7 +1270,7 @@ # It will be generated on server side from scm log, # before package moves to the rsync server. # This is needed because we try to avoid merge collisions. - if vcs not in ( git, ) and ChangeLog not in checkdirlist: + if vcs not in ( git, hg ) and ChangeLog not in checkdirlist: stats[changelog.missing]+=1 fails[changelog.missing].append(x+/ChangeLog) @@ -1977,6 +1988,15 @@ raise # TODO propogate this except: err(Error retrieving bzr info; exiting.) + if vcs == hg: + myunadded = os.popen(hg status --no-status --unknown .).readlines() + myunadded = [./ + elem.rstrip() for elem in myunadded] + + # Mercurial doesn't handle manually deleted files as removed from + # the repository, so the user need to remove them before commit, + # using hg remove [FILES] + mydeleted = os.popen(hg status --no-status --deleted .).readlines() + mydeleted = [./ + elem.rstrip() for elem in mydeleted] myautoadd=[] @@ -2002,6 +2022,8 @@ print((git add + .join(myautoadd)+)) elif vcs == bzr: print((bzr add + .join(myautoadd)+)) + elif vcs == hg: +print((hg add + .join(myautoadd)+)) retval=0 else: if vcs == cvs: @@ -2012,6 +2034,8 @@ retval=os.system(git add + .join(myautoadd)) elif vcs == bzr: retval=os.system(bzr add + .join(myautoadd)) + elif vcs == hg: +retval=os.system(hg add + .join(myautoadd)) if retval: writemsg_level(!!! Exiting on %s (shell) error code: %s\n % \ (vcs, retval), level=logging.ERROR, noiselevel=-1) @@ -2026,6 +2050,15 @@ print() sys.exit(1) + if vcs == hg and mydeleted: + print(red(!!! The following files are removed manually from your local tree but are not)) + print(red(!!! removed from the repository. Please remove them, using \hg remove [FILES]\.)) + for x in mydeleted: + print( ,x) + print() + print() + sys.exit(1) + if vcs == cvs: mycvstree = cvstree.getentries(./, recursive=1) mychanged = cvstree.findchanged(mycvstree, recursive=1, basedir=./) @@ -2084,8 +2117,16 @@ myremoved = [ ./ + elem.split()[-3:-2][0].split('/')[-1:][0] for elem in bzrstatus if elem and ( elem[1:2] == K or elem[0:1] == R ) ] # Bazaar expands nothing. + if vcs == hg: + mychanged = os.popen(hg status --no-status --modified .).readlines() + mychanged = [./ + elem.rstrip() for elem in mychanged] + mynew = os.popen(hg status --no-status --added .).readlines() + mynew = [./ + elem.rstrip() for elem in mynew] + myremoved = os.popen(hg status --no-status --removed .).readlines() + myremoved = [./ + elem.rstrip() for elem in myremoved] + if vcs: - if not (mychanged or mynew or myremoved): + if not (mychanged or mynew or myremoved or (vcs == hg and mydeleted)): print(green(RepoMan sez:), \Doing nothing is not always good for QA.\) print() print((Didn't find any changed files...)) @@ -2101,7 +2142,7 @@ mymanifests.add(f) else: