Kiln » Kiln Extensions
Clone URL:  
Pushed to 2 repositories · View In Graph Contained in tip

Kiln 3.0.155 extensions

Changeset 2b92642bde25

Parent aaeadefa6ecd

by Profile picture of William ZimrinWilliam Zimrin

Changes to 8 files · Browse files at 2b92642bde25 Showing diff from parent aaeadefa6ecd Diff from another changeset...

Change 1 of 5 Show Entire File kiln.py Stacked
 
179
180
181
182
 
183
184
185
 
564
565
566
567
568
569
570
571
572
573
574
575
576
 
 
 
 
577
 
 
578
579
580
 
582
583
584
585
586
587
588
589
590
 
 
 
 
 
 
 
 
 
 
 
 
591
592
593
 
619
620
621
 
 
622
623
 
624
625
626
 
986
987
988
989
990
991
992
993
994
995
996
997
998
999
 
179
180
181
 
182
183
184
185
 
564
565
566
 
 
 
 
 
 
 
 
 
 
567
568
569
570
571
572
573
574
575
576
 
578
579
580
 
 
 
 
 
 
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
 
621
622
623
624
625
626
 
627
628
629
630
 
990
991
992
 
 
 
 
 
 
 
 
993
994
995
@@ -179,7 +179,7 @@
  except AttributeError:   # Mercurial <= 1.8   url = hgurl.removeauth(remote.url()) - if url.lower().find('/kiln/') > 0 or url.lower().find('kilnhg.com/') > 0: + if url.lower().find('/kiln/') > 0 or url.lower().find('kilnhg.com/') > 0 or url.lower().find('kilnhg.dev.local/') > 0:   return url   else:   return None @@ -564,17 +564,13 @@
     def get_targets(repo): - def get_kiln_repo_url_prefix(default_prefix): - '''Checks repo paths and returns server url for ssh:. For http(s) falls back to default_prefix.''' - default_path = repo.ui.config('paths', 'default') - if default_path and default_path.startswith('ssh:'): - return default_path.rsplit('/', 3)[0] - return default_prefix - targets = [] - kilnschemes = repo.ui.configitems('kiln_scheme') - for scheme in kilnschemes: - url = scheme[1] + targets = set() + urls = repo.ui.configitems('paths') + for tup in urls: + url = tup[1]   baseurl = get_api_url(url) + if baseurl is None or baseurl.startswith('ssh:'): + continue     tails = get_tails(repo)   token = get_token(repo.ui, baseurl) @@ -582,12 +578,18 @@
  # We have an token at this point   params = dict(revTails=tails, token=token)   related_repos = call_api(repo.ui, baseurl, 'Api/1.0/Repo/Related', params) - targets.extend([[get_kiln_repo_url_prefix(url), - related_repo['sProjectSlug'], - related_repo['sGroupSlug'], - related_repo['sSlug'], - [a['sSlug'] for a in related_repo.get('rgAliases', [])]] for related_repo in related_repos]) - return targets + stripped = baseurl.rstrip('/') + if not stripped.startswith('ssh:'): + stripped += "/Code" + related = [(stripped, + related_repo['sProjectSlug'], + related_repo['sGroupSlug'], + related_repo['sSlug'], + tuple(a['sSlug'] for a in related_repo.get('rgAliases', []))) for related_repo in related_repos] + targets = targets.union(related) + out = list(targets) + out.sort() + return out      def display_targets(repo): @@ -619,8 +621,10 @@
  baseurl = url[:url.lower().find('kilnhg.com/') + 11]   elif '/kiln/' in url.lower():   baseurl = url[:url.lower().find('/kiln/') + 6] + elif 'kilnhg.dev.local/' in url.lower(): + baseurl = url[:url.lower().find('kilnhg.dev.local/') + 17]   else: - baseurl = url + baseurl = None   return baseurl     @@ -986,14 +990,6 @@
   def extsetup(ui):   try: - g = extensions.find('gestalt') - extensions.wrapcommand(g.cmdtable, 'overview', guess_kilnpath) - extensions.wrapcommand(g.cmdtable, 'advice', guess_kilnpath) - extensions.wrapcommand(g.cmdtable, 'next', guess_kilnpath) - except KeyError: - pass - - try:   f = extensions.find('fetch')   extensions.wrapcommand(f.cmdtable, 'fetch', guess_kilnpath)   except KeyError:
