Skip to content

Commit 1c25f00

Browse files
committed
Add argument to enhance portability: --git
1 parent 4498f5f commit 1c25f00

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

build_docs.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,18 @@ def shell_out(cmd):
6464

6565

6666
def build_one(version, isdev, quick, sphinxbuild, build_root, www_root,
67-
skip_cache_invalidation=False, group='docs'):
67+
skip_cache_invalidation=False, group='docs', git=False):
6868
checkout = build_root + "/python" + str(version).replace('.', '')
6969
target = www_root + "/" + str(version)
7070
logging.info("Doc autobuild started in %s", checkout)
7171
os.chdir(checkout)
7272

7373
logging.info("Updating checkout")
74-
shell_out("hg pull -u")
74+
if git:
75+
shell_out("git reset --hard HEAD")
76+
shell_out("git pull --ff-only")
77+
else:
78+
shell_out("hg pull -u")
7579

7680
maketarget = "autobuild-" + ("dev" if isdev else "stable") + ("-html" if quick else "")
7781
logging.info("Running make %s", maketarget)
@@ -176,6 +180,10 @@ def parse_args():
176180
"--group",
177181
help="Group files on targets and www-root file should get.",
178182
default="docs")
183+
parser.add_argument(
184+
"--git",
185+
help="Use git instead of mercurial.",
186+
action="store_true")
179187
return parser.parse_args()
180188

181189

@@ -194,12 +202,12 @@ def parse_args():
194202
build_one(args.branch, args.devel, args.quick, sphinxbuild,
195203
args.build_root, args.www_root,
196204
args.skip_cache_invalidation,
197-
args.group)
205+
args.group, args.git)
198206
else:
199207
for version, devel in BRANCHES:
200208
build_one(version, devel, args.quick, sphinxbuild,
201209
args.build_root, args.www_root,
202-
args.skip_cache_invalidation, args.group)
210+
args.skip_cache_invalidation, args.group, args.git)
203211
build_devguide(args.devguide_checkout, args.devguide_target,
204212
sphinxbuild, args.skip_cache_invalidation)
205213
except Exception:

0 commit comments

Comments
 (0)