diff options
author | Marcin Owsiany <porridge> | 2010-10-05 23:24:11 +0000 |
---|---|---|
committer | Marcin Owsiany <porridge> | 2010-10-05 23:24:11 +0000 |
commit | 77cea79e8d6f881b7a687c02314655125072b0dd (patch) | |
tree | 50ee1c9d56fe1ceca5aa85fd1bfec900421afaf0 | |
parent | 7d7fc0458d96586841d831f1559f334dec57797f (diff) |
Adding a partial checkout update script.
CVS version numbers
Makefile: 1.45 -> 1.46
cvsup.py: INITIAL -> 1.1
english/devel/website/using_cvs.wml: 1.21 -> 1.22
-rw-r--r-- | Makefile | 5 | ||||
-rwxr-xr-x | cvsup.py | 72 | ||||
-rw-r--r-- | english/devel/website/using_cvs.wml | 5 |
3 files changed, 81 insertions, 1 deletions
@@ -10,7 +10,7 @@ LANGUAGES-install := $(addsuffix -install,$(LANGUAGES)) LANGUAGES-clean := $(addsuffix -clean,$(LANGUAGES)) .SUFFIXES: -.PHONY: install all clean $(LANGUAGES) $(LANGUAGES-install) +.PHONY: install all clean $(LANGUAGES) $(LANGUAGES-install) $(LANGUAGES-clean) list-languages all: $(LANGUAGES) @@ -26,3 +26,6 @@ $(LANGUAGES-clean): $(LANGUAGES): $(MAKE) -C $@ + +list-languages: + @echo $(LANGUAGES) diff --git a/cvsup.py b/cvsup.py new file mode 100755 index 00000000000..882ef999799 --- /dev/null +++ b/cvsup.py @@ -0,0 +1,72 @@ +#!/usr/bin/python +# A script to recursively update a CVS checkout, skipping directories for +# languages you do not know or care about. Useful for translators who only want +# a checkout of the directories for English and their own language. +# +# This special script is needed because: +# - "cvs up -d" will check out languages most people usually do not care about +# - however plain "cvs up" does not create directories newly created in the +# repository +# +# Copyright 2010 Marcin Owsiany <porridge@debian.org> + +import sys +import logging +import os +import subprocess + +logging.basicConfig(level=logging.INFO) + +logging.info('Getting list of entries in the repository.') +# Set LANG=C as we need to parse command output +env = dict(os.environ) +env['LANG'] = 'C' +lines = subprocess.Popen(['cvs', 'ls', '-l'], stdout=subprocess.PIPE, env=env).communicate()[0] +repo_dirs = set() +for line in lines.split('\n'): + if not line: + pass + elif line.startswith('-'): + pass + elif line.startswith('d'): + repo_dirs.add(line.split(None, 4)[4]) + else: + logging.warn('Unexpected line: %s', line) + +logging.info('Getting list of known languages.') +lines = subprocess.Popen(['make', 'list-languages'], stdout=subprocess.PIPE).communicate()[0] +langs = set(lines.split()) + +logging.info('Getting list of checked-out directories.') +local_dirs = set(e for e in os.listdir('.') if os.path.isdir(e)) + +logging.debug('Dirs in repo: %s', ' '.join(sorted(repo_dirs))) +logging.debug('LANGS : %s', ' '.join(sorted(langs))) +logging.debug('Dirs in . : %s', ' '.join(sorted(local_dirs))) + +# We want: +# - all currently checked out directories (i.e. ones that exist locally and in +# the repository) +checked_out = local_dirs.intersection(repo_dirs) +# - all directories in repo that are not langs +specials = repo_dirs - langs +# However we do not want e.g. stale language directories which are being +# transitioned to a new name. So we keep a list of known non-language +# directories, and we warn (and ignore) if the above encounters anything else. +known_specials = set(['Perl', 'po']) +mysterious = specials - known_specials + +to_update = known_specials | checked_out +if to_update: + logging.info('Updating recursively: %s', ' '.join(to_update)) + subprocess.Popen(['cvs', '-q', 'up', '-dP'] + sorted(list(to_update))).wait() +else: + logging.warn('No directories to update recursively.') +logging.info('Updating current directory.') +subprocess.Popen(['cvs', '-q', 'up', '-lP']).wait() + +if mysterious: + logging.warn('The following directories exist in repo but are neither ' + 'known special dirs nor in LANGUAGES in top Makefile. ' + 'Please delete them or add to known_specials in %s: %s', + sys.argv[0], ' '.join(mysterious)) diff --git a/english/devel/website/using_cvs.wml b/english/devel/website/using_cvs.wml index fa681e73cb1..c6dae6a04ad 100644 --- a/english/devel/website/using_cvs.wml +++ b/english/devel/website/using_cvs.wml @@ -76,6 +76,11 @@ part. Every few days you will want to do a <p>to retrieve any files from the repository which have changed. The <code>-d</code> update option will add any new directories, automatically. +It will also check out all the directories that were omitted if you performed a +partial checkout — in that case you might want to use the +<code>cvsup.py</code> script. + +<p> You may want to create a <code>~/.cvsrc</code> file so that you don't have to type some options all the time. For example, it can contain: |