Change 1 of 1 Show Entire File tests/​README Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@@ -0,0 +1,19 @@
+Run tests with "python tests/runner.py" from any directory. + +You can run an individual test with "python tests/test-mytest.py". + +The tester must have the url and login info for a kiln instance. +By default, the tests connect to "your.kilnhg.dev.local" with the +username "test" and password "tester". This is configured in +tests/custom.py. You can override these defaults by passing in +--kilnurl, --user, and/or --password arguments to the runner or +individual tests. kilnurl must be a http url so that kilnauth can +be tested. python runner.py -h (or python test-*.py -h) will +print out usage information. + +Note that the extension files must be in the parent of the +directory with runner.py, custom.py, and test-*.py. + +hostfingerprints should be set up such that +you can talk to your dev instance without spamming security +warning.
Change 1 of 1 Show Entire File tests/​custom.py Stacked
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
@@ -0,0 +1,7 @@
+#These variables determine the default values for +#the command line parameters. Passing in --kilnurl, +#--user, or --password will override the values here. + +KILNURL = 'http://your.kilnhg.dev.local' +USER = 'test' +PASSWORD = 'tester'
Change 1 of 1 Show Entire File tests/​hgtest.py Stacked
 
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
@@ -1,2 +1,418 @@
-import bfpath -from tests.hgtest import * +""" +Experimental testing framework for Mercurial and its extensions. +The goal is to allow tests to be Python scripts rather than shell +scripts. They should be: + * more portable + * possibly faster + * much easier to understand and modify + * somewhat easier to write + +""" + +import argparse +import sys +import os +import re +import atexit +import subprocess +import traceback +import shutil +import getpass +import json +import time +from urllib import urlencode +import urllib2 +from custom import * + +ANYTHING = re.compile(r'') + +CURDIR = os.path.dirname(os.path.realpath(__file__)) +TESTDIR = os.path.join(CURDIR, "tmp") +EXTDIR = os.path.dirname(CURDIR) + +HGARGS = [ + "--config", + "extensions.kiln=" + os.path.join(EXTDIR, "kiln.py"), + "--config", + "extensions.kilnauth=" + os.path.join(EXTDIR, "kilnauth.py"), + "--config", + "extensions.big-push=" + os.path.join(EXTDIR, "big-push.py") +] + +# Ensure that the home directory is set appropriately so that the kilnauth +# cookies will be found. This is important because Mercurial 1.9 and later +# changes the home directory in the test script. +os.environ['HOME'] = os.path.expanduser('~' + getpass.getuser()); + + +class Failure(Exception): + pass + +def parse_args(): + parser = argparse.ArgumentParser(description='Test the hg command line') + parser.add_argument('--user', default=USER, dest='user') + parser.add_argument('--password', default=PASSWORD, dest='password') + parser.add_argument('--kilnurl', default=KILNURL, dest='kilnurl') + return parser.parse_args() + + + +class Tester(object): + """ + Default test framework. Is fairly verbose: writes each announcement + and each hg command to stdout. + """ + + ANYTHING = ANYTHING + + def __init__(self, auth = True): + """ + auth: whether the tester should automatically supply the username + and password to hg. Defaults to true. + """ + self.stdout = sys.stdout + self.failures = [] + atexit.register(self._atexit) + self.firstannounce = True + self._clear_test_dir() + self.auth = auth + self.s_project = None + self.ix_group = None + + args = parse_args() + self.kilnurl = args.kilnurl + self.user = args.user + self.password = args.password + + self.auth_args = [ + "--config", "auth.test.prefix=" + self.kilnurl, + "--config", "auth.test.username=" + self.user, + "--config", "auth.test.password=" + self.password + ] + os.chdir(TESTDIR) + + def init_project(self, token): + if self.s_project is not None: + return + self.s_project = "ExtTest-"+str(int(time.time())) + proj = self.slurp(self.api("Project/Create"), { "sName": self.s_project, "token": token }, True) + ixProject = proj["ixProject"] + group = self.slurp(self.api("RepoGroup/Create"), { "sName": "Test", "ixProject": ixProject, "token": token}, True) + self.ix_group = group["ixRepoGroup"] + + def test_url(self): + return self.kilnurl + "/Code/" + self.s_project + "/Test/Test" + + def test_branch_url(self): + return self.kilnurl + "/Code/" + self.s_project + "/Test/TestBranch" + + def api(self, url): + return self.kilnurl + '/api/1.0/' + url + + def slurp(self, url, params={}, post=False, raw=False): + params = urlencode(params, doseq=True) + handle = urllib2.urlopen(url, params) if post else urllib2.urlopen(url + '?' + params) + content = handle.read() + obj = content if raw else json.loads(content) + handle.close() + return obj + + def gettoken(self): + return self.slurp(self.api('Auth/Login'), dict(sUser=self.user, sPassword=self.password)) + + def createtest(self, token): + self.init_project(token) + + repo = self.slurp(self.api('Repo/Create'), dict(sName='Test', sDescription='test', ixRepoGroup=self.ix_group, sDefaultPermission='write', token=token)) + ixRepo = repo['ixRepo'] + + self.asserttrue(isinstance(ixRepo, int), 'Create failed %s' % (str(ixRepo))) + + time.sleep(1) + while True: + # work around a known bug in Kiln that returns non-JSON data for this + # API route so that we don't have "ignorable tests" in bfiles + try: + if self.slurp(self.api('Repo/%d' % ixRepo), dict(token=token))['sStatus'] == 'good': + break + except ValueError: + pass + time.sleep(0.1) + + return (self.kilnurl + '/Code/Test/Test/Test', ixRepo) + + def createtestbranch(self, token, ixParent): + self.init_project(token) + parent = self.slurp(self.api('Repo/%d' % ixParent), dict(token=token)) + while parent['sStatus'] != 'good' or not parent['fHasChangesets']: + time.sleep(0.1) + parent = self.slurp(self.api('Repo/%d' % ixParent), dict(token=token)) + + + repo = self.slurp(self.api('Repo/Create'), dict(sName='TestBranch', sDescription='test branch', ixRepoGroup=self.ix_group, ixParent=ixParent, fCentral=False, sDefaultPermission='write', token=token)) + ixRepo = repo['ixRepo'] + + self.asserttrue(isinstance(ixRepo, int), 'Create failed %s' % (str(ixRepo))) + + time.sleep(1) + while self.slurp(self.api('Repo/%d' % ixRepo), dict(token=token))['sStatus'] != 'good': + time.sleep(0.1) + + return (self.kilnurl + '/Code/Test/Test/TestBranch', ixRepo) + + def deletetest(self, token): + if self.s_project is None: + return + + projects = self.slurp(self.api('Project'), dict(token=token)) + + found = False + foundbranch = False + for project in projects: + if project['sName'] == self.s_project: + ixProject = project['ixProject'] + for group in project['repoGroups']: + if group['sName'] == 'Test': + ixRepoGroup = group['ixRepoGroup'] + for repo in group['repos']: + if repo['sName'] == 'Test': + ixRepo = repo['ixRepo'] + found = True + if repo['sName'] == 'TestBranch': + ixBranch = repo['ixRepo'] + foundbranch = True + + if foundbranch: + self.slurp(self.api('Repo/%d/Delete' % ixBranch), dict(token=token), post=True) + if found: + self.slurp(self.api('Repo/%d/Delete' % ixRepo), dict(token=token), post=True) + + def _atexit(self): + if self.failures: + sys.stderr.write('%d failures\n' % len(self.failures)) + sys.exit(1) + + def _clear_test_dir(self): + if os.path.exists(TESTDIR): + shutil.rmtree(TESTDIR) + os.mkdir(TESTDIR) + + def announce(self, msg): + if self.firstannounce: + msg = '% ' + msg + '\n' + self.firstannounce = False + else: + msg = '\n% ' + msg + '\n' + self.stdout.write(msg) + self.stdout.flush() + + def hg(self, args, stdout='', stderr='', status=0, log=True, auth=False, stdin=None): + """ + Run an hg command and check that it output the specified text to + stdout and stderr and returned the specified status. stdout and + stderr may be strings for exact comparison or re pattern objects + for a regex comparison. The constant ANYTHING conveniently + matches any output, for when you don't care. Auth determines + whether the username and password will automatically be passed in + to hg. If either the auth argument or tester.auth is true, the + login info is passed. + """ + + # XXX should use exact path to hg + # XXX set PYTHONPATH? + + hgname = 'hg' + if auth or self.auth: + cmd = [hgname] + HGARGS + self.auth_args + args + else: + cmd = [hgname] + HGARGS + args + if log: + self._logcmd(['hg'] + args) + if stdin is None: + stdin_arg = None + else: + stdin_arg = subprocess.PIPE + child = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + stdin=stdin_arg, + universal_newlines=True) + + actual_stdout, actual_stderr = child.communicate(input=stdin) + actual_status = child.returncode + if os.name == 'nt' and actual_status < 0: + # hack to match my Unix-centric expected status + # (Mercurial actually exits with status -1, and the signedness + # is preserved in Windows but wrapped around to 255 on Unix) + actual_status += 256 + + self.assertoutput(stdout, actual_stdout, 'stdout', cmd) + self.assertoutput(stderr, actual_stderr, 'stderr', cmd) + if isinstance(status, list): + self.asserttrue(actual_status in status, "Status doesn't match") + elif status == -1: + self.asserttrue(actual_status != 0, "Status should be non-zero, is 0") + else: + self.assertequals(status, actual_status) + self._failearly() + + def tjoin(self, *path): + '''Return the path to filename in $TESTDIR.''' + return os.path.join(TESTDIR, *path) + + def writefile(self, filename, content, mode='w'): + '''Write content to filename. By default, clobber the file and + write in text mode; override mode to append and/or write in + binary mode.''' + dirname = os.path.dirname(filename) + if dirname != '' and not os.path.exists(dirname): + os.makedirs(dirname) + + f = open(filename, mode) + try: + f.write(content) + finally: + f.close() + + def readfile(self, filename, mode='r'): + f = open(filename, mode) + try: + return f.read() + finally: + f.close() + + def assertfalse(self, test, msg): + if test: + self._fail(msg) + + def asserttrue(self, test, msg): + if not test: + self._fail(msg) + + def assertequals(self, expect, actual, prefix=''): + if expect != actual: + if prefix: + prefix += ': ' + if isinstance(expect, list): + msg = self._listfailure(expect, actual, prefix) + else: + msg = prefix + self._shortfailure(expect, actual) + self._fail(msg) + + def expect_str(self, expect): + if isinstance(expect, list): + return "\n".join(map(lambda s: s+"*", expect)) + else: + return str(expect) + + def assertoutput(self, expect, actual, label, cmd): + '''Assert that the actual output (stdout or stderr) of cmd matches + the expected output.''' + filtered = self._filteroutput(actual) + if self._stringmatch(expect, filtered): + # silence is golden, so say nothing on success + return + + msg = self._bannerbracket( + 'cmd:', + str(cmd), + '%s %s:' % ('expected', label), + self.expect_str(expect), + '%s %s:' % ('actual (filtered)', label), + str(filtered)) + self._fail(msg) + + # -- Internal methods ---------------------------------------------- + + def _shortfailure(self, expect, actual): + return 'expected %r, but got %r' % (expect, actual) + + def _listfailure(self, expect, actual, prefix): + return self._bannerbracket( + '%s%s:' % (prefix, 'expected'), + '\n'.join([' %r' % v for v in expect]) + '\n', + '%s%s:' % (prefix, 'actual'), + '\n'.join([' %r' % v for v in actual]) + '\n') + + def _bannerbracket(self, *items): + banner = True + out = "\n" + for line in items: + if banner: + out += ('-- %s ' % line).ljust(60, '-') + banner = False + else: + out += line + banner = True + out += "\n" + out += '-'*60 + return out + + + def _fail(self, msg): + self.stdout.write('FAIL: %s\n' % msg) + + # print a stack trace up to the point where we entered this module + sys.stdout.write('failure context:\n') + stack = traceback.extract_stack() + modfile = sys.modules[__name__].__file__ + modfile = re.sub(r'\.py[co]$', '.py', modfile) + while stack[-1][0] == modfile: + del stack[-1] + for line in traceback.format_list(stack): + sys.stdout.write(line) + + self.failures.append(msg) + + def _failearly(self): + if self.failures: + raise Failure() + + def report(self): + if self.failures: + sys.exit("%i tests failed" % len(self.failures)) + sys.exit() + + def _stringmatch(self, expect, actual): + if isinstance(expect, list): + actual = actual.rstrip().split('\n') + if len(actual) != len(expect): + return False + for i in xrange(len(actual)): + if not actual[i].startswith(expect[i]): + return False + return True + else: + return expect.rstrip() == actual.rstrip() + + unsafechars = re.compile(r'[^a-zA-Z0-9\-\_\+\.\/\=\:]') + + def _logcmd(self, cmd): + vcmd = [] + sep = os.path.sep + unix = (sep == '/') + for arg in cmd: + if not unix and sep in arg: + arg = arg.replace(sep, '/') + if self.unsafechars.search(arg): + arg = '\'' + arg.replace('\'', '\\\'') + '\'' + val = TESTDIR.replace(sep, '/') + arg = arg.replace(val, '$TESTDIR') + vcmd.append(arg) + self.stdout.write(' '.join(vcmd) + '\n') + self.stdout.flush() + + def _filteroutput(self, output): + '''Filter Mercurial output to match test expectations. + - convert local path separator to Unix + - replace occurences of TESTDIR with pseudo-variable + expansion + ''' + sep = os.path.sep + unix = (sep == '/') + if not unix and sep in output: + output = output.replace(sep, '/') + val = TESTDIR.replace(sep, '/') + output = output.replace(val, '$TESTDIR') + return output
Change 1 of 1 Show Entire File tests/​runner.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
@@ -0,0 +1,34 @@
+import os +import subprocess +import sys +import hgtest + +path = os.path.dirname(os.path.realpath(__file__)) + +args = vars(hgtest.parse_args()) +arglist = [] +for opt, val in args.iteritems(): + arglist.extend(['--' + opt, val]) + +files = os.listdir(path) +failures = 0 + +for file in files: + if file.startswith("test") and file.endswith(".py"): + try: + child = subprocess.Popen(["python", os.path.join(path, file)] + arglist, + stdout=sys.stdout, + stderr=sys.stderr, + stdin=sys.stdin, + universal_newlines=True) + + ret = child.wait() + if ret != 0: + failures += 1 + except: + if child.poll(): + child.kill() + raise + +if failures > 0: + sys.exit("%i files failed" % failures) \ No newline at end of file
 
3
4
5
6
7
8
9
10
11
 
12
13
14
15
16
17
18
19
 
 
 
 
20
21
22
 
25
26
27
28
29
 
30
31
32
 
33
34
35
36
37
 
38
39
40
41
42
 
43
44
45
46
47
48
 
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
 
67
68
69
70
71
 
 
72
73
74
 
75
76
 
77
78
79
 
82
83
84
 
 
 
3
4
5
 
6
7
 
8
 
9
10
 
 
11
 
 
 
 
12
13
14
15
16
17
18
 
21
22
23
 
 
24
25
26
 
27
28
29
30
 
 
31
32
33
34
35
 
36
37
38
39
40
 
 
41
42
43
44
45
46
 
47
48
 
49
50
 
51
52
 
53
 
 
54
55
56
57
 
 
 
58
59
60
61
 
62
63
 
64
65
66
67
 
70
71
72
73
 
@@ -3,20 +3,16 @@
 # Test big-push extension    import os -import common    import hgtest -import kilntest   -hgt = common.BfilesTester() +hgt = hgtest.Tester()   -hgt.updaterc({'extensions': [('kilnauth', kilntest.KILNAUTHPATH), - ('big-push', kilntest.BIGPUSHPATH)]})  hgt.announce('setup') -token = kilntest.gettoken() -kilntest.deletetest(hgt, token) -test = kilntest.createtest(hgt, token) -hgt.hg(['clone', kilntest.KILNURL + '/Repo/Test/Test/Test', 'repo1'], log=False, +token = hgt.gettoken() +hgt.deletetest(token) +test = hgt.createtest(token) +hgt.hg(['clone', hgt.test_url(), 'repo1'], log=False,   stdout='''no changes found  updating to branch default  0 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -25,55 +21,47 @@
 hgt.writefile('n1', 'n1')  hgt.hg(['add', 'n1'])  hgt.hg(['commit', '-m', 'add file']) -hgt.hg(['push'], stdout='''pushing to %s/Repo/Test/Test/Test -searching for changes +hgt.hg(['push'], stdout='''pushing to %s  searching for changes  remote: kiln: successfully pushed one changeset -''' % kilntest.KILNURL) +''' % hgt.test_url())  hgt.writefile('n2', 'n2')  hgt.hg(['add', 'n2'])  hgt.hg(['commit', '-m', 'add another file']) -hgt.hg(['push', '--chunked'], stdout='''pushing to %s/Repo/Test/Test/Test -searching for changes +hgt.hg(['push', '--chunked'], stdout='''pushing to %s  searching for changes  searching for changes  searching for changes  remote: kiln: successfully pushed one changeset -''' % kilntest.KILNURL) +''' % hgt.test_url())  for i in range(3, 25):   hgt.writefile('n%d' % i, 'dummy')   hgt.hg(['add', 'n%d' % i])   hgt.hg(['commit', '-m', 'changeset %d' % i]) -hgt.hg(['push', '--chunked'], stdout='''pushing to %s/Repo/Test/Test/Test -searching for changes +hgt.hg(['push', '--chunked'], stdout='''pushing to %s  searching for changes  searching for changes  searching for changes  remote: kiln: successfully pushed one changeset  searching for changes -searching for changes  remote: kiln: successfully pushed 2 changesets  searching for changes -searching for changes  remote: kiln: successfully pushed 4 changesets  searching for changes -searching for changes  remote: kiln: successfully pushed 8 changesets  searching for changes -searching for changes  remote: kiln: successfully pushed 7 changesets -''' % kilntest.KILNURL) -hgt.hg(['pull'], stdout='''pulling from %s/Repo/Test/Test/Test +''' % hgt.test_url()) +hgt.hg(['pull'], stdout='''pulling from %s  searching for changes  no changes found -''' % kilntest.KILNURL) -hgt.hg(['push'], stdout='''pushing to %s/Repo/Test/Test/Test -searching for changes +''' % hgt.test_url()) +hgt.hg(['push'], stdout='''pushing to %s  searching for changes  no changes found -''' % kilntest.KILNURL) +''' % hgt.test_url())  os.chdir('..') -hgt.hg(['clone', kilntest.KILNURL + '/Repo/Test/Test/Test', 'repo2'], log=False, +hgt.hg(['clone', hgt.test_url(), 'repo2'], log=False,   stdout='''requesting all changes  adding changesets  adding manifests @@ -82,3 +70,4 @@
 updating to branch default  24 files updated, 0 files merged, 0 files removed, 0 files unresolved  ''') +hgt.report() \ No newline at end of file
Change 1 of 1 Show Entire File tests/​test-kilnauth.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@@ -0,0 +1,34 @@
+import hgtest +import os + +hgt = hgtest.Tester(auth=False) +hgt.announce('setup') +token = hgt.gettoken() +hgt.deletetest(token) +test = hgt.createtest(token) +hgt.hg(['clone', hgt.test_url(), 'repo1'], log=False, auth=True, + stdout='''no changes found +updating to branch default +0 files updated, 0 files merged, 0 files removed, 0 files unresolved +''') +os.chdir('repo1') + +hgt.hg(['logout']) + +hgt.hg(['pull'], stdin='\n\n', status=-1, + stderr='abort: http authorization required for %s' % hgt.test_url()) + +hgt.hg(['pull'], auth=True, + stdout='''pulling from %s +no changes found +''' % hgt.test_url()) + +hgt.hg(['pull'], + stdout='''pulling from %s +no changes found +''' % hgt.test_url()) + +hgt.hg(['logout']) + +hgt.hg(['pull'], stdin='\n\n', status=-1, + stderr='abort: http authorization required for %s' % hgt.test_url())
 
3
4
5
6
7
8
9
10
11
 
12
13
14
15
16
17
18
19
20
 
 
 
21
22
 
23
24
25
 
28
29
30
31
32
 
33
34
35
36
 
 
37
38
39
40
41
 
 
 
42
43
44
45
46
47
48
 
 
49
50
51
52
 
 
53
54
55
 
56
57
58
59
60
61
62
63
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
66
67
68
69
70
71
72
73
74
 
75
76
77
 
78
79
 
80
81
82
 
86
87
88
89
90
91
92
93
94
95
96
97
98
 
 
 
 
 
 
 
 
 
 
99
100
101
102
103
104
105
 
106
107
 
 
3
4
5
 
6
7
 
8
 
9
10
 
 
 
 
11
 
 
 
12
13
14
15
 
16
17
18
19
 
22
23
24
 
 
25
26
27
 
 
28
29
30
31
 
 
 
32
33
34
35
36
37
38
39
 
 
40
41
42
 
 
 
43
44
45
46
 
47
48
49
50
 
 
 
 
 
 
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
 
 
 
 
 
 
 
 
67
68
69
 
70
71
 
72
73
74
75
 
79
80
81
 
 
 
 
 
 
 
 
 
 
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
 
98
99
 
100
@@ -3,23 +3,17 @@
 # Test hg kiln -t and path guessing    import os -import common    import hgtest -import kilntest   -hgt = common.BfilesTester() +hgt = hgtest.Tester()   -hgt.updaterc({'extensions': [('kilnauth', kilntest.KILNAUTHPATH), - ('kiln', kilntest.KILNPATH)], - 'hostfingerprints': [('developers.kilnhg.com', 'fe:ab:65:89:7c:6f:1a:21:a8:39:54:6c:2a:cb:ca:ae:e9:e5:f0:01')], - 'kiln_scheme': [('kiln', kilntest.KILNURL + '/Repo')]})  hgt.announce('setup') -token = kilntest.gettoken() -kilntest.deletetest(hgt, token) -test = kilntest.createtest(hgt, token) +token = hgt.gettoken() +hgt.deletetest(token) +test = hgt.createtest(token)  testurl, ixParent = test -hgt.hg(['clone', kilntest.KILNURL + '/Repo/Test/Test/Test', 'repo1'], log=False, +hgt.hg(['clone', hgt.test_url(), 'repo1'], log=False,   stdout='''no changes found  updating to branch default  0 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -28,55 +22,54 @@
 hgt.writefile('n1', 'n1')  hgt.hg(['add', 'n1'])  hgt.hg(['commit', '-m', 'add file']) -hgt.hg(['push'], stdout='''pushing to %s/Repo/Test/Test/Test -searching for changes +hgt.hg(['push'], stdout='''pushing to %s  searching for changes  remote: kiln: successfully pushed one changeset -''' % kilntest.KILNURL) -testbranch = kilntest.createtestbranch(hgt, token, ixParent) +''' % hgt.test_url()) +testbranch = hgt.createtestbranch(token, ixParent)  hgt.hg(['kiln', '-t'], '''The following Kiln targets are available for this repository:   - %s/Repo/Test/Test/Test - %s/Repo/Test/Test/TestBranch -''' % (kilntest.KILNURL, kilntest.KILNURL)) + %s + %s +''' % (hgt.test_url(), hgt.test_branch_url()))  hgt.writefile('n2', 'n2')  hgt.hg(['add', 'n2'])  hgt.hg(['commit', '-m', 'add to central repository'])  hgt.hg(['push', 'Test'], status=255, stderr='''abort: Test matches more than one Kiln repository:   - %s/Repo/Test/Test/Test - %s/Repo/Test/Test/TestBranch + %s + %s   -''' % (kilntest.KILNURL, kilntest.KILNURL)) -hgt.hg(['push'], stdout='''pushing to %s/Repo/Test/Test/Test -searching for changes +''' % (hgt.test_url(), hgt.test_branch_url())) +hgt.hg(['push'], stdout='''pushing to %s  searching for changes  remote: kiln: successfully pushed one changeset -''' % kilntest.KILNURL) +''' % hgt.test_url())  hgt.writefile('n3', 'n3')  hgt.hg(['add', 'n3'])  hgt.hg(['commit', '-m', 'add to branch repository']) -hgt.hg(['outgoing', 'TestBranch'], stdout='''comparing with %s/Repo/Test/Test/TestBranch -searching for changes -changeset: 1:ab1d97532947 -user: test -date: Thu Jan 01 00:00:00 1970 +0000 -summary: add to central repository +hgt.hg(['outgoing', 'TestBranch'], stdout=[ + "comparing with %s" % hgt.test_branch_url(), + "searching for changes", + "changeset:", + "tag:", + "user:", + "date:", + "summary:", + "", + "changeset:", + "tag:", + "user:", + "date:", + "summary:" +])   -changeset: 2:b2faa98b26f6 -tag: tip -user: test -date: Thu Jan 01 00:00:00 1970 +0000 -summary: add to branch repository - -''' % kilntest.KILNURL) -hgt.hg(['push', 'TestBranch'], stdout='''pushing to %s/Repo/Test/Test/TestBranch -searching for changes +hgt.hg(['push', 'TestBranch'], stdout='''pushing to %s  searching for changes  remote: kiln: successfully pushed 2 changesets -''' % kilntest.KILNURL) +''' % hgt.test_branch_url())  os.chdir('..') -hgt.hg(['clone', kilntest.KILNURL + '/Repo/Test/Test/Test', 'repo2'], log=False, +hgt.hg(['clone', hgt.test_url(), 'repo2'], log=False,   stdout='''requesting all changes  adding changesets  adding manifests @@ -86,22 +79,22 @@
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved  ''')  os.chdir('repo2') -hgt.hg(['incoming', 'TestBranch'], stdout='''comparing with %s/Repo/Test/Test/TestBranch -searching for changes -changeset: 2:b2faa98b26f6 -tag: tip -user: test -date: Thu Jan 01 00:00:00 1970 +0000 -summary: add to branch repository - -''' % kilntest.KILNURL) -hgt.hg(['pull', 'TestBranch'], stdout='''pulling from %s/Repo/Test/Test/TestBranch +hgt.hg(['incoming', 'TestBranch'], stdout=[ + "comparing with %s" % hgt.test_branch_url(), + "searching for changes", + "changeset:", + "tag:", + "user:", + "date:", + "summary:" +]) +hgt.hg(['pull', 'TestBranch'], stdout='''pulling from %s  searching for changes  adding changesets  adding manifests  adding file changes  added 1 changesets with 1 changes to 1 files  (run 'hg update' to get a working copy) -''' % kilntest.KILNURL) +''' % hgt.test_branch_url())  os.chdir('..') - +hgt.report()