Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
2e1d92c2
Commit
2e1d92c2
authored
Jan 14, 2014
by
jctanner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5141 from kisielk/hg
hg module: Don't modify hgrc when running purge
parents
e4d0ce5b
23009027
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
42 deletions
+6
-42
library/source_control/hg
+6
-42
No files found.
library/source_control/hg
View file @
2e1d92c2
...
...
@@ -59,9 +59,7 @@ options:
choices: [ "yes", "no" ]
purge:
description:
- Deletes untracked files. Runs C(hg purge). Note this requires C(purge) extension to
be enabled if C(purge=yes). This module will modify hgrc file on behalf of the user
and undo the changes before exiting the task.
- Deletes untracked files. Runs C(hg purge).
required: false
default: "no"
choices: [ "yes", "no" ]
...
...
@@ -85,36 +83,6 @@ EXAMPLES = '''
- hg: repo=https://bitbucket.org/user/repo1 dest=/home/user/repo1 revision=stable purge=yes
'''
def
_set_hgrc
(
hgrc
,
vals
):
parser
=
ConfigParser
.
SafeConfigParser
()
parser
.
read
(
hgrc
)
# val is a list of triple-tuple of the form [(section, option, value),...]
for
each
in
vals
:
(
section
,
option
,
value
)
=
each
if
not
parser
.
has_section
(
section
):
parser
.
add_section
(
section
)
parser
.
set
(
section
,
option
,
value
)
f
=
open
(
hgrc
,
'w'
)
parser
.
write
(
f
)
f
.
close
()
def
_undo_hgrc
(
hgrc
,
vals
):
parser
=
ConfigParser
.
SafeConfigParser
()
parser
.
read
(
hgrc
)
for
each
in
vals
:
(
section
,
option
,
value
)
=
each
if
parser
.
has_section
(
section
):
parser
.
remove_option
(
section
,
option
)
f
=
open
(
hgrc
,
'w'
)
parser
.
write
(
f
)
f
.
close
()
class
Hg
(
object
):
def
__init__
(
self
,
module
,
dest
,
repo
,
revision
,
hg_path
):
...
...
@@ -129,7 +97,8 @@ class Hg(object):
return
(
rc
,
out
,
err
)
def
_list_untracked
(
self
):
return
self
.
_command
([
'purge'
,
'-R'
,
self
.
dest
,
'--print'
])
args
=
[
'purge'
,
'--config'
,
'extensions.purge='
,
'-R'
,
self
.
dest
,
'--print'
]
return
self
.
_command
(
args
)
def
get_revision
(
self
):
"""
...
...
@@ -168,10 +137,6 @@ class Hg(object):
return
True
def
purge
(
self
):
hgrc
=
os
.
path
.
join
(
self
.
dest
,
'.hg/hgrc'
)
purge_option
=
[(
'extensions'
,
'purge'
,
''
)]
_set_hgrc
(
hgrc
,
purge_option
)
# enable purge extension
# before purge, find out if there are any untracked files
(
rc1
,
out1
,
err1
)
=
self
.
_list_untracked
()
if
rc1
!=
0
:
...
...
@@ -179,10 +144,9 @@ class Hg(object):
# there are some untrackd files
if
out1
!=
''
:
(
rc2
,
out2
,
err2
)
=
self
.
_command
([
'purge'
,
'-R'
,
self
.
dest
])
if
rc2
==
0
:
_undo_hgrc
(
hgrc
,
purge_option
)
else
:
args
=
[
'purge'
,
'--config'
,
'extensions.purge='
,
'-R'
,
self
.
dest
]
(
rc2
,
out2
,
err2
)
=
self
.
_command
(
args
)
if
rc2
!=
0
:
self
.
module
.
fail_json
(
msg
=
err2
)
return
True
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